From cf6a14cea10822c97e388f6c5e08280dc1ae9f29 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 16 Feb 2024 17:44:16 +0100 Subject: [PATCH] Add ui test for `unneeded_clippy_cfg_attr` --- tests/ui/unnecessary_clippy_cfg.rs | 23 ++++++++++ tests/ui/unnecessary_clippy_cfg.stderr | 61 ++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 tests/ui/unnecessary_clippy_cfg.rs create mode 100644 tests/ui/unnecessary_clippy_cfg.stderr diff --git a/tests/ui/unnecessary_clippy_cfg.rs b/tests/ui/unnecessary_clippy_cfg.rs new file mode 100644 index 00000000000..ff960520f5e --- /dev/null +++ b/tests/ui/unnecessary_clippy_cfg.rs @@ -0,0 +1,23 @@ +//@no-rustfix + +#![warn(clippy::unnecessary_clippy_cfg)] +#![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#![cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg + +#[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#[cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +pub struct Bar; + +fn main() {} diff --git a/tests/ui/unnecessary_clippy_cfg.stderr b/tests/ui/unnecessary_clippy_cfg.stderr new file mode 100644 index 00000000000..fbc05743ca7 --- /dev/null +++ b/tests/ui/unnecessary_clippy_cfg.stderr @@ -0,0 +1,61 @@ +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:13:1 + | +LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg)]` + | + = note: `-D clippy::unnecessary-clippy-cfg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_clippy_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:15:36 + | +LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: write instead: `#[deny(clippy::non_minimal_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:17:36 + | +LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: write instead: `#[deny(clippy::non_minimal_cfg,clippy::maybe_misused_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:19:1 + | +LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:4:1 + | +LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:6:37 + | +LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: write instead: `#![deny(clippy::non_minimal_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:8:37 + | +LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: write instead: `#![deny(clippy::non_minimal_cfg,clippy::maybe_misused_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:10:1 + | +LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg)]` + +error: aborting due to 8 previous errors +