Skip to content

Commit 43d9b17

Browse files
wip
1 parent 0974c9d commit 43d9b17

File tree

51 files changed

+1241
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1241
-23
lines changed

compiler/rustc_attr_parsing/messages.ftl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ attr_parsing_empty_attribute =
1111
.suggestion = remove this attribute
1212
1313
attr_parsing_invalid_target = `#[{$name}]` attribute cannot be used on {$article} {$target}
14-
15-
attr_parsing_invalid_target_warn = `#[{$name}]` attribute cannot be used on {$article} {$target}
14+
.help = `#[{$name}]` can be applied to...
15+
attr_parsing_invalid_target_lint = `#[{$name}]` attribute cannot be used on {$article} {$target}
1616
.warn = {-attr_parsing_previously_accepted}
17+
.help = `#[{$name}]` can be applied to...
1718
1819
attr_parsing_empty_confusables =
1920
expected at least one confusable name

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl<S: Stage> SingleAttributeParser<S> for DeprecationParser {
5050
Allow(Target::MacroDef),
5151
Allow(Target::Method(MethodKind::Inherent)),
5252
Allow(Target::Method(MethodKind::Trait { body: false })),
53+
Allow(Target::Method(MethodKind::Trait { body: true })),
5354
Allow(Target::TyAlias),
5455
Allow(Target::Use),
5556
Allow(Target::ForeignFn),

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,9 @@ pub(crate) struct EmptyAttributeList {
481481
}
482482

483483
#[derive(LintDiagnostic)]
484-
#[diag(attr_parsing_invalid_target_warn)]
484+
#[diag(attr_parsing_invalid_target_lint)]
485485
#[warning]
486+
#[help]
486487
pub(crate) struct InvalidTargetLint {
487488
pub name: Symbol,
488489
pub article: &'static str,
@@ -493,6 +494,7 @@ pub(crate) struct InvalidTargetLint {
493494
#[diag(attr_parsing_invalid_target)]
494495
pub(crate) struct InvalidTarget {
495496
#[primary_span]
497+
#[help]
496498
pub span: Span,
497499
pub name: Symbol,
498500
pub article: &'static str,

tests/ui/asm/naked-invalid-attr.stderr

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,72 @@ LL | #[::a]
77
error: `#[naked]` attribute cannot be used on a crate
88
--> $DIR/naked-invalid-attr.rs:4:1
99
|
10+
LL | #![unsafe(naked)]
11+
| ^^^^^^^^^^^^^^^^^
12+
|
13+
help: `#[naked]` can be applied to...
14+
--> $DIR/naked-invalid-attr.rs:4:1
15+
|
1016
LL | #![unsafe(naked)]
1117
| ^^^^^^^^^^^^^^^^^
1218

1319
error: `#[naked]` attribute cannot be used on a foreign function
1420
--> $DIR/naked-invalid-attr.rs:9:5
1521
|
22+
LL | #[unsafe(naked)]
23+
| ^^^^^^^^^^^^^^^^
24+
|
25+
help: `#[naked]` can be applied to...
26+
--> $DIR/naked-invalid-attr.rs:9:5
27+
|
1628
LL | #[unsafe(naked)]
1729
| ^^^^^^^^^^^^^^^^
1830

1931
error: `#[naked]` attribute cannot be used on a struct
2032
--> $DIR/naked-invalid-attr.rs:13:1
2133
|
34+
LL | #[unsafe(naked)]
35+
| ^^^^^^^^^^^^^^^^
36+
|
37+
help: `#[naked]` can be applied to...
38+
--> $DIR/naked-invalid-attr.rs:13:1
39+
|
2240
LL | #[unsafe(naked)]
2341
| ^^^^^^^^^^^^^^^^
2442

2543
error: `#[naked]` attribute cannot be used on a struct field
2644
--> $DIR/naked-invalid-attr.rs:16:5
2745
|
46+
LL | #[unsafe(naked)]
47+
| ^^^^^^^^^^^^^^^^
48+
|
49+
help: `#[naked]` can be applied to...
50+
--> $DIR/naked-invalid-attr.rs:16:5
51+
|
2852
LL | #[unsafe(naked)]
2953
| ^^^^^^^^^^^^^^^^
3054

3155
error: `#[naked]` attribute cannot be used on a required trait method
3256
--> $DIR/naked-invalid-attr.rs:22:5
3357
|
58+
LL | #[unsafe(naked)]
59+
| ^^^^^^^^^^^^^^^^
60+
|
61+
help: `#[naked]` can be applied to...
62+
--> $DIR/naked-invalid-attr.rs:22:5
63+
|
3464
LL | #[unsafe(naked)]
3565
| ^^^^^^^^^^^^^^^^
3666

3767
error: `#[naked]` attribute cannot be used on a closure
3868
--> $DIR/naked-invalid-attr.rs:51:5
3969
|
70+
LL | #[unsafe(naked)]
71+
| ^^^^^^^^^^^^^^^^
72+
|
73+
help: `#[naked]` can be applied to...
74+
--> $DIR/naked-invalid-attr.rs:51:5
75+
|
4076
LL | #[unsafe(naked)]
4177
| ^^^^^^^^^^^^^^^^
4278

tests/ui/attributes/attrs-on-params.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ LL | fn function(#[inline] param: u32) {
77
error: `#[inline]` attribute cannot be used on a function param
88
--> $DIR/attrs-on-params.rs:3:13
99
|
10+
LL | fn function(#[inline] param: u32) {
11+
| ^^^^^^^^^
12+
|
13+
help: `#[inline]` can be applied to...
14+
--> $DIR/attrs-on-params.rs:3:13
15+
|
1016
LL | fn function(#[inline] param: u32) {
1117
| ^^^^^^^^^
1218

tests/ui/attributes/cold-attribute-application-54044.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | #[cold]
55
| ^^^^^^^
66
|
77
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= help: `#[cold]` can be applied to...
89
note: the lint level is defined here
910
--> $DIR/cold-attribute-application-54044.rs:2:9
1011
|
@@ -18,6 +19,7 @@ LL | #[cold]
1819
| ^^^^^^^
1920
|
2021
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
22+
= help: `#[cold]` can be applied to...
2123

2224
error: aborting due to 2 previous errors
2325

tests/ui/attributes/inline-attribute-enum-variant-error.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
error: `#[inline]` attribute cannot be used on a enum variant
22
--> $DIR/inline-attribute-enum-variant-error.rs:4:5
33
|
4+
LL | #[inline]
5+
| ^^^^^^^^^
6+
|
7+
help: `#[inline]` can be applied to...
8+
--> $DIR/inline-attribute-enum-variant-error.rs:4:5
9+
|
410
LL | #[inline]
511
| ^^^^^^^^^
612

tests/ui/attributes/inline/attr-usage-inline.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
error: `#[inline]` attribute cannot be used on a struct
22
--> $DIR/attr-usage-inline.rs:7:1
33
|
4+
LL | #[inline]
5+
| ^^^^^^^^^
6+
|
7+
help: `#[inline]` can be applied to...
8+
--> $DIR/attr-usage-inline.rs:7:1
9+
|
410
LL | #[inline]
511
| ^^^^^^^^^
612

tests/ui/attributes/issue-105594-invalid-attr-validation.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
error: `#[track_caller]` attribute cannot be used on a static item
22
--> $DIR/issue-105594-invalid-attr-validation.rs:6:1
33
|
4+
LL | #[track_caller]
5+
| ^^^^^^^^^^^^^^^
6+
|
7+
help: `#[track_caller]` can be applied to...
8+
--> $DIR/issue-105594-invalid-attr-validation.rs:6:1
9+
|
410
LL | #[track_caller]
511
| ^^^^^^^^^^^^^^^
612

tests/ui/attributes/lint_on_root.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
error: `#[inline]` attribute cannot be used on a crate
22
--> $DIR/lint_on_root.rs:3:1
33
|
4+
LL | #![inline = ""]
5+
| ^^^^^^^^^^^^^^^
6+
|
7+
help: `#[inline]` can be applied to...
8+
--> $DIR/lint_on_root.rs:3:1
9+
|
410
LL | #![inline = ""]
511
| ^^^^^^^^^^^^^^^
612

0 commit comments

Comments
 (0)