From 861ad6f6c90b61e0dc7971291fc20cde25a2943d Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sat, 1 Jun 2024 22:26:20 +0900 Subject: [PATCH] Ignore more lints at workspace level --- Cargo.toml | 12 +++++++++++- bench/benches/bench.rs | 1 - build.rs | 8 -------- portable-atomic-util/Cargo.toml | 3 ++- portable-atomic-util/src/lib.rs | 3 --- src/lib.rs | 1 - tests/api-test/Cargo.toml | 2 +- tests/api-test/build.rs | 5 ----- tests/avr/Cargo.toml | 6 +++++- tests/avr/build.rs | 6 ------ tests/gba/Cargo.toml | 5 ++++- tests/gba/build.rs | 5 ----- tests/helper/Cargo.toml | 2 +- tests/helper/src/lib.rs | 1 - tests/no-std-qemu/Cargo.toml | 5 ++++- tests/no-std-qemu/build.rs | 1 - tests/xtensa/Cargo.toml | 5 ++++- tests/xtensa/build.rs | 5 ----- 18 files changed, 32 insertions(+), 44 deletions(-) delete mode 100644 tests/api-test/build.rs delete mode 100644 tests/avr/build.rs delete mode 100644 tests/gba/build.rs delete mode 100644 tests/xtensa/build.rs diff --git a/Cargo.toml b/Cargo.toml index 48cde47c..27a0c1cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,6 +112,15 @@ improper_ctypes_definitions = "warn" non_ascii_idents = "warn" rust_2018_idioms = "warn" single_use_lifetimes = "warn" +unexpected_cfgs = { level = "warn", check-cfg = [ + "cfg(target_arch,values(\"xtensa\"))", + "cfg(target_pointer_width,values(\"128\"))", + # Known custom cfgs, excluding those that may be set by build script. + # Not public API. + "cfg(portable_atomic_test_outline_atomics_detect_false,qemu,valgrind)", + # Public APIs, considered unstable unless documented in readme. + "cfg(portable_atomic_no_outline_atomics,portable_atomic_outline_atomics)", +] } unreachable_pub = "warn" # unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 is not available on MSRV [workspace.lints.clippy] @@ -129,12 +138,13 @@ borrow_as_ptr = { level = "allow", priority = 1 } # https://github.com/rust-lang declare_interior_mutable_const = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7665 doc_markdown = { level = "allow", priority = 1 } float_cmp = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7725 +incompatible_msrv = { level = "allow", priority = 1 } # buggy: doesn't consider cfg, https://github.com/rust-lang/rust-clippy/issues/12280, https://github.com/rust-lang/rust-clippy/issues/12257#issuecomment-2093667187 lint_groups_priority = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/12270 manual_assert = { level = "allow", priority = 1 } manual_range_contains = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/6455#issuecomment-1225966395 missing_errors_doc = { level = "allow", priority = 1 } module_name_repetitions = { level = "allow", priority = 1 } -nonminimal_bool = { level = "allow", priority = 1 } # buggy https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+nonminimal_bool +nonminimal_bool = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+nonminimal_bool similar_names = { level = "allow", priority = 1 } single_match = { level = "allow", priority = 1 } single_match_else = { level = "allow", priority = 1 } diff --git a/bench/benches/bench.rs b/bench/benches/bench.rs index d2031bf6..218f39c8 100644 --- a/bench/benches/bench.rs +++ b/bench/benches/bench.rs @@ -6,7 +6,6 @@ unexpected_cfgs, unused_extern_crates, clippy::duplicate_mod, - clippy::incompatible_msrv, // similar to https://github.com/rust-lang/rust-clippy/issues/12257, but for bench clippy::inline_always, clippy::naive_bytecount, clippy::wildcard_imports diff --git a/build.rs b/build.rs index fbbb0d5f..8b0607a7 100644 --- a/build.rs +++ b/build.rs @@ -46,18 +46,10 @@ fn main() { }; if version.minor >= 80 { - println!(r#"cargo:rustc-check-cfg=cfg(target_pointer_width,values("128"))"#); - println!(r#"cargo:rustc-check-cfg=cfg(target_arch,values("xtensa"))"#); println!( r#"cargo:rustc-check-cfg=cfg(target_feature,values("lse2","lse128","rcpc3","quadword-atomics","fast-serialization","load-store-on-cond","distinct-ops","miscellaneous-extensions-3"))"# ); - // Known custom cfgs, excluding those that may be set by build script. - // Not public API. - println!("cargo:rustc-check-cfg=cfg(portable_atomic_test_outline_atomics_detect_false,qemu,valgrind)"); - // Public APIs, considered unstable unless documented in readme. - println!("cargo:rustc-check-cfg=cfg(portable_atomic_no_outline_atomics,portable_atomic_outline_atomics)"); - // Custom cfgs set by build script. Not public API. // grep -E 'cargo:rustc-cfg=' build.rs | grep -v '=//' | sed -E 's/^.*cargo:rustc-cfg=//; s/(=\\)?".*$//' | LC_ALL=C sort -u | tr '\n' ',' println!( diff --git a/portable-atomic-util/Cargo.toml b/portable-atomic-util/Cargo.toml index a0c72efe..1eb8cf69 100644 --- a/portable-atomic-util/Cargo.toml +++ b/portable-atomic-util/Cargo.toml @@ -17,7 +17,8 @@ targets = ["x86_64-unknown-linux-gnu"] [package.metadata.cargo_check_external_types] # The following are external types that are allowed to be exposed in our public API. -allowed_external_types = [] +allowed_external_types = [ +] [lib] doc-scrape-examples = false diff --git a/portable-atomic-util/src/lib.rs b/portable-atomic-util/src/lib.rs index 0ac3afcd..22fdc9db 100644 --- a/portable-atomic-util/src/lib.rs +++ b/portable-atomic-util/src/lib.rs @@ -57,9 +57,6 @@ See [#1] for other primitives being considered for addition to this crate. clippy::std_instead_of_alloc, clippy::std_instead_of_core, )] -#![allow( - clippy::incompatible_msrv, // false positive: this lint doesn't consider cfg -)] // docs.rs only (cfg is enabled by docs.rs, not build script) #![cfg_attr(docsrs, feature(doc_cfg))] diff --git a/src/lib.rs b/src/lib.rs index 1209ba57..52a95733 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -210,7 +210,6 @@ RUSTFLAGS="--cfg portable_atomic_no_outline_atomics" cargo ... #![cfg_attr(not(portable_atomic_no_asm), warn(missing_docs))] // module-level #![allow(missing_docs)] doesn't work for macros on old rustc #![allow( clippy::cast_lossless, - clippy::incompatible_msrv, // false positive: this lint doesn't consider cfg clippy::inline_always, clippy::naive_bytecount, clippy::unreadable_literal diff --git a/tests/api-test/Cargo.toml b/tests/api-test/Cargo.toml index 9cb39c5a..dae6f578 100644 --- a/tests/api-test/Cargo.toml +++ b/tests/api-test/Cargo.toml @@ -2,7 +2,7 @@ name = "api-test" version = "0.0.0" edition = "2018" -rust-version = "1.34" +rust-version = "1.34" # Prevent clippy from suggesting a code that requires a new version. publish = false [lib] diff --git a/tests/api-test/build.rs b/tests/api-test/build.rs deleted file mode 100644 index b92a0966..00000000 --- a/tests/api-test/build.rs +++ /dev/null @@ -1,5 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 OR MIT - -fn main() { - println!(r#"cargo:rustc-check-cfg=cfg(target_arch,values("xtensa"))"#); // for helper.rs -} diff --git a/tests/avr/Cargo.toml b/tests/avr/Cargo.toml index b057f58a..a38af1cc 100644 --- a/tests/avr/Cargo.toml +++ b/tests/avr/Cargo.toml @@ -21,9 +21,13 @@ resolver = "2" [lints.rust] rust_2018_idioms = "warn" single_use_lifetimes = "warn" +unexpected_cfgs = { level = "warn", check-cfg = [ + "cfg(target_arch,values(\"xtensa\"))", + "cfg(qemu)", +] } # unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 is not available on MSRV [lints.clippy] -lint_groups_priority = { level = "allow", priority = 1 } # clippy bug: https://github.com/rust-lang/rust-clippy/issues/12270 +lint_groups_priority = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/12270 [profile.dev] lto = true diff --git a/tests/avr/build.rs b/tests/avr/build.rs deleted file mode 100644 index 570f4283..00000000 --- a/tests/avr/build.rs +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 OR MIT - -fn main() { - println!(r#"cargo:rustc-check-cfg=cfg(target_arch,values("xtensa"))"#); // for helper.rs - println!("cargo:rustc-check-cfg=cfg(qemu)"); -} diff --git a/tests/gba/Cargo.toml b/tests/gba/Cargo.toml index 42974368..26ced71f 100644 --- a/tests/gba/Cargo.toml +++ b/tests/gba/Cargo.toml @@ -17,9 +17,12 @@ resolver = "2" [lints.rust] rust_2018_idioms = "warn" single_use_lifetimes = "warn" +unexpected_cfgs = { level = "warn", check-cfg = [ + "cfg(target_arch,values(\"xtensa\"))", +] } # unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 is not available on MSRV [lints.clippy] -lint_groups_priority = { level = "allow", priority = 1 } # clippy bug: https://github.com/rust-lang/rust-clippy/issues/12270 +lint_groups_priority = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/12270 [profile.dev] # TODO: "GBA: Illegal opcode: e7ffdefe" on opt-level=0, GBA hang on opt-level={1,s,z} diff --git a/tests/gba/build.rs b/tests/gba/build.rs deleted file mode 100644 index b92a0966..00000000 --- a/tests/gba/build.rs +++ /dev/null @@ -1,5 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 OR MIT - -fn main() { - println!(r#"cargo:rustc-check-cfg=cfg(target_arch,values("xtensa"))"#); // for helper.rs -} diff --git a/tests/helper/Cargo.toml b/tests/helper/Cargo.toml index 3578a86f..2237b423 100644 --- a/tests/helper/Cargo.toml +++ b/tests/helper/Cargo.toml @@ -2,7 +2,7 @@ name = "test-helper" version = "0.0.0" edition = "2018" -rust-version = "1.34" +rust-version = "1.34" # Prevent clippy from suggesting a code that requires a new version. publish = false [lib] diff --git a/tests/helper/src/lib.rs b/tests/helper/src/lib.rs index ce739da2..d13cebba 100644 --- a/tests/helper/src/lib.rs +++ b/tests/helper/src/lib.rs @@ -2,7 +2,6 @@ #![no_std] #![allow( - clippy::incompatible_msrv, clippy::missing_panics_doc, clippy::new_without_default, clippy::undocumented_unsafe_blocks diff --git a/tests/no-std-qemu/Cargo.toml b/tests/no-std-qemu/Cargo.toml index 7061ee94..f472bf1e 100644 --- a/tests/no-std-qemu/Cargo.toml +++ b/tests/no-std-qemu/Cargo.toml @@ -34,9 +34,12 @@ resolver = "2" [lints.rust] rust_2018_idioms = "warn" single_use_lifetimes = "warn" +unexpected_cfgs = { level = "warn", check-cfg = [ + "cfg(target_arch,values(\"xtensa\"))", +] } # unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 is not available on MSRV [lints.clippy] -lint_groups_priority = { level = "allow", priority = 1 } # clippy bug: https://github.com/rust-lang/rust-clippy/issues/12270 +lint_groups_priority = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/12270 single_match = { level = "allow", priority = 1 } [profile.dev] diff --git a/tests/no-std-qemu/build.rs b/tests/no-std-qemu/build.rs index b11cd92e..fae583e9 100644 --- a/tests/no-std-qemu/build.rs +++ b/tests/no-std-qemu/build.rs @@ -5,7 +5,6 @@ use std::env; fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rustc-check-cfg=cfg(armv5te,f,d)"); - println!(r#"cargo:rustc-check-cfg=cfg(target_arch,values("xtensa"))"#); // for helper.rs let target = &*env::var("TARGET").expect("TARGET not set"); let target_arch = &*env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH not set"); diff --git a/tests/xtensa/Cargo.toml b/tests/xtensa/Cargo.toml index b1ed3f05..324a2d04 100644 --- a/tests/xtensa/Cargo.toml +++ b/tests/xtensa/Cargo.toml @@ -21,9 +21,12 @@ resolver = "2" [lints.rust] rust_2018_idioms = "warn" single_use_lifetimes = "warn" +unexpected_cfgs = { level = "warn", check-cfg = [ + "cfg(target_arch,values(\"xtensa\"))", +] } # unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 is not available on MSRV [lints.clippy] -lint_groups_priority = { level = "allow", priority = 1 } # clippy bug: https://github.com/rust-lang/rust-clippy/issues/12270 +lint_groups_priority = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/12270 [profile.dev] opt-level = 'z' diff --git a/tests/xtensa/build.rs b/tests/xtensa/build.rs deleted file mode 100644 index b92a0966..00000000 --- a/tests/xtensa/build.rs +++ /dev/null @@ -1,5 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 OR MIT - -fn main() { - println!(r#"cargo:rustc-check-cfg=cfg(target_arch,values("xtensa"))"#); // for helper.rs -}