Skip to content

Commit 6ec2474

Browse files
Strenghten tests for crate-level attributes check
1 parent 3950a6d commit 6ec2474

File tree

2 files changed

+107
-18
lines changed

2 files changed

+107
-18
lines changed

src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs-error.rs

+22
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@
77

88
// ignore-tidy-linelength
99

10+
#![deny(unused_attributes)]
11+
//~^ NOTE not a function or static
12+
//~^^ NOTE the lint level is defined here
13+
//~^^^ NOTE not an `extern crate` item
14+
//~^^^^ NOTE not a function or static
15+
//~^^^^^ NOTE not a function or closure
16+
17+
#![macro_export]
18+
#![main]
19+
#![start]
20+
#![repr()]
21+
#![path = "3800"]
22+
#![automatically_derived]
23+
#![no_mangle]
24+
//~^ ERROR attribute should be applied to a function or static
25+
//~^^ WARN
26+
#![no_link]
27+
//~^ ERROR: attribute should be applied to an `extern crate` item
28+
#![export_name = "2200"]
29+
//~^ ERROR: attribute should be applied to a function or static
30+
#![inline]
31+
//~^ ERROR: attribute should be applied to function or closure
1032
#[inline]
1133
//~^ ERROR attribute should be applied to function or closure
1234
mod inline {

src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs-error.stderr

+85-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: attribute must be of the form `#[inline]` or `#[inline(always|never)]`
2-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:19:5
2+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:41:5
33
|
44
LL | #[inline = "2100"] fn f() { }
55
| ^^^^^^^^^^^^^^^^^^
@@ -9,7 +9,7 @@ LL | #[inline = "2100"] fn f() { }
99
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
1010

1111
error[E0518]: attribute should be applied to function or closure
12-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:10:1
12+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:32:1
1313
|
1414
LL | #[inline]
1515
| ^^^^^^^^^
@@ -24,7 +24,7 @@ LL | | }
2424
| |_- not a function or closure
2525

2626
error: attribute should be applied to an `extern crate` item
27-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:38:1
27+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:60:1
2828
|
2929
LL | #[no_link]
3030
| ^^^^^^^^^^
@@ -39,7 +39,7 @@ LL | | }
3939
| |_- not an `extern crate` item
4040

4141
error: attribute should be applied to a function or static
42-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:64:1
42+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:86:1
4343
|
4444
LL | #[export_name = "2200"]
4545
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -53,84 +53,151 @@ LL | |
5353
LL | | }
5454
| |_- not a function or static
5555

56+
error: attribute should be applied to a function or static
57+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:23:1
58+
|
59+
LL | / #![deny(unused_attributes)]
60+
LL | |
61+
LL | |
62+
LL | |
63+
... |
64+
LL | | #![no_mangle]
65+
| | ^^^^^^^^^^^^^
66+
... |
67+
LL | |
68+
LL | | fn main() {}
69+
| |____________- not a function or static
70+
|
71+
note: the lint level is defined here
72+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:10:9
73+
|
74+
LL | #![deny(unused_attributes)]
75+
| ^^^^^^^^^^^^^^^^^
76+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
77+
78+
error: attribute should be applied to an `extern crate` item
79+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:26:1
80+
|
81+
LL | / #![deny(unused_attributes)]
82+
LL | |
83+
LL | |
84+
LL | |
85+
... |
86+
LL | | #![no_link]
87+
| | ^^^^^^^^^^^
88+
... |
89+
LL | |
90+
LL | | fn main() {}
91+
| |____________- not an `extern crate` item
92+
93+
error: attribute should be applied to a function or static
94+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:28:1
95+
|
96+
LL | / #![deny(unused_attributes)]
97+
LL | |
98+
LL | |
99+
LL | |
100+
... |
101+
LL | | #![export_name = "2200"]
102+
| | ^^^^^^^^^^^^^^^^^^^^^^^^
103+
... |
104+
LL | |
105+
LL | | fn main() {}
106+
| |____________- not a function or static
107+
108+
error[E0518]: attribute should be applied to function or closure
109+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:30:1
110+
|
111+
LL | / #![deny(unused_attributes)]
112+
LL | |
113+
LL | |
114+
LL | |
115+
... |
116+
LL | | #![inline]
117+
| | ^^^^^^^^^^
118+
... |
119+
LL | |
120+
LL | | fn main() {}
121+
| |____________- not a function or closure
122+
56123
error[E0518]: attribute should be applied to function or closure
57-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:15:17
124+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:37:17
58125
|
59126
LL | mod inner { #![inline] }
60127
| ------------^^^^^^^^^^-- not a function or closure
61128

62129
error[E0518]: attribute should be applied to function or closure
63-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:25:5
130+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:47:5
64131
|
65132
LL | #[inline] struct S;
66133
| ^^^^^^^^^ --------- not a function or closure
67134

68135
error[E0518]: attribute should be applied to function or closure
69-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:29:5
136+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:51:5
70137
|
71138
LL | #[inline] type T = S;
72139
| ^^^^^^^^^ ----------- not a function or closure
73140

74141
error[E0518]: attribute should be applied to function or closure
75-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:33:5
142+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:55:5
76143
|
77144
LL | #[inline] impl S { }
78145
| ^^^^^^^^^ ---------- not a function or closure
79146

80147
error: attribute should be applied to an `extern crate` item
81-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:43:17
148+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:65:17
82149
|
83150
LL | mod inner { #![no_link] }
84151
| ------------^^^^^^^^^^^-- not an `extern crate` item
85152

86153
error: attribute should be applied to an `extern crate` item
87-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:47:5
154+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:69:5
88155
|
89156
LL | #[no_link] fn f() { }
90157
| ^^^^^^^^^^ ---------- not an `extern crate` item
91158

92159
error: attribute should be applied to an `extern crate` item
93-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:51:5
160+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:73:5
94161
|
95162
LL | #[no_link] struct S;
96163
| ^^^^^^^^^^ --------- not an `extern crate` item
97164

98165
error: attribute should be applied to an `extern crate` item
99-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:55:5
166+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:77:5
100167
|
101168
LL | #[no_link]type T = S;
102169
| ^^^^^^^^^^----------- not an `extern crate` item
103170

104171
error: attribute should be applied to an `extern crate` item
105-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:59:5
172+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:81:5
106173
|
107174
LL | #[no_link] impl S { }
108175
| ^^^^^^^^^^ ---------- not an `extern crate` item
109176

110177
error: attribute should be applied to a function or static
111-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:69:17
178+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:91:17
112179
|
113180
LL | mod inner { #![export_name="2200"] }
114181
| ------------^^^^^^^^^^^^^^^^^^^^^^-- not a function or static
115182

116183
error: attribute should be applied to a function or static
117-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:75:5
184+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:97:5
118185
|
119186
LL | #[export_name = "2200"] struct S;
120187
| ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a function or static
121188

122189
error: attribute should be applied to a function or static
123-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:79:5
190+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:101:5
124191
|
125192
LL | #[export_name = "2200"] type T = S;
126193
| ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a function or static
127194

128195
error: attribute should be applied to a function or static
129-
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:83:5
196+
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:105:5
130197
|
131198
LL | #[export_name = "2200"] impl S { }
132199
| ^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a function or static
133200

134-
error: aborting due to 17 previous errors
201+
error: aborting due to 21 previous errors
135202

136203
For more information about this error, try `rustc --explain E0518`.

0 commit comments

Comments
 (0)