about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-02-22 11:00:52 +0000
committerbors <bors@rust-lang.org>2024-02-22 11:00:52 +0000
commitd554bcad7914a7fbe01a40371a7917ac0b763494 (patch)
treec187b72f62d0689f2123e379fb0efbdbb6b8d2f2 /tests/ui
parent422f9c5b657299d577feab8a7bc208d653eec90e (diff)
parentcf6a14cea10822c97e388f6c5e08280dc1ae9f29 (diff)
downloadrust-d554bcad7914a7fbe01a40371a7917ac0b763494.tar.gz
rust-d554bcad7914a7fbe01a40371a7917ac0b763494.zip
Auto merge of #12303 - GuillaumeGomez:unneedeed_clippy_cfg_attr, r=flip1995
Add `unnecessary_clippy_cfg` lint

Follow-up of https://github.com/rust-lang/rust-clippy/pull/12292.

r? `@flip1995`

changelog: Add `unnecessary_clippy_cfg` lint
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/unnecessary_clippy_cfg.rs23
-rw-r--r--tests/ui/unnecessary_clippy_cfg.stderr61
2 files changed, 84 insertions, 0 deletions
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
+