From d5b972385d269a3a597ac44cb23a52780fda3660 Mon Sep 17 00:00:00 2001 From: Fangdun Tsai Date: Wed, 22 Nov 2023 10:04:04 +0800 Subject: [PATCH] lint: move to workspace.lints table --- .github/workflows/CI.yml | 2 +- Cargo.toml | 14 ++++++++++++++ viz-core/Cargo.toml | 3 +++ viz-core/src/lib.rs | 8 -------- viz-core/src/middleware/otel/tracing.rs | 2 +- viz-handlers/Cargo.toml | 3 +++ viz-handlers/src/lib.rs | 7 ------- viz-macros/Cargo.toml | 3 +++ viz-macros/src/lib.rs | 7 ------- viz-router/Cargo.toml | 3 +++ viz-router/src/lib.rs | 7 ------- viz/Cargo.toml | 3 ++- viz/src/lib.rs | 7 ------- viz/src/tls.rs | 2 -- 14 files changed, 30 insertions(+), 41 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 644bf7a6..f3b0205c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@clippy - uses: Swatinem/rust-cache@v2 - - run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic + - run: cargo clippy --tests fmt: name: Fmt diff --git a/Cargo.toml b/Cargo.toml index 507d8de3..569426c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -110,3 +110,17 @@ split-debuginfo = "unpacked" [profile.dev.package."*"] opt-level = 3 debug = false + +[workspace.lints.rust] +unsafe_code = "forbid" +rust_2018_idioms = "warn" +single_use_lifetimes = "warn" +non_ascii_idents = "warn" +unreachable_pub = "warn" +missing_debug_implementations = "warn" +missing_docs = "warn" + +[workspace.lints.clippy] +all = "deny" +pedantic = "deny" +module_name_repetitions = { level = "allow", priority = 1 } diff --git a/viz-core/Cargo.toml b/viz-core/Cargo.toml index 45694cd0..70e0a302 100644 --- a/viz-core/Cargo.toml +++ b/viz-core/Cargo.toml @@ -105,3 +105,6 @@ tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true diff --git a/viz-core/src/lib.rs b/viz-core/src/lib.rs index 39aa6a4f..ac3c91b9 100644 --- a/viz-core/src/lib.rs +++ b/viz-core/src/lib.rs @@ -4,14 +4,6 @@ #![doc(html_logo_url = "https://viz.rs/logo.svg")] #![doc(html_favicon_url = "https://viz.rs/logo.svg")] -#![allow(clippy::module_name_repetitions)] -#![forbid(unsafe_code)] -#![warn( - missing_debug_implementations, - missing_docs, - rust_2018_idioms, - unreachable_pub -)] #![doc(test( no_crate_inject, attr( diff --git a/viz-core/src/middleware/otel/tracing.rs b/viz-core/src/middleware/otel/tracing.rs index 82043035..d60af86c 100644 --- a/viz-core/src/middleware/otel/tracing.rs +++ b/viz-core/src/middleware/otel/tracing.rs @@ -141,7 +141,7 @@ impl<'a> RequestHeaderCarrier<'a> { } } -impl<'a> Extractor for RequestHeaderCarrier<'a> { +impl Extractor for RequestHeaderCarrier<'_> { fn get(&self, key: &str) -> Option<&str> { self.headers.get(key).and_then(|v| v.to_str().ok()) } diff --git a/viz-handlers/Cargo.toml b/viz-handlers/Cargo.toml index 7713b577..0b077150 100644 --- a/viz-handlers/Cargo.toml +++ b/viz-handlers/Cargo.toml @@ -66,3 +66,6 @@ tokio = { workspace = true, features = ["rt", "macros"] } [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true diff --git a/viz-handlers/src/lib.rs b/viz-handlers/src/lib.rs index 7ec4742a..eb8843d8 100644 --- a/viz-handlers/src/lib.rs +++ b/viz-handlers/src/lib.rs @@ -2,13 +2,6 @@ #![doc(html_logo_url = "https://viz.rs/logo.svg")] #![doc(html_favicon_url = "https://viz.rs/logo.svg")] -#![forbid(unsafe_code)] -#![warn( - missing_debug_implementations, - missing_docs, - rust_2018_idioms, - unreachable_pub -)] #![doc(test( no_crate_inject, attr( diff --git a/viz-macros/Cargo.toml b/viz-macros/Cargo.toml index 127838e0..b206f019 100644 --- a/viz-macros/Cargo.toml +++ b/viz-macros/Cargo.toml @@ -28,3 +28,6 @@ tokio = { workspace = true, features = ["rt", "macros"] } [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true diff --git a/viz-macros/src/lib.rs b/viz-macros/src/lib.rs index 8e4a4f8e..d23e8dbe 100644 --- a/viz-macros/src/lib.rs +++ b/viz-macros/src/lib.rs @@ -27,13 +27,6 @@ #![doc(html_logo_url = "https://viz.rs/logo.svg")] #![doc(html_favicon_url = "https://viz.rs/logo.svg")] -#![forbid(unsafe_code)] -#![warn( - missing_debug_implementations, - missing_docs, - rust_2018_idioms, - unreachable_pub -)] #![doc(test( no_crate_inject, attr( diff --git a/viz-router/Cargo.toml b/viz-router/Cargo.toml index abddc76f..bae3bf21 100644 --- a/viz-router/Cargo.toml +++ b/viz-router/Cargo.toml @@ -30,3 +30,6 @@ serde_derive.workspace = true hyper.workspace = true http-body-util.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } + +[lints] +workspace = true diff --git a/viz-router/src/lib.rs b/viz-router/src/lib.rs index a9d17d56..f339ff62 100644 --- a/viz-router/src/lib.rs +++ b/viz-router/src/lib.rs @@ -2,13 +2,6 @@ #![doc(html_logo_url = "https://viz.rs/logo.svg")] #![doc(html_favicon_url = "https://viz.rs/logo.svg")] -#![forbid(unsafe_code)] -#![warn( - missing_debug_implementations, - missing_docs, - rust_2018_idioms, - unreachable_pub -)] #![doc(test( no_crate_inject, attr( diff --git a/viz/Cargo.toml b/viz/Cargo.toml index 0421a38f..e1aaf52b 100644 --- a/viz/Cargo.toml +++ b/viz/Cargo.toml @@ -87,4 +87,5 @@ tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread"] } all-features = true rustdoc-args = ["--cfg", "docsrs"] -[package.metadata.playground] +[lints] +workspace = true diff --git a/viz/src/lib.rs b/viz/src/lib.rs index 9d8023d8..3ec2b174 100644 --- a/viz/src/lib.rs +++ b/viz/src/lib.rs @@ -514,13 +514,6 @@ #![doc(html_logo_url = "https://viz.rs/logo.svg")] #![doc(html_favicon_url = "https://viz.rs/logo.svg")] -#![forbid(unsafe_code)] -#![warn( - missing_debug_implementations, - missing_docs, - rust_2018_idioms, - unreachable_pub -)] #![doc(test( no_crate_inject, attr( diff --git a/viz/src/tls.rs b/viz/src/tls.rs index 10479993..7907ad36 100644 --- a/viz/src/tls.rs +++ b/viz/src/tls.rs @@ -1,5 +1,3 @@ -#![allow(clippy::module_name_repetitions)] - mod listener; pub use listener::Listener;