Skip to content

Commit 1b364ae

Browse files
authored
Rollup merge of rust-lang#95910 - ehuss:fix-crate-type-duplicate, r=Dylan-DPC
Fix crate_type attribute to not warn on duplicates In rust-lang#88681 I accidentally marked the `crate_type` attribute as only allowing a single attribute. However, multiple attributes are allowed (they are joined together [here](https://github.com/rust-lang/rust/blob/027a232755fa9728e9699337267f6675dfd0a8ba/compiler/rustc_interface/src/util.rs#L530-L542)). This fixes it to not report a warning if duplicates are found. Closes rust-lang#95902
2 parents 2836143 + be23ead commit 1b364ae

File tree

3 files changed

+45
-61
lines changed

3 files changed

+45
-61
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
310310

311311
// Crate properties:
312312
ungated!(crate_name, CrateLevel, template!(NameValueStr: "name"), FutureWarnFollowing),
313-
ungated!(crate_type, CrateLevel, template!(NameValueStr: "bin|lib|..."), FutureWarnFollowing),
313+
ungated!(crate_type, CrateLevel, template!(NameValueStr: "bin|lib|..."), DuplicatesOk),
314314
// crate_id is deprecated
315315
ungated!(crate_id, CrateLevel, template!(NameValueStr: "ignored"), FutureWarnFollowing),
316316

src/test/ui/lint/unused/unused-attr-duplicate.rs

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#![crate_name = "unused_attr_duplicate"]
1414
#![crate_name = "unused_attr_duplicate2"] //~ ERROR unused attribute
1515
//~^ WARN this was previously accepted
16-
#![crate_type = "bin"]
17-
#![crate_type = "rlib"] //~ ERROR unused attribute
18-
//~^ WARN this was previously accepted
1916
#![recursion_limit = "128"]
2017
#![recursion_limit = "256"] //~ ERROR unused attribute
2118
//~^ WARN this was previously accepted
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unused attribute
2-
--> $DIR/unused-attr-duplicate.rs:36:1
2+
--> $DIR/unused-attr-duplicate.rs:33:1
33
|
44
LL | #[no_link]
55
| ^^^^^^^^^^ help: remove this attribute
@@ -10,180 +10,180 @@ note: the lint level is defined here
1010
LL | #![deny(unused_attributes)]
1111
| ^^^^^^^^^^^^^^^^^
1212
note: attribute also specified here
13-
--> $DIR/unused-attr-duplicate.rs:35:1
13+
--> $DIR/unused-attr-duplicate.rs:32:1
1414
|
1515
LL | #[no_link]
1616
| ^^^^^^^^^^
1717

1818
error: unused attribute
19-
--> $DIR/unused-attr-duplicate.rs:40:1
19+
--> $DIR/unused-attr-duplicate.rs:37:1
2020
|
2121
LL | #[macro_use]
2222
| ^^^^^^^^^^^^ help: remove this attribute
2323
|
2424
note: attribute also specified here
25-
--> $DIR/unused-attr-duplicate.rs:39:1
25+
--> $DIR/unused-attr-duplicate.rs:36:1
2626
|
2727
LL | #[macro_use]
2828
| ^^^^^^^^^^^^
2929

3030
error: unused attribute
31-
--> $DIR/unused-attr-duplicate.rs:50:1
31+
--> $DIR/unused-attr-duplicate.rs:47:1
3232
|
3333
LL | #[path = "bar.rs"]
3434
| ^^^^^^^^^^^^^^^^^^ help: remove this attribute
3535
|
3636
note: attribute also specified here
37-
--> $DIR/unused-attr-duplicate.rs:49:1
37+
--> $DIR/unused-attr-duplicate.rs:46:1
3838
|
3939
LL | #[path = "auxiliary/lint_unused_extern_crate.rs"]
4040
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4141
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4242

4343
error: unused attribute
44-
--> $DIR/unused-attr-duplicate.rs:56:1
44+
--> $DIR/unused-attr-duplicate.rs:53:1
4545
|
4646
LL | #[ignore = "some text"]
4747
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
4848
|
4949
note: attribute also specified here
50-
--> $DIR/unused-attr-duplicate.rs:55:1
50+
--> $DIR/unused-attr-duplicate.rs:52:1
5151
|
5252
LL | #[ignore]
5353
| ^^^^^^^^^
5454

5555
error: unused attribute
56-
--> $DIR/unused-attr-duplicate.rs:58:1
56+
--> $DIR/unused-attr-duplicate.rs:55:1
5757
|
5858
LL | #[should_panic(expected = "values don't match")]
5959
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
6060
|
6161
note: attribute also specified here
62-
--> $DIR/unused-attr-duplicate.rs:57:1
62+
--> $DIR/unused-attr-duplicate.rs:54:1
6363
|
6464
LL | #[should_panic]
6565
| ^^^^^^^^^^^^^^^
6666
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
6767

