Skip to content

Commit

Permalink
Centralize lint configuration (#3055)
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte authored Nov 30, 2024
1 parent 2eaed0b commit d84136e
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 161 deletions.
38 changes: 38 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,41 @@ resolver = "2"

[workspace.package]
rust-version = "1.75"

[workspace.lints.rust]
unsafe_code = "forbid"

rust_2018_idioms = { level = "warn", priority = -1 }
missing_debug_implementations = "warn"
missing_docs = "warn"
unreachable_pub = "warn"

[workspace.lints.clippy]
type_complexity = "allow"

await_holding_lock = "warn"
dbg_macro = "warn"
empty_enum = "warn"
enum_glob_use = "warn"
exit = "warn"
filter_map_next = "warn"
fn_params_excessive_bools = "warn"
if_let_mutex = "warn"
imprecise_flops = "warn"
inefficient_to_string = "warn"
linkedlist = "warn"
lossy_float_literal = "warn"
macro_use_imports = "warn"
match_on_vec_items = "warn"
match_wildcard_for_single_variants = "warn"
mem_forget = "warn"
needless_borrow = "warn"
needless_continue = "warn"
option_option = "warn"
rest_pat_in_fully_bound_structs = "warn"
str_to_string = "warn"
suboptimal_flops = "warn"
todo = "warn"
unnested_or_patterns = "warn"
unused_self = "warn"
verbose_file_reads = "warn"
3 changes: 3 additions & 0 deletions axum-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ hyper = "1.0.0"
tokio = { version = "1.25.0", features = ["macros"] }
tower-http = { version = "0.6.0", features = ["limit"] }

[lints]
workspace = true

[package.metadata.cargo-public-api-crates]
allowed = [
# not 1.0
Expand Down
37 changes: 0 additions & 37 deletions axum-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,6 @@
//! [`axum`]: https://crates.io/crates/axum
//! [`axum-core`]: http://crates.io/crates/axum-core
#![warn(
clippy::all,
clippy::dbg_macro,
clippy::todo,
clippy::empty_enum,
clippy::enum_glob_use,
clippy::mem_forget,
clippy::unused_self,
clippy::filter_map_next,
clippy::needless_continue,
clippy::needless_borrow,
clippy::match_wildcard_for_single_variants,
clippy::if_let_mutex,
clippy::await_holding_lock,
clippy::match_on_vec_items,
clippy::imprecise_flops,
clippy::suboptimal_flops,
clippy::lossy_float_literal,
clippy::rest_pat_in_fully_bound_structs,
clippy::fn_params_excessive_bools,
clippy::exit,
clippy::inefficient_to_string,
clippy::linkedlist,
clippy::macro_use_imports,
clippy::option_option,
clippy::verbose_file_reads,
clippy::unnested_or_patterns,
clippy::str_to_string,
rust_2018_idioms,
future_incompatible,
nonstandard_style,
missing_debug_implementations,
missing_docs
)]
#![deny(unreachable_pub)]
#![allow(elided_lifetimes_in_paths, clippy::type_complexity)]
#![forbid(unsafe_code)]
#![cfg_attr(test, allow(clippy::float_cmp))]
#![cfg_attr(not(test), warn(clippy::print_stdout, clippy::dbg_macro))]

Expand Down
3 changes: 3 additions & 0 deletions axum-extra/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ tokio = { version = "1.14", features = ["full"] }
tower = { version = "0.5.1", features = ["util"] }
tower-http = { version = "0.6.0", features = ["map-response-body", "timeout"] }

[lints]
workspace = true

[package.metadata.docs.rs]
all-features = true

