Skip to content

Commit 9dd2d71

Browse files
Regression test for attributes on macro calls
1 parent e0d4350 commit 9dd2d71

File tree

2 files changed

+300
-0
lines changed

2 files changed

+300
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ check-pass
2+
// Regression test for https://github.com/rust-lang/rust/issues/145779
3+
#![warn(unused_attributes)]
4+
5+
fn main() {
6+
#[export_name = "x"] //~ WARN unused attribute
7+
#[unsafe(naked)] //~ WARN unused attribute
8+
#[track_caller] //~ WARN unused attribute
9+
#[used] //~ WARN unused attribute
10+
#[target_feature(enable = "x")] //~ WARN unused attribute
11+
#[deprecated] //~ WARN unused attribute
12+
#[inline] //~ WARN unused attribute
13+
#[link_name = "x"] //~ WARN unused attribute
14+
#[link_section = "x"] //~ WARN unused attribute
15+
#[link_ordinal(42)] //~ WARN unused attribute
16+
#[non_exhaustive] //~ WARN unused attribute
17+
#[proc_macro] //~ WARN unused attribute
18+
#[cold] //~ WARN unused attribute
19+
#[no_mangle] //~ WARN unused attribute
20+
#[deprecated] //~ WARN unused attribute
21+
#[automatically_derived] //~ WARN unused attribute
22+
#[macro_use] //~ WARN unused attribute
23+
#[must_use] //~ WARN unused attribute
24+
#[no_implicit_prelude] //~ WARN unused attribute
25+
#[path = ""] //~ WARN unused attribute
26+
#[ignore] //~ WARN unused attribute
27+
#[should_panic] //~ WARN unused attribute
28+
unreachable!();
29+
}
Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
warning: unused attribute `export_name`
2+
--> $DIR/attr-on-mac-call.rs:6:5
3+
|
4+
LL | #[export_name = "x"]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: the built-in attribute `export_name` will be ignored, since it's applied to the macro invocation `unreachable`
8+
--> $DIR/attr-on-mac-call.rs:28:5
9+
|
10+
LL | unreachable!();
11+
| ^^^^^^^^^^^
12+
note: the lint level is defined here
13+
--> $DIR/attr-on-mac-call.rs:3:9
14+
|
15+
LL | #![warn(unused_attributes)]
16+
| ^^^^^^^^^^^^^^^^^
17+
18+
warning: unused attribute `naked`
19+
--> $DIR/attr-on-mac-call.rs:7:5
20+
|
21+
LL | #[unsafe(naked)]
22+
| ^^^^^^^^^^^^^^^^
23+
|
24+
note: the built-in attribute `naked` will be ignored, since it's applied to the macro invocation `unreachable`
25+
--> $DIR/attr-on-mac-call.rs:28:5
26+
|
27+
LL | unreachable!();
28+
| ^^^^^^^^^^^
29+
30+
warning: unused attribute `track_caller`
31+
--> $DIR/attr-on-mac-call.rs:8:5
32+
|
33+
LL | #[track_caller]
34+
| ^^^^^^^^^^^^^^^
35+
|
36+
note: the built-in attribute `track_caller` will be ignored, since it's applied to the macro invocation `unreachable`
37+
--> $DIR/attr-on-mac-call.rs:28:5
38+
|
39+
LL | unreachable!();
40+
| ^^^^^^^^^^^
41+
42+
warning: unused attribute `used`
43+
--> $DIR/attr-on-mac-call.rs:9:5
44+
|
45+
LL | #[used]
46+
| ^^^^^^^
47+
|
48+
note: the built-in attribute `used` will be ignored, since it's applied to the macro invocation `unreachable`
49+
--> $DIR/attr-on-mac-call.rs:28:5
50+
|
51+
LL | unreachable!();
52+
| ^^^^^^^^^^^
53+
54+
warning: unused attribute `target_feature`
55+
--> $DIR/attr-on-mac-call.rs:10:5
56+
|
57+
LL | #[target_feature(enable = "x")]
58+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59+
|
60+
note: the built-in attribute `target_feature` will be ignored, since it's applied to the macro invocation `unreachable`
61+
--> $DIR/attr-on-mac-call.rs:28:5
62+
|
63+
LL | unreachable!();
64+
| ^^^^^^^^^^^
65+
66+
warning: unused attribute `deprecated`
67+
--> $DIR/attr-on-mac-call.rs:11:5
68+
|
69+
LL | #[deprecated]
70+
| ^^^^^^^^^^^^^
71+
|
72+
note: the built-in attribute `deprecated` will be ignored, since it's applied to the macro invocation `unreachable`
73+
--> $DIR/attr-on-mac-call.rs:28:5
74+
|
75+
LL | unreachable!();
76+
| ^^^^^^^^^^^
77+
78+
warning: unused attribute `inline`
79+
--> $DIR/attr-on-mac-call.rs:12:5
80+
|
81+
LL | #[inline]
82+
| ^^^^^^^^^
83+
|
84+
note: the built-in attribute `inline` will be ignored, since it's applied to the macro invocation `unreachable`
85+
--> $DIR/attr-on-mac-call.rs:28:5
86+
|
87+
LL | unreachable!();
88+
| ^^^^^^^^^^^
89+
90+
warning: unused attribute `link_name`
91+
--> $DIR/attr-on-mac-call.rs:13:5
92+
|
93+
LL | #[link_name = "x"]
94+
| ^^^^^^^^^^^^^^^^^^
95+
|
96+
note: the built-in attribute `link_name` will be ignored, since it's applied to the macro invocation `unreachable`
97+
--> $DIR/attr-on-mac-call.rs:28:5
98+
|
99+
LL | unreachable!();
100+
| ^^^^^^^^^^^
101+
102+
warning: unused attribute `link_section`
103+
--> $DIR/attr-on-mac-call.rs:14:5
104+
|
105+
LL | #[link_section = "x"]
106+
| ^^^^^^^^^^^^^^^^^^^^^
107+
|
108+
note: the built-in attribute `link_section` will be ignored, since it's applied to the macro invocation `unreachable`
109+
--> $DIR/attr-on-mac-call.rs:28:5
110+
|
111+
LL | unreachable!();
112+
| ^^^^^^^^^^^
113+
114+
warning: unused attribute `link_ordinal`
115+
--> $DIR/attr-on-mac-call.rs:15:5
116+
|
117+
LL | #[link_ordinal(42)]
118+
| ^^^^^^^^^^^^^^^^^^^
119+
|
120+
note: the built-in attribute `link_ordinal` will be ignored, since it's applied to the macro invocation `unreachable`
121+
--> $DIR/attr-on-mac-call.rs:28:5
122+
|
123+
LL | unreachable!();
124+
| ^^^^^^^^^^^
125+
126+
warning: unused attribute `non_exhaustive`
127+
--> $DIR/attr-on-mac-call.rs:16:5
128+
|
129+
LL | #[non_exhaustive]
130+
| ^^^^^^^^^^^^^^^^^
131+
|
132+
note: the built-in attribute `non_exhaustive` will be ignored, since it's applied to the macro invocation `unreachable`
133+
--> $DIR/attr-on-mac-call.rs:28:5
134+
|
135+
LL | unreachable!();
136+
| ^^^^^^^^^^^
137+
138+
warning: unused attribute `proc_macro`
139+
--> $DIR/attr-on-mac-call.rs:17:5
140+
|
141+
LL | #[proc_macro]
142+
| ^^^^^^^^^^^^^
143+
|
144+
note: the built-in attribute `proc_macro` will be ignored, since it's applied to the macro invocation `unreachable`
145+
--> $DIR/attr-on-mac-call.rs:28:5
146+
|
147+
LL | unreachable!();
148+
| ^^^^^^^^^^^
149+
150+
warning: unused attribute `cold`
151+
--> $DIR/attr-on-mac-call.rs:18:5
152+
|
153+
LL | #[cold]
154+
| ^^^^^^^
155+
|
156+
note: the built-in attribute `cold` will be ignored, since it's applied to the macro invocation `unreachable`
157+
--> $DIR/attr-on-mac-call.rs:28:5
158+
|
159+
LL | unreachable!();
160+
| ^^^^^^^^^^^
161+
162+
warning: unused attribute `no_mangle`
163+
--> $DIR/attr-on-mac-call.rs:19:5
164+
|
165+
LL | #[no_mangle]
166+
| ^^^^^^^^^^^^
167+
|
168+
note: the built-in attribute `no_mangle` will be ignored, since it's applied to the macro invocation `unreachable`
169+
--> $DIR/attr-on-mac-call.rs:28:5
170+
|
171+
LL | unreachable!();
172+
| ^^^^^^^^^^^
173+
174+
warning: unused attribute `deprecated`
175+
--> $DIR/attr-on-mac-call.rs:20:5
176+
|
177+
LL | #[deprecated]
178+
| ^^^^^^^^^^^^^
179+
|
180+
note: the built-in attribute `deprecated` will be ignored, since it's applied to the macro invocation `unreachable`
181+
--> $DIR/attr-on-mac-call.rs:28:5
182+
|
183+
LL | unreachable!();
184+
| ^^^^^^^^^^^
185+
186+
warning: unused attribute `automatically_derived`
187+
--> $DIR/attr-on-mac-call.rs:21:5
188+
|
189+
LL | #[automatically_derived]
190+
| ^^^^^^^^^^^^^^^^^^^^^^^^
191+
|
192+
note: the built-in attribute `automatically_derived` will be ignored, since it's applied to the macro invocation `unreachable`
193+
--> $DIR/attr-on-mac-call.rs:28:5
194+
|
195+
LL | unreachable!();
196+
| ^^^^^^^^^^^
197+
198+
warning: unused attribute `macro_use`
199+
--> $DIR/attr-on-mac-call.rs:22:5
200+
|
201+
LL | #[macro_use]
202+
| ^^^^^^^^^^^^
203+
|
204+
note: the built-in attribute `macro_use` will be ignored, since it's applied to the macro invocation `unreachable`
205+
--> $DIR/attr-on-mac-call.rs:28:5
206+
|
207+
LL | unreachable!();
208+
| ^^^^^^^^^^^
209+
210+
warning: unused attribute `must_use`
211+
--> $DIR/attr-on-mac-call.rs:23:5
212+
|
213+
LL | #[must_use]
214+
| ^^^^^^^^^^^
215+
|
216+
note: the built-in attribute `must_use` will be ignored, since it's applied to the macro invocation `unreachable`
217+
--> $DIR/attr-on-mac-call.rs:28:5
218+
|
219+
LL | unreachable!();
220+
| ^^^^^^^^^^^
221+
222+
warning: unused attribute `no_implicit_prelude`
223+
--> $DIR/attr-on-mac-call.rs:24:5
224+
|
225+
LL | #[no_implicit_prelude]
226+
| ^^^^^^^^^^^^^^^^^^^^^^
227+
|
228+
note: the built-in attribute `no_implicit_prelude` will be ignored, since it's applied to the macro invocation `unreachable`
229+
--> $DIR/attr-on-mac-call.rs:28:5
230+
|
231+
LL | unreachable!();
232+
| ^^^^^^^^^^^
233+
234+
warning: unused attribute `path`
235+
--> $DIR/attr-on-mac-call.rs:25:5
236+
|
237+
LL | #[path = ""]
238+
| ^^^^^^^^^^^^
239+
|
240+
note: the built-in attribute `path` will be ignored, since it's applied to the macro invocation `unreachable`
241+
--> $DIR/attr-on-mac-call.rs:28:5
242+
|
243+
LL | unreachable!();
244+
| ^^^^^^^^^^^
245+
246+
warning: unused attribute `ignore`
247+
--> $DIR/attr-on-mac-call.rs:26:5
248+
|
249+
LL | #[ignore]
250+
| ^^^^^^^^^
251+
|
252+
note: the built-in attribute `ignore` will be ignored, since it's applied to the macro invocation `unreachable`
253+
--> $DIR/attr-on-mac-call.rs:28:5
254+
|
255+
LL | unreachable!();
256+
| ^^^^^^^^^^^
257+
258+
warning: unused attribute `should_panic`
259+
--> $DIR/attr-on-mac-call.rs:27:5
260+
|
261+
LL | #[should_panic]
262+
| ^^^^^^^^^^^^^^^
263+
|
264+
note: the built-in attribute `should_panic` will be ignored, since it's applied to the macro invocation `unreachable`
265+
--> $DIR/attr-on-mac-call.rs:28:5
266+
|
267+
LL | unreachable!();
268+
| ^^^^^^^^^^^
269+
270+
warning: 22 warnings emitted
271+

0 commit comments

Comments
 (0)