6868
error: unused attribute
69-
--> $DIR/unused-attr-duplicate.rs:63:1
69+
--> $DIR/unused-attr-duplicate.rs:60:1
7070
|
7171
LL | #[must_use = "some message"]
7272
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
7373
|
7474
note: attribute also specified here
75-
--> $DIR/unused-attr-duplicate.rs:62:1
75+
--> $DIR/unused-attr-duplicate.rs:59:1
7676
|
7777
LL | #[must_use]
7878
| ^^^^^^^^^^^
7979
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8080

8181
error: unused attribute
82-
--> $DIR/unused-attr-duplicate.rs:69:1
82+
--> $DIR/unused-attr-duplicate.rs:66:1
8383
|
8484
LL | #[non_exhaustive]
8585
| ^^^^^^^^^^^^^^^^^ help: remove this attribute
8686
|
8787
note: attribute also specified here
88-
--> $DIR/unused-attr-duplicate.rs:68:1
88+
--> $DIR/unused-attr-duplicate.rs:65:1
8989
|
9090
LL | #[non_exhaustive]
9191
| ^^^^^^^^^^^^^^^^^
9292

9393
error: unused attribute
94-
--> $DIR/unused-attr-duplicate.rs:73:1
94+
--> $DIR/unused-attr-duplicate.rs:70:1
9595
|
9696
LL | #[automatically_derived]
9797
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
9898
|
9999
note: attribute also specified here
100-
--> $DIR/unused-attr-duplicate.rs:72:1
100+
--> $DIR/unused-attr-duplicate.rs:69:1
101101
|
102102
LL | #[automatically_derived]
103103
| ^^^^^^^^^^^^^^^^^^^^^^^^
104104

105105
error: unused attribute
106-
--> $DIR/unused-attr-duplicate.rs:77:1
106+
--> $DIR/unused-attr-duplicate.rs:74:1
107107
|
108108
LL | #[inline(never)]
109109
| ^^^^^^^^^^^^^^^^ help: remove this attribute
110110
|
111111
note: attribute also specified here
112-
--> $DIR/unused-attr-duplicate.rs:76:1
112+
--> $DIR/unused-attr-duplicate.rs:73:1
113113
|
114114
LL | #[inline(always)]
115115
| ^^^^^^^^^^^^^^^^^
116116
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
117117

118118
error: unused attribute
119-
--> $DIR/unused-attr-duplicate.rs:80:1
119+
--> $DIR/unused-attr-duplicate.rs:77:1
120120
|
121121
LL | #[cold]
122122
| ^^^^^^^ help: remove this attribute
123123
|
124124
note: attribute also specified here
125-
--> $DIR/unused-attr-duplicate.rs:79:1
125+
--> $DIR/unused-attr-duplicate.rs:76:1
126126
|
127127
LL | #[cold]
128128
| ^^^^^^^
129129

130130
error: unused attribute
131-
--> $DIR/unused-attr-duplicate.rs:82:1
131+
--> $DIR/unused-attr-duplicate.rs:79:1
132132
|
133133
LL | #[track_caller]
134134
| ^^^^^^^^^^^^^^^ help: remove this attribute
135135
|
136136
note: attribute also specified here
137-
--> $DIR/unused-attr-duplicate.rs:81:1
137+
--> $DIR/unused-attr-duplicate.rs:78:1
138138
|
139139
LL | #[track_caller]
140140
| ^^^^^^^^^^^^^^^
141141

142142
error: unused attribute
143-
--> $DIR/unused-attr-duplicate.rs:95:1
143+
--> $DIR/unused-attr-duplicate.rs:92:1
144144
|
145145
LL | #[export_name = "exported_symbol_name"]
146146
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
147147
|
148148
note: attribute also specified here
149-
--> $DIR/unused-attr-duplicate.rs:97:1
149+
--> $DIR/unused-attr-duplicate.rs:94:1
150150
|
151151
LL | #[export_name = "exported_symbol_name2"]
152152
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
153153
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
154154

155155
error: unused attribute
156-
--> $DIR/unused-attr-duplicate.rs:101:1
156+
--> $DIR/unused-attr-duplicate.rs:98:1
157157
|
158158
LL | #[no_mangle]
159159
| ^^^^^^^^^^^^ help: remove this attribute
160160
|
161161
note: attribute also specified here
162-
--> $DIR/unused-attr-duplicate.rs:100:1
162+
--> $DIR/unused-attr-duplicate.rs:97:1
163163
|
164164
LL | #[no_mangle]
165165
| ^^^^^^^^^^^^
166166

167167
error: unused attribute
168-
--> $DIR/unused-attr-duplicate.rs:105:1
168+
--> $DIR/unused-attr-duplicate.rs:102:1
169169
|
170170
LL | #[used]
171171
| ^^^^^^^ help: remove this attribute
172172
|
173173
note: attribute also specified here
174-
--> $DIR/unused-attr-duplicate.rs:104:1
174+
--> $DIR/unused-attr-duplicate.rs:101:1
175175
|
176176
LL | #[used]
177177
| ^^^^^^^
178178