Expand Down
37 changes: 0 additions & 37 deletions axum-extra/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,6 @@
//!
//! [`axum`]: https://crates.io/crates/axum
#![warn(
clippy::all,
clippy::dbg_macro,
clippy::todo,
clippy::empty_enum,
clippy::enum_glob_use,
clippy::mem_forget,
clippy::unused_self,
clippy::filter_map_next,
clippy::needless_continue,
clippy::needless_borrow,
clippy::match_wildcard_for_single_variants,
clippy::if_let_mutex,
clippy::await_holding_lock,
clippy::match_on_vec_items,
clippy::imprecise_flops,
clippy::suboptimal_flops,
clippy::lossy_float_literal,
clippy::rest_pat_in_fully_bound_structs,
clippy::fn_params_excessive_bools,
clippy::exit,
clippy::inefficient_to_string,
clippy::linkedlist,
clippy::macro_use_imports,
clippy::option_option,
clippy::verbose_file_reads,
clippy::unnested_or_patterns,
clippy::str_to_string,
rust_2018_idioms,
future_incompatible,
nonstandard_style,
missing_debug_implementations,
missing_docs
)]
#![deny(unreachable_pub)]
#![allow(elided_lifetimes_in_paths, clippy::type_complexity)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(test, allow(clippy::float_cmp))]
#![cfg_attr(not(test), warn(clippy::print_stdout, clippy::dbg_macro))]
Expand Down
3 changes: 3 additions & 0 deletions axum-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ syn = { version = "2.0", features = ["full", "extra-traits"] }
tokio = { version = "1.25.0", features = ["full"] }
trybuild = "1.0.63"

[lints]
workspace = true

[package.metadata.cargo-public-api-crates]
allowed = []

Expand Down
4 changes: 2 additions & 2 deletions axum-macros/src/attr_parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use syn::{
};

pub(crate) fn parse_parenthesized_attribute<K, T>(
input: ParseStream,
input: ParseStream<'_>,
out: &mut Option<(K, T)>,
) -> syn::Result<()>
where
Expand All @@ -30,7 +30,7 @@ where
}

