Skip to content

Commit b09a9d0

Browse files
committed
add tests making sure to FCW warn on field, arm, and macro def
1 parent 52bcaab commit b09a9d0

File tree

2 files changed

+70
-25
lines changed

2 files changed

+70
-25
lines changed

tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,35 @@ mod no_link {
6464
mod inner { #![no_link] }
6565
//~^ ERROR `#[no_link]` attribute cannot be used on modules
6666

67-
#[no_link] fn f() { }
68-
//~^ ERROR `#[no_link]` attribute cannot be used on functions
67+
#[no_link] fn f() {
68+
//~^ ERROR `#[no_link]` attribute cannot be used on functions
69+
match () {
70+
#[no_link]
71+
//~^ WARN `#[no_link]` attribute cannot be used on match arms [unused_attributes]
72+
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
73+
_ => ()
74+
}
75+
}
6976

70-
#[no_link] struct S;
77+
#[no_link]
7178
//~^ ERROR `#[no_link]` attribute cannot be used on structs
79+
struct S {
80+
#[no_link]
81+
//~^ WARN `#[no_link]` attribute cannot be used on struct fields [unused_attributes]
82+
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
83+
field: ()
84+
}
7285

7386
#[no_link]type T = S;
7487
//~^ ERROR `#[no_link]` attribute cannot be used on type aliases
7588

7689
#[no_link] impl S { }
7790
//~^ ERROR `#[no_link]` attribute cannot be used on inherent impl blocks
91+
92+
#[no_link]
93+
//~^ WARN `#[no_link]` attribute cannot be used on macro defs
94+
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
95+
macro_rules! m{() => {}}
7896
}
7997

8098
#[export_name = "2200"]

tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,85 +123,85 @@ LL | mod inner { #![no_link] }
123123
error: `#[no_link]` attribute cannot be used on functions
124124
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:67:5
125125
|
126-
LL | #[no_link] fn f() { }
126+
LL | #[no_link] fn f() {
127127
| ^^^^^^^^^^
128128
|
129129
= help: `#[no_link]` can only be applied to extern crates
130130

131131
error: `#[no_link]` attribute cannot be used on structs
132-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:70:5
132+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:77:5
133133
|
134-
LL | #[no_link] struct S;
134+
LL | #[no_link]
135135
| ^^^^^^^^^^
136136
|
137137
= help: `#[no_link]` can only be applied to extern crates
138138

139139
error: `#[no_link]` attribute cannot be used on type aliases
140-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:73:5
140+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:86:5
141141
|
142142
LL | #[no_link]type T = S;
143143
| ^^^^^^^^^^
144144
|
145145
= help: `#[no_link]` can only be applied to extern crates
146146

147147
error: `#[no_link]` attribute cannot be used on inherent impl blocks
148-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:76:5
148+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:89:5
149149
|
150150
LL | #[no_link] impl S { }
151151
| ^^^^^^^^^^
152152
|
153153
= help: `#[no_link]` can only be applied to extern crates
154154

155155
error: `#[export_name]` attribute cannot be used on modules
156-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:80:1
156+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:98:1
157157
|
158158
LL | #[export_name = "2200"]
159159
| ^^^^^^^^^^^^^^^^^^^^^^^
160160
|
161161
= help: `#[export_name]` can be applied to functions and statics
162162

163163
error: `#[export_name]` attribute cannot be used on modules
164-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:83:17
164+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:101:17
165165
|
166166
LL | mod inner { #![export_name="2200"] }
167167
| ^^^^^^^^^^^^^^^^^^^^^^
168168
|
169169
= help: `#[export_name]` can be applied to functions and statics
170170

171171
error: `#[export_name]` attribute cannot be used on structs
172-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:88:5
172+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:106:5
173173
|
174174
LL | #[export_name = "2200"] struct S;
175175
| ^^^^^^^^^^^^^^^^^^^^^^^
176176
|
177177
= help: `#[export_name]` can be applied to functions and statics
178178

179179
error: `#[export_name]` attribute cannot be used on type aliases
180-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:91:5
180+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:109:5
181181
|
182182
LL | #[export_name = "2200"] type T = S;
183183
| ^^^^^^^^^^^^^^^^^^^^^^^
184184
|
185185
= help: `#[export_name]` can be applied to functions and statics
186186

187187
error: `#[export_name]` attribute cannot be used on inherent impl blocks
188-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:94:5
188+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:112:5
189189
|
190190
LL | #[export_name = "2200"] impl S { }
191191
| ^^^^^^^^^^^^^^^^^^^^^^^
192192
|
193193
= help: `#[export_name]` can be applied to functions and statics
194194

195195
error: `#[export_name]` attribute cannot be used on required trait methods
196-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:98:9
196+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:116:9
197197
|
198198
LL | #[export_name = "2200"] fn foo();
199199
| ^^^^^^^^^^^^^^^^^^^^^^^
200200
|
201201
= help: `#[export_name]` can be applied to functions, inherent methods, provided trait methods, statics, and trait methods in impl blocks
202202

203203
error[E0517]: attribute should be applied to a struct, enum, or union
204-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:105:8
204+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:123:8
205205
|
206206
LL | #[repr(C)]
207207
| ^
@@ -214,7 +214,7 @@ LL | | }
214214
| |_- not a struct, enum, or union
215215

216216
error[E0517]: attribute should be applied to a struct, enum, or union
217-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:129:8
217+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:147:8
218218
|
219219
LL | #[repr(Rust)]
220220
| ^^^^
@@ -259,49 +259,49 @@ LL + #[repr()]
259259
|
260260

261261
error[E0517]: attribute should be applied to a struct, enum, or union
262-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:109:25
262+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:127:25
263263
|
264264
LL | mod inner { #![repr(C)] }
265265
| --------------------^---- not a struct, enum, or union
266266

267267
error[E0517]: attribute should be applied to a struct, enum, or union
268-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:113:12
268+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:131:12
269269
|
270270
LL | #[repr(C)] fn f() { }
271271
| ^ ---------- not a struct, enum, or union
272272

273273
error[E0517]: attribute should be applied to a struct, enum, or union
274-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:119:12
274+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:137:12
275275
|
276276
LL | #[repr(C)] type T = S;
277277
| ^ ----------- not a struct, enum, or union
278278

279279
error[E0517]: attribute should be applied to a struct, enum, or union
280-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:123:12
280+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:141:12
281281
|
282282
LL | #[repr(C)] impl S { }
283283
| ^ ---------- not a struct, enum, or union
284284

285285
error[E0517]: attribute should be applied to a struct, enum, or union
286-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:133:25
286+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:151:25
287287
|
288288
LL | mod inner { #![repr(Rust)] }
289289
| --------------------^^^^---- not a struct, enum, or union
290290

291291
error[E0517]: attribute should be applied to a struct, enum, or union
292-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:137:12
292+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:155:12
293293
|
294294
LL | #[repr(Rust)] fn f() { }
295295
| ^^^^ ---------- not a struct, enum, or union
296296

297297
error[E0517]: attribute should be applied to a struct, enum, or union
298-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:143:12
298+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:161:12
299299
|
300300
LL | #[repr(Rust)] type T = S;
301301
| ^^^^ ----------- not a struct, enum, or union
302302

303303
error[E0517]: attribute should be applied to a struct, enum, or union
304-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:147:12
304+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:165:12
305305
|
306306
LL | #[repr(Rust)] impl S { }
307307
| ^^^^ ---------- not a struct, enum, or union
@@ -316,6 +316,33 @@ LL | #[inline = "2100"] fn f() { }
316316
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
317317
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
318318

319+
warning: `#[no_link]` attribute cannot be used on match arms
320+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:70:13
321+
|
322+
LL | #[no_link]
323+
| ^^^^^^^^^^
324+
|
325+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
326+
= help: `#[no_link]` can only be applied to extern crates
327+
328+
warning: `#[no_link]` attribute cannot be used on struct fields
329+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:80:9
330+
|
331+
LL | #[no_link]
332+
| ^^^^^^^^^^
333+
|
334+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
335+
= help: `#[no_link]` can only be applied to extern crates
336+
337+
warning: `#[no_link]` attribute cannot be used on macro defs
338+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:92:5
339+
|
340+
LL | #[no_link]
341+
| ^^^^^^^^^^
342+
|
343+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
344+
= help: `#[no_link]` can only be applied to extern crates
345+
319346
warning: unused attribute
320347
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:16:1
321348
|
@@ -333,7 +360,7 @@ LL | #![no_mangle]
333360
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
334361
= help: `#[no_mangle]` can be applied to functions and statics
335362

336-
error: aborting due to 37 previous errors; 3 warnings emitted
363+
error: aborting due to 37 previous errors; 6 warnings emitted
337364

338365
Some errors have detailed explanations: E0517, E0658.
339366
For more information about an error, try `rustc --explain E0517`.

0 commit comments

Comments
 (0)