about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-02-28 17:25:28 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2024-03-09 12:43:18 +0100
commit749e225cd64b26197b62a179a11e0040dcbef8ad (patch)
tree713bf5936fcb39818af6ca51c02045a54a57e9c9
parentf34804d807a8ca576c3a9096064a8b95ff7d0c2e (diff)
Add ui test for new `duplicated_attributes` lint
-rw-r--r--tests/ui/duplicated_attributes.rs17
-rw-r--r--tests/ui/duplicated_attributes.stderr123
2 files changed, 140 insertions, 0 deletions
diff --git a/tests/ui/duplicated_attributes.rs b/tests/ui/duplicated_attributes.rs
new file mode 100644
index 00000000000..0f036c684c1
--- /dev/null
+++ b/tests/ui/duplicated_attributes.rs
@@ -0,0 +1,17 @@
+#![warn(clippy::duplicated_attributes)]
+#![cfg(any(unix, windows))]
+#![allow(dead_code)]
+#![allow(dead_code)] //~ ERROR: duplicated attribute
+#![cfg(any(unix, windows))]
+//~^ ERROR: duplicated attribute
+//~| ERROR: duplicated attribute
+
+#[cfg(any(unix, windows, target_os = "linux"))]
+#[allow(dead_code)]
+#[allow(dead_code)] //~ ERROR: duplicated attribute
+#[cfg(any(unix, windows, target_os = "linux"))]
+//~^ ERROR: duplicated attribute
+//~| ERROR: duplicated attribute
+fn foo() {}
+
+fn main() {}
diff --git a/tests/ui/duplicated_attributes.stderr b/tests/ui/duplicated_attributes.stderr
new file mode 100644
index 00000000000..1c6578dbb43
--- /dev/null
+++ b/tests/ui/duplicated_attributes.stderr
@@ -0,0 +1,123 @@
+error: duplicated attribute
+  --> tests/ui/duplicated_attributes.rs:4:10
+   |
+LL | #![allow(dead_code)]
+   |          ^^^^^^^^^
+   |
+note: first defined here
+  --> tests/ui/duplicated_attributes.rs:3:10
+   |
+LL | #![allow(dead_code)]
+   |          ^^^^^^^^^
+help: remove this attribute
+  --> tests/ui/duplicated_attributes.rs:4:10
+   |
+LL | #![allow(dead_code)]
+   |          ^^^^^^^^^
+   = note: `-D clippy::duplicated-attributes` implied by `-D warnings`
+   = help: to override `-D warnings` add `#[allow(clippy::duplicated_attributes)]`
+
+error: duplicated attribute
+  --> tests/ui/duplicated_attributes.rs:5:12
+   |
+LL | #![cfg(any(unix, windows))]
+   |            ^^^^
+   |
+note: first defined here
+  --> tests/ui/duplicated_attributes.rs:2:12
+   |
+LL | #![cfg(any(unix, windows))]
+   |            ^^^^
+help: remove this attribute
+  --> tests/ui/duplicated_attributes.rs:5:12
+   |
+LL | #![cfg(any(unix, windows))]
+   |            ^^^^
+
+error: duplicated attribute
+  --> tests/ui/duplicated_attributes.rs:5:18
+   |
+LL | #![cfg(any(unix, windows))]
+   |                  ^^^^^^^
+   |
+note: first defined here
+  --> tests/ui/duplicated_attributes.rs:2:18
+   |
+LL | #![cfg(any(unix, windows))]
+   |                  ^^^^^^^
+help: remove this attribute
+  --> tests/ui/duplicated_attributes.rs:5:18
+   |
+LL | #![cfg(any(unix, windows))]
+   |                  ^^^^^^^
+
+error: duplicated attribute
+  --> tests/ui/duplicated_attributes.rs:11:9
+   |
+LL | #[allow(dead_code)]
+   |         ^^^^^^^^^
+   |
+note: first defined here
+  --> tests/ui/duplicated_attributes.rs:10:9
+   |
+LL | #[allow(dead_code)]
+   |         ^^^^^^^^^
+help: remove this attribute
+  --> tests/ui/duplicated_attributes.rs:11:9
+   |
+LL | #[allow(dead_code)]
+   |         ^^^^^^^^^
+
+error: duplicated attribute
+  --> tests/ui/duplicated_attributes.rs:12:11
+   |
+LL | #[cfg(any(unix, windows, target_os = "linux"))]
+   |           ^^^^
+   |
+note: first defined here
+  --> tests/ui/duplicated_attributes.rs:9:11
+   |
+LL | #[cfg(any(unix, windows, target_os = "linux"))]
+   |           ^^^^
+help: remove this attribute
+  --> tests/ui/duplicated_attributes.rs:12:11
+   |
+LL | #[cfg(any(unix, windows, target_os = "linux"))]
+   |           ^^^^
+
+error: duplicated attribute
+  --> tests/ui/duplicated_attributes.rs:12:17
+   |
+LL | #[cfg(any(unix, windows, target_os = "linux"))]
+   |                 ^^^^^^^
+   |
+note: first defined here
+  --> tests/ui/duplicated_attributes.rs:9:17
+   |
+LL | #[cfg(any(unix, windows, target_os = "linux"))]
+   |                 ^^^^^^^
+help: remove this attribute
+  --> tests/ui/duplicated_attributes.rs:12:17
+   |
+LL | #[cfg(any(unix, windows, target_os = "linux"))]
+   |                 ^^^^^^^
+
+error: duplicated attribute
+  --> tests/ui/duplicated_attributes.rs:12:26
+   |
+LL | #[cfg(any(unix, windows, target_os = "linux"))]
+   |                          ^^^^^^^^^^^^^^^^^^^
+   |
+note: first defined here
+  --> tests/ui/duplicated_attributes.rs:9:26
+   |
+LL | #[cfg(any(unix, windows, target_os = "linux"))]
+   |                          ^^^^^^^^^^^^^^^^^^^
+help: remove this attribute
+  --> tests/ui/duplicated_attributes.rs:12:26
+   |
+LL | #[cfg(any(unix, windows, target_os = "linux"))]
+   |                          ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 7 previous errors
+