pub(crate) fn parse_assignment_attribute<K, T>(
input: ParseStream,
input: ParseStream<'_>,
out: &mut Option<(K, T)>,
) -> syn::Result<()>
where
Expand Down
2 changes: 1 addition & 1 deletion axum-macros/src/axum_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) fn expand(_attr: Attrs, mut item_fn: ItemFn) -> TokenStream {
pub(crate) struct Attrs;

impl Parse for Attrs {
fn parse(_input: syn::parse::ParseStream) -> syn::Result<Self> {
fn parse(_input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {
Ok(Self)
}
}
Expand Down
2 changes: 1 addition & 1 deletion axum-macros/src/debug_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub(crate) struct Attrs {
}

impl Parse for Attrs {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {
let mut state_ty = None;

while !input.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion axum-macros/src/from_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub(super) struct FieldAttrs {
}

impl Parse for FieldAttrs {
fn parse(input: ParseStream) -> syn::Result<Self> {
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
let mut skip = None;

while !input.is_empty() {
Expand Down
4 changes: 2 additions & 2 deletions axum-macros/src/from_request/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(super) struct FromRequestContainerAttrs {
}

impl Parse for FromRequestContainerAttrs {
fn parse(input: ParseStream) -> syn::Result<Self> {
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
let mut via = None;
let mut rejection = None;
let mut state = None;
Expand Down Expand Up @@ -66,7 +66,7 @@ pub(super) struct FromRequestFieldAttrs {
}

impl Parse for FromRequestFieldAttrs {
fn parse(input: ParseStream) -> syn::Result<Self> {
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
let mut via = None;

while !input.is_empty() {
Expand Down
37 changes: 0 additions & 37 deletions axum-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,6 @@
//!
//! [`axum`]: https://crates.io/crates/axum
#![warn(
clippy::all,
clippy::dbg_macro,
clippy::todo,
clippy::empty_enum,
clippy::enum_glob_use,
clippy::mem_forget,
clippy::unused_self,
clippy::filter_map_next,
clippy::needless_continue,
clippy::needless_borrow,
clippy::match_wildcard_for_single_variants,
clippy::if_let_mutex,
clippy::await_holding_lock,
clippy::match_on_vec_items,
clippy::imprecise_flops,
clippy::suboptimal_flops,
clippy::lossy_float_literal,
clippy::rest_pat_in_fully_bound_structs,
clippy::fn_params_excessive_bools,
clippy::exit,
clippy::inefficient_to_string,
clippy::linkedlist,
clippy::macro_use_imports,
clippy::option_option,
clippy::verbose_file_reads,
clippy::unnested_or_patterns,
clippy::str_to_string,
rust_2018_idioms,
future_incompatible,
nonstandard_style,
missing_debug_implementations,
missing_docs
)]
#![deny(unreachable_pub)]
#![allow(elided_lifetimes_in_paths, clippy::type_complexity)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(test, allow(clippy::float_cmp))]
#![cfg_attr(not(test), warn(clippy::print_stdout, clippy::dbg_macro))]
Expand Down
2 changes: 1 addition & 1 deletion axum-macros/src/typed_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct Attrs {
}

impl Parse for Attrs {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {
let mut path = None;
let mut rejection = None;

Expand Down
9 changes: 6 additions & 3 deletions axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["json"] }
uuid = { version = "1.0", features = ["serde", "v4"] }

[package.metadata.docs.rs]
all-features = true

[dev-dependencies.tower]
package = "tower"
version = "0.5.1"
Expand Down Expand Up @@ -180,6 +177,12 @@ features = [
"validate-request",
]

[lints]
workspace = true

[package.metadata.docs.rs]
all-features = true

[package.metadata.playground]
features = [
"http1",
Expand Down
2 changes: 2 additions & 0 deletions axum/benches/benches.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(missing_docs)]

use axum::{
extract::State,
routing::{get, post},
Expand Down
2 changes: 1 addition & 1 deletion axum/src/box_clone_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ where
}

impl<T, U, E> fmt::Debug for BoxCloneService<T, U, E> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("BoxCloneService").finish()
}
}
36 changes: 0 additions & 36 deletions axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,42 +420,6 @@
//! [`axum-core`]: http://crates.io/crates/axum-core
//! [`State`]: crate::extract::State
#![warn(
clippy::all,
clippy::todo,
clippy::empty_enum,
clippy::enum_glob_use,
clippy::mem_forget,
clippy::unused_self,
clippy::filter_map_next,
clippy::needless_continue,
clippy::needless_borrow,
clippy::match_wildcard_for_single_variants,
clippy::if_let_mutex,
clippy::await_holding_lock,
clippy::match_on_vec_items,
clippy::imprecise_flops,
clippy::suboptimal_flops,
clippy::lossy_float_literal,
clippy::rest_pat_in_fully_bound_structs,
clippy::fn_params_excessive_bools,
clippy::exit,
clippy::inefficient_to_string,
clippy::linkedlist,
clippy::macro_use_imports,
clippy::option_option,
clippy::verbose_file_reads,
clippy::unnested_or_patterns,
clippy::str_to_string,
rust_2018_idioms,
future_incompatible,
nonstandard_style,
missing_debug_implementations,
missing_docs
)]
#![deny(unreachable_pub)]
#![allow(elided_lifetimes_in_paths, clippy::type_complexity)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]
#![cfg_attr(test, allow(clippy::float_cmp))]
#![cfg_attr(not(test), warn(clippy::print_stdout, clippy::dbg_macro))]
Expand Down
2 changes: 1 addition & 1 deletion axum/src/routing/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ async fn logging_rejections() {
.await;

assert_eq!(
dbg!(events),
events,
Vec::from([
TracingEvent {
fields: RejectionEvent {
Expand Down
2 changes: 1 addition & 1 deletion axum/src/routing/url_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) enum UrlParams {
InvalidUtf8InPathParam { key: Arc<str> },
}

pub(super) fn insert_url_params(extensions: &mut Extensions, params: Params) {
pub(super) fn insert_url_params(extensions: &mut Extensions, params: Params<'_, '_>) {
let current_params = extensions.get_mut();

if let Some(UrlParams::InvalidUtf8InPathParam { .. }) = current_params {
Expand Down

0 comments on commit d84136e

Please sign in to comment.