Centralize lint configuration (#3055)

This commit is contained in:
Jonas Platte 2024-11-30 16:53:48 +01:00 committed by GitHub
parent 2eaed0badc
commit d84136e1e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 66 additions and 161 deletions

View file

@ -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"

View file

@ -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

View file

@ -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))]

View file

@ -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

View file

@ -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))]

View file

@ -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 = []

View file

@ -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
@ -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

View file

@ -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)
}
}

View file

@ -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() {

View file

@ -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() {

View file

@ -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;
@ -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() {

View file

@ -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))]

View file

@ -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;

View file

@ -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"
@ -180,6 +177,12 @@ features = [
"validate-request",
]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true
[package.metadata.playground]
features = [
"http1",

View file

@ -1,3 +1,5 @@
#![allow(missing_docs)]
use axum::{
extract::State,
routing::{get, post},

View file

@ -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()
}
}

View file

@ -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))]

View file

@ -981,7 +981,7 @@ async fn logging_rejections() {
.await;
assert_eq!(
dbg!(events),
events,
Vec::from([
TracingEvent {
fields: RejectionEvent {

View file

@ -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 {