Skip to content

Commit 0974c9d

Browse files
wip
1 parent cead675 commit 0974c9d

File tree

58 files changed

+638
-465
lines changed

Some content is hidden

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

58 files changed

+638
-465
lines changed

compiler/rustc_attr_parsing/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ attr_parsing_empty_attribute =
1212
1313
attr_parsing_invalid_target = `#[{$name}]` attribute cannot be used on {$article} {$target}
1414
15+
attr_parsing_invalid_target_warn = `#[{$name}]` attribute cannot be used on {$article} {$target}
16+
.warn = {-attr_parsing_previously_accepted}
17+
1518
attr_parsing_empty_confusables =
1619
expected at least one confusable name
1720
attr_parsing_expected_one_cfg_pattern =

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
906906
AllowedResult::Warn => {
907907
emit_lint(AttributeLint {
908908
id: target_id,
909-
span: n.item.span(),
909+
span: attr.span,
910910
kind: AttributeLintKind::InvalidTarget {
911911
name: parts[0],
912912
article: target.article(),
@@ -916,7 +916,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
916916
}
917917
AllowedResult::Error => {
918918
self.dcx().emit_err(InvalidTarget {
919-
span: n.item.span(),
919+
span: attr.span,
920920
name: parts[0],
921921
article: target.article(),
922922
target: target.name(),

compiler/rustc_attr_parsing/src/session_diagnostics.rs

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

483483
#[derive(LintDiagnostic)]
484-
#[diag(attr_parsing_invalid_target)]
484+
#[diag(attr_parsing_invalid_target_warn)]
485+
#[warning]
485486
pub(crate) struct InvalidTargetLint {
486487
pub name: Symbol,
487488
pub article: &'static str,

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@ LL | #[::a]
55
| ^ use of unresolved module or unlinked crate `a`
66

77
error: `#[naked]` attribute cannot be used on a crate
8-
--> $DIR/naked-invalid-attr.rs:4:11
8+
--> $DIR/naked-invalid-attr.rs:4:1
99
|
1010
LL | #![unsafe(naked)]
11-
| ^^^^^
11+
| ^^^^^^^^^^^^^^^^^
1212

1313
error: `#[naked]` attribute cannot be used on a foreign function
14-
--> $DIR/naked-invalid-attr.rs:9:14
14+
--> $DIR/naked-invalid-attr.rs:9:5
1515
|
1616
LL | #[unsafe(naked)]
17-
| ^^^^^
17+
| ^^^^^^^^^^^^^^^^
1818

1919
error: `#[naked]` attribute cannot be used on a struct
20-
--> $DIR/naked-invalid-attr.rs:13:10
20+
--> $DIR/naked-invalid-attr.rs:13:1
2121
|
2222
LL | #[unsafe(naked)]
23-
| ^^^^^
23+
| ^^^^^^^^^^^^^^^^
2424

2525
error: `#[naked]` attribute cannot be used on a struct field
26-
--> $DIR/naked-invalid-attr.rs:16:14
26+
--> $DIR/naked-invalid-attr.rs:16:5
2727
|
2828
LL | #[unsafe(naked)]
29-
| ^^^^^
29+
| ^^^^^^^^^^^^^^^^
3030

3131
error: `#[naked]` attribute cannot be used on a required trait method
32-
--> $DIR/naked-invalid-attr.rs:22:14
32+
--> $DIR/naked-invalid-attr.rs:22:5
3333
|
3434
LL | #[unsafe(naked)]
35-
| ^^^^^
35+
| ^^^^^^^^^^^^^^^^
3636

3737
error: `#[naked]` attribute cannot be used on a closure
38-
--> $DIR/naked-invalid-attr.rs:51:14
38+
--> $DIR/naked-invalid-attr.rs:51:5
3939
|
4040
LL | #[unsafe(naked)]
41-
| ^^^^^
41+
| ^^^^^^^^^^^^^^^^
4242

4343
error[E0736]: attribute incompatible with `#[unsafe(naked)]`
4444
--> $DIR/naked-invalid-attr.rs:56:3

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | fn function(#[inline] param: u32) {
55
| ^^^^^^^^^
66

77
error: `#[inline]` attribute cannot be used on a function param
8-
--> $DIR/attrs-on-params.rs:3:15
8+
--> $DIR/attrs-on-params.rs:3:13
99
|
1010
LL | fn function(#[inline] param: u32) {
11-
| ^^^^^^
11+
| ^^^^^^^^^
1212

1313
error: aborting due to 2 previous errors
1414

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
#[cold]
55
//~^ ERROR attribute cannot be used on
6+
//~| WARN previously accepted
67
struct Foo;
78

89
fn main() {
910
#[cold]
1011
//~^ ERROR attribute cannot be used on
12+
//~| WARN previously accepted
1113
5;
1214
}
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
error: `#[cold]` attribute cannot be used on a struct
2-
--> $DIR/cold-attribute-application-54044.rs:4:3
2+
--> $DIR/cold-attribute-application-54044.rs:4:1
33
|
44
LL | #[cold]
5-
| ^^^^
5+
| ^^^^^^^
66
|
7+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
78
note: the lint level is defined here
89
--> $DIR/cold-attribute-application-54044.rs:2:9
910
|
1011
LL | #![deny(unused_attributes)]
1112
| ^^^^^^^^^^^^^^^^^
1213

1314
error: `#[cold]` attribute cannot be used on an expression
14-
--> $DIR/cold-attribute-application-54044.rs:9:7
15+
--> $DIR/cold-attribute-application-54044.rs:10:5
1516
|
1617
LL | #[cold]
17-
| ^^^^
18+
| ^^^^^^^
19+
|
20+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1821

1922
error: aborting due to 2 previous errors
2023

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: `#[inline]` attribute cannot be used on a enum variant
2-
--> $DIR/inline-attribute-enum-variant-error.rs:4:7
2+
--> $DIR/inline-attribute-enum-variant-error.rs:4:5
33
|
44
LL | #[inline]
5-
| ^^^^^^
5+
| ^^^^^^^^^
66

77
error: aborting due to 1 previous error
88

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: `#[inline]` attribute cannot be used on a struct
2-
--> $DIR/attr-usage-inline.rs:7:3
2+
--> $DIR/attr-usage-inline.rs:7:1
33
|
44
LL | #[inline]
5-
| ^^^^^^
5+
| ^^^^^^^^^
66

77
error[E0518]: attribute should be applied to function or closure
88
--> $DIR/attr-usage-inline.rs:21:1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: `#[track_caller]` attribute cannot be used on a static item
2-
--> $DIR/issue-105594-invalid-attr-validation.rs:6:3
2+
--> $DIR/issue-105594-invalid-attr-validation.rs:6:1
33
|
44
LL | #[track_caller]
5-
| ^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^
66

77
error: aborting due to 1 previous error
88

0 commit comments

Comments
 (0)