Skip to content

Commit d050b00

Browse files
authored
Rollup merge of #69412 - tmiasko:checked-unused, r=petrochenkov
Mark attributes consumed by `check_mod_attrs` as normal Take advantage of the fact that `check_mod_attrs` marks attributes as used and change their type to normal, so that any remaining uses will be warned about by the unused attribute lint.
2 parents 41bf200 + d78b22f commit d050b00

File tree

3 files changed

+63
-6
lines changed

3 files changed

+63
-6
lines changed

src/librustc_feature/builtin_attrs.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
234234
ungated!(export_name, Whitelisted, template!(NameValueStr: "name")),
235235
ungated!(link_section, Whitelisted, template!(NameValueStr: "name")),
236236
ungated!(no_mangle, Whitelisted, template!(Word)),
237-
ungated!(used, Whitelisted, template!(Word)),
237+
ungated!(used, Normal, template!(Word)),
238238

239239
// Limits:
240240
ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N")),
@@ -250,17 +250,17 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
250250
ungated!(path, Normal, template!(NameValueStr: "file")),
251251
ungated!(no_std, CrateLevel, template!(Word)),
252252
ungated!(no_implicit_prelude, Normal, template!(Word)),
253-
ungated!(non_exhaustive, Whitelisted, template!(Word)),
253+
ungated!(non_exhaustive, Normal, template!(Word)),
254254

255255
// Runtime
256256
ungated!(windows_subsystem, Whitelisted, template!(NameValueStr: "windows|console")),
257257
ungated!(panic_handler, Normal, template!(Word)), // RFC 2070
258258

259259
// Code generation:
260-
ungated!(inline, Whitelisted, template!(Word, List: "always|never")),
260+
ungated!(inline, Normal, template!(Word, List: "always|never")),
261261
ungated!(cold, Whitelisted, template!(Word)),
262262
ungated!(no_builtins, Whitelisted, template!(Word)),
263-
ungated!(target_feature, Whitelisted, template!(List: r#"enable = "name""#)),
263+
ungated!(target_feature, Normal, template!(List: r#"enable = "name""#)),
264264
gated!(
265265
no_sanitize, Whitelisted,
266266
template!(List: "address, memory, thread"),
@@ -275,7 +275,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
275275
// ==========================================================================
276276

277277
// Linking:
278-
gated!(naked, Whitelisted, template!(Word), naked_functions, experimental!(naked)),
278+
gated!(naked, Normal, template!(Word), naked_functions, experimental!(naked)),
279279
gated!(
280280
link_args, Normal, template!(NameValueStr: "args"),
281281
"the `link_args` attribute is experimental and not portable across platforms, \
@@ -332,7 +332,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
332332
),
333333

334334
gated!(ffi_returns_twice, Whitelisted, template!(Word), experimental!(ffi_returns_twice)),
335-
gated!(track_caller, Whitelisted, template!(Word), experimental!(track_caller)),
335+
gated!(track_caller, Normal, template!(Word), experimental!(track_caller)),
336336
gated!(
337337
register_attr, CrateLevel, template!(List: "attr1, attr2, ..."),
338338
experimental!(register_attr),
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![deny(unused_attributes)]
2+
3+
#![feature(naked_functions)]
4+
#![feature(track_caller)]
5+
6+
#![used] //~ ERROR unused attribute
7+
#![non_exhaustive] //~ ERROR unused attribute
8+
#![inline] //~ ERROR unused attribute
9+
#![target_feature(enable = "")] //~ ERROR unused attribute
10+
#![naked] //~ ERROR unused attribute
11+
#![track_caller] //~ ERROR unused attribute
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
error: unused attribute
2+
--> $DIR/unused-attr-crate.rs:6:1
3+
|
4+
LL | #![used]
5+
| ^^^^^^^^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/unused-attr-crate.rs:1:9
9+
|
10+
LL | #![deny(unused_attributes)]
11+
| ^^^^^^^^^^^^^^^^^
12+
13+
error: unused attribute
14+
--> $DIR/unused-attr-crate.rs:7:1
15+
|
16+
LL | #![non_exhaustive]
17+
| ^^^^^^^^^^^^^^^^^^
18+
19+
error: unused attribute
20+
--> $DIR/unused-attr-crate.rs:8:1
21+
|
22+
LL | #![inline]
23+
| ^^^^^^^^^^
24+
25+
error: unused attribute
26+
--> $DIR/unused-attr-crate.rs:9:1
27+
|
28+
LL | #![target_feature(enable = "")]
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
31+
error: unused attribute
32+
--> $DIR/unused-attr-crate.rs:10:1
33+
|
34+
LL | #![naked]
35+
| ^^^^^^^^^
36+
37+
error: unused attribute
38+
--> $DIR/unused-attr-crate.rs:11:1
39+
|
40+
LL | #![track_caller]
41+
| ^^^^^^^^^^^^^^^^
42+
43+
error: aborting due to 6 previous errors
44+

0 commit comments

Comments
 (0)