179179
error: unused attribute
180-
--> $DIR/unused-attr-duplicate.rs:89:5
180+
--> $DIR/unused-attr-duplicate.rs:86:5
181181
|
182182
LL | #[link_name = "this_does_not_exist"]
183183
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
184184
|
185185
note: attribute also specified here
186-
--> $DIR/unused-attr-duplicate.rs:91:5
186+
--> $DIR/unused-attr-duplicate.rs:88:5
187187
|
188188
LL | #[link_name = "rust_dbg_extern_identity_u32"]
189189
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -205,102 +205,89 @@ LL | #![crate_name = "unused_attr_duplicate"]
205205
error: unused attribute
206206
--> $DIR/unused-attr-duplicate.rs:17:1
207207
|
208-
LL | #![crate_type = "rlib"]
209-
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
210-
|
211-
note: attribute also specified here
212-
--> $DIR/unused-attr-duplicate.rs:16:1
213-
|
214-
LL | #![crate_type = "bin"]
215-
| ^^^^^^^^^^^^^^^^^^^^^^
216-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
217-
218-
error: unused attribute
219-
--> $DIR/unused-attr-duplicate.rs:20:1
220-
|
221208
LL | #![recursion_limit = "256"]
222209
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
223210
|
224211
note: attribute also specified here
225-
--> $DIR/unused-attr-duplicate.rs:19:1
212+
--> $DIR/unused-attr-duplicate.rs:16:1
226213
|
227214
LL | #![recursion_limit = "128"]
228215
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
229216
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
230217

231218
error: unused attribute
232-
--> $DIR/unused-attr-duplicate.rs:23:1
219+
--> $DIR/unused-attr-duplicate.rs:20:1
233220
|
234221
LL | #![type_length_limit = "1"]
235222
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
236223
|
237224
note: attribute also specified here
238-
--> $DIR/unused-attr-duplicate.rs:22:1
225+
--> $DIR/unused-attr-duplicate.rs:19:1
239226
|
240227
LL | #![type_length_limit = "1048576"]
241228
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
242229
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
243230

244231
error: unused attribute
245-
--> $DIR/unused-attr-duplicate.rs:26:1
232+
--> $DIR/unused-attr-duplicate.rs:23:1
246233
|
247234
LL | #![no_std]
248235
| ^^^^^^^^^^ help: remove this attribute
249236
|
250237
note: attribute also specified here
251-
--> $DIR/unused-attr-duplicate.rs:25:1
238+
--> $DIR/unused-attr-duplicate.rs:22:1
252239
|
253240
LL | #![no_std]
254241
| ^^^^^^^^^^
255242

256243
error: unused attribute
257-
--> $DIR/unused-attr-duplicate.rs:28:1
244+
--> $DIR/unused-attr-duplicate.rs:25:1
258245
|
259246
LL | #![no_implicit_prelude]
260247
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
261248
|
262249
note: attribute also specified here
263-
--> $DIR/unused-attr-duplicate.rs:27:1
250+
--> $DIR/unused-attr-duplicate.rs:24:1
264251
|
265252
LL | #![no_implicit_prelude]
266253
| ^^^^^^^^^^^^^^^^^^^^^^^
267254

268255
error: unused attribute
269-
--> $DIR/unused-attr-duplicate.rs:30:1
256+
--> $DIR/unused-attr-duplicate.rs:27:1
270257
|
271258
LL | #![windows_subsystem = "windows"]
272259
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
273260
|
274261
note: attribute also specified here
275-
--> $DIR/unused-attr-duplicate.rs:29:1
262+
--> $DIR/unused-attr-duplicate.rs:26:1
276263
|
277264
LL | #![windows_subsystem = "console"]
278265
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
279266
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
280267

281268
error: unused attribute
282-
--> $DIR/unused-attr-duplicate.rs:33:1
269+
--> $DIR/unused-attr-duplicate.rs:30:1
283270
|
284271
LL | #![no_builtins]
285272
| ^^^^^^^^^^^^^^^ help: remove this attribute
286273
|
287274
note: attribute also specified here
288-
--> $DIR/unused-attr-duplicate.rs:32:1
275+
--> $DIR/unused-attr-duplicate.rs:29:1
289276
|
290277
LL | #![no_builtins]
291278
| ^^^^^^^^^^^^^^^
292279

293280
error: unused attribute
294-
--> $DIR/unused-attr-duplicate.rs:43:5
281+
--> $DIR/unused-attr-duplicate.rs:40:5
295282
|
296283
LL | #[macro_export]
297284
| ^^^^^^^^^^^^^^^ help: remove this attribute
298285
|
299286
note: attribute also specified here
300-
--> $DIR/unused-attr-duplicate.rs:42:5
287+
--> $DIR/unused-attr-duplicate.rs:39:5
301288
|
302289
LL | #[macro_export]
303290
| ^^^^^^^^^^^^^^^
304291

305-
error: aborting due to 24 previous errors
292+
error: aborting due to 23 previous errors
306293

0 commit comments

Comments
 (0)