Skip to content

Commit 749e225

Browse files
Add ui test for new duplicated_attributes lint
1 parent f34804d commit 749e225

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed

tests/ui/duplicated_attributes.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![warn(clippy::duplicated_attributes)]
2+
#![cfg(any(unix, windows))]
3+
#![allow(dead_code)]
4+
#![allow(dead_code)] //~ ERROR: duplicated attribute
5+
#![cfg(any(unix, windows))]
6+
//~^ ERROR: duplicated attribute
7+
//~| ERROR: duplicated attribute
8+
9+
#[cfg(any(unix, windows, target_os = "linux"))]
10+
#[allow(dead_code)]
11+
#[allow(dead_code)] //~ ERROR: duplicated attribute
12+
#[cfg(any(unix, windows, target_os = "linux"))]
13+
//~^ ERROR: duplicated attribute
14+
//~| ERROR: duplicated attribute
15+
fn foo() {}
16+
17+
fn main() {}

tests/ui/duplicated_attributes.stderr

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
error: duplicated attribute
2+
--> tests/ui/duplicated_attributes.rs:4:10
3+
|
4+
LL | #![allow(dead_code)]
5+
| ^^^^^^^^^
6+
|
7+
note: first defined here
8+
--> tests/ui/duplicated_attributes.rs:3:10
9+
|
10+
LL | #![allow(dead_code)]
11+
| ^^^^^^^^^
12+
help: remove this attribute
13+
--> tests/ui/duplicated_attributes.rs:4:10
14+
|
15+
LL | #![allow(dead_code)]
16+
| ^^^^^^^^^
17+
= note: `-D clippy::duplicated-attributes` implied by `-D warnings`
18+
= help: to override `-D warnings` add `#[allow(clippy::duplicated_attributes)]`
19+
20+
error: duplicated attribute
21+
--> tests/ui/duplicated_attributes.rs:5:12
22+
|
23+
LL | #![cfg(any(unix, windows))]
24+
| ^^^^
25+
|
26+
note: first defined here
27+
--> tests/ui/duplicated_attributes.rs:2:12
28+
|
29+
LL | #![cfg(any(unix, windows))]
30+
| ^^^^
31+
help: remove this attribute
32+
--> tests/ui/duplicated_attributes.rs:5:12
33+
|
34+
LL | #![cfg(any(unix, windows))]
35+
| ^^^^
36+
37+
error: duplicated attribute
38+
--> tests/ui/duplicated_attributes.rs:5:18
39+
|
40+
LL | #![cfg(any(unix, windows))]
41+
| ^^^^^^^
42+
|
43+
note: first defined here
44+
--> tests/ui/duplicated_attributes.rs:2:18
45+
|
46+
LL | #![cfg(any(unix, windows))]
47+
| ^^^^^^^
48+
help: remove this attribute
49+
--> tests/ui/duplicated_attributes.rs:5:18
50+
|
51+
LL | #![cfg(any(unix, windows))]
52+
| ^^^^^^^
53+
54+
error: duplicated attribute
55+
--> tests/ui/duplicated_attributes.rs:11:9
56+
|
57+
LL | #[allow(dead_code)]
58+
| ^^^^^^^^^
59+
|
60+
note: first defined here
61+
--> tests/ui/duplicated_attributes.rs:10:9
62+
|
63+
LL | #[allow(dead_code)]
64+
| ^^^^^^^^^
65+
help: remove this attribute
66+
--> tests/ui/duplicated_attributes.rs:11:9
67+
|
68+
LL | #[allow(dead_code)]
69+
| ^^^^^^^^^
70+
71+
error: duplicated attribute
72+
--> tests/ui/duplicated_attributes.rs:12:11
73+
|
74+
LL | #[cfg(any(unix, windows, target_os = "linux"))]
75+
| ^^^^
76+
|
77+
note: first defined here
78+
--> tests/ui/duplicated_attributes.rs:9:11
79+
|
80+
LL | #[cfg(any(unix, windows, target_os = "linux"))]
81+
| ^^^^
82+
help: remove this attribute
83+
--> tests/ui/duplicated_attributes.rs:12:11
84+
|
85+
LL | #[cfg(any(unix, windows, target_os = "linux"))]
86+
| ^^^^
87+
88+
error: duplicated attribute
89+
--> tests/ui/duplicated_attributes.rs:12:17
90+
|
91+
LL | #[cfg(any(unix, windows, target_os = "linux"))]
92+
| ^^^^^^^
93+
|
94+
note: first defined here
95+
--> tests/ui/duplicated_attributes.rs:9:17
96+
|
97+
LL | #[cfg(any(unix, windows, target_os = "linux"))]
98+
| ^^^^^^^
99+
help: remove this attribute
100+
--> tests/ui/duplicated_attributes.rs:12:17
101+
|
102+
LL | #[cfg(any(unix, windows, target_os = "linux"))]
103+
| ^^^^^^^
104+
105+
error: duplicated attribute
106+
--> tests/ui/duplicated_attributes.rs:12:26
107+
|
108+
LL | #[cfg(any(unix, windows, target_os = "linux"))]
109+
| ^^^^^^^^^^^^^^^^^^^
110+
|
111+
note: first defined here
112+
--> tests/ui/duplicated_attributes.rs:9:26
113+
|
114+
LL | #[cfg(any(unix, windows, target_os = "linux"))]
115+
| ^^^^^^^^^^^^^^^^^^^
116+
help: remove this attribute
117+
--> tests/ui/duplicated_attributes.rs:12:26
118+
|
119+
LL | #[cfg(any(unix, windows, target_os = "linux"))]
120+
| ^^^^^^^^^^^^^^^^^^^
121+
122+
error: aborting due to 7 previous errors
123+

0 commit comments

Comments
 (0)