Skip to content

Commit a1c6f2a

Browse files
wip2
1 parent 4bdb861 commit a1c6f2a

File tree

104 files changed

+3443
-2392
lines changed

Some content is hidden

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

104 files changed

+3443
-2392
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
// Checks that the #[unsafe(naked)] attribute can be placed on function definitions only.
22
//
33
//@ needs-asm-support
4-
#![unsafe(naked)] //~ ERROR should be applied to a function definition
4+
#![unsafe(naked)] //~ ERROR attribute cannot be used on
55

66
use std::arch::naked_asm;
77

88
extern "C" {
9-
#[unsafe(naked)] //~ ERROR should be applied to a function definition
9+
#[unsafe(naked)] //~ ERROR attribute cannot be used on
1010
fn f();
1111
}
1212

13-
#[unsafe(naked)] //~ ERROR should be applied to a function definition
13+
#[unsafe(naked)] //~ ERROR attribute cannot be used on
1414
#[repr(C)]
1515
struct S {
16-
#[unsafe(naked)] //~ ERROR should be applied to a function definition
16+
#[unsafe(naked)] //~ ERROR attribute cannot be used on
1717
a: u32,
1818
b: u32,
1919
}
2020

2121
trait Invoke {
22-
#[unsafe(naked)] //~ ERROR should be applied to a function definition
22+
#[unsafe(naked)] //~ ERROR attribute cannot be used on
2323
extern "C" fn invoke(&self);
2424
}
2525

@@ -48,7 +48,7 @@ impl S {
4848
}
4949

5050
fn main() {
51-
#[unsafe(naked)] //~ ERROR should be applied to a function definition
51+
#[unsafe(naked)] //~ ERROR attribute cannot be used on
5252
|| {};
5353
}
5454

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

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,86 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `a`
44
LL | #[::a]
55
| ^ use of unresolved module or unlinked crate `a`
66

7-
error[E0736]: attribute incompatible with `#[unsafe(naked)]`
8-
--> $DIR/naked-invalid-attr.rs:56:3
7+
error: `#[naked]` attribute cannot be used on crates
8+
--> $DIR/naked-invalid-attr.rs:4:1
99
|
10-
LL | #[::a]
11-
| ^^^ the `::a` attribute is incompatible with `#[unsafe(naked)]`
12-
...
13-
LL | #[unsafe(naked)]
14-
| ---------------- function marked with `#[unsafe(naked)]` here
10+
LL | #![unsafe(naked)]
11+
| ^^^^^^^^^^^^^^^^^
12+
|
13+
help: `#[naked]` can be applied to functions
14+
--> $DIR/naked-invalid-attr.rs:4:1
15+
|
16+
LL | #![unsafe(naked)]
17+
| ^^^^^^^^^^^^^^^^^
1518

16-
error: attribute should be applied to a function definition
19+
error: `#[naked]` attribute cannot be used on foreign functions
20+
--> $DIR/naked-invalid-attr.rs:9:5
21+
|
22+
LL | #[unsafe(naked)]
23+
| ^^^^^^^^^^^^^^^^
24+
|
25+
help: `#[naked]` can be applied to methods, functions
26+
--> $DIR/naked-invalid-attr.rs:9:5
27+
|
28+
LL | #[unsafe(naked)]
29+
| ^^^^^^^^^^^^^^^^
30+
31+
error: `#[naked]` attribute cannot be used on structs
32+
--> $DIR/naked-invalid-attr.rs:13:1
33+
|
34+
LL | #[unsafe(naked)]
35+
| ^^^^^^^^^^^^^^^^
36+
|
37+
help: `#[naked]` can be applied to functions
1738
--> $DIR/naked-invalid-attr.rs:13:1
1839
|
19-
LL | #[unsafe(naked)]
20-
| ^^^^^^^^^^^^^^^^
21-
LL | #[repr(C)]
22-
LL | / struct S {
23-
LL | | #[unsafe(naked)]
24-
LL | | a: u32,
25-
LL | | b: u32,
26-
LL | | }
27-
| |_- not a function definition
40+
LL | #[unsafe(naked)]
41+
| ^^^^^^^^^^^^^^^^
2842

29-
error: attribute should be applied to a function definition
43+
error: `#[naked]` attribute cannot be used on struct fields
3044
--> $DIR/naked-invalid-attr.rs:16:5
3145
|
3246
LL | #[unsafe(naked)]
3347
| ^^^^^^^^^^^^^^^^
34-
LL | a: u32,
35-
| ------ not a function definition
36-
37-
error: attribute should be applied to a function definition
38-
--> $DIR/naked-invalid-attr.rs:51:5
48+
|
49+
help: `#[naked]` can be applied to functions
50+
--> $DIR/naked-invalid-attr.rs:16:5
3951
|
4052
LL | #[unsafe(naked)]
4153
| ^^^^^^^^^^^^^^^^
42-
LL | || {};
43-
| ----- not a function definition
4454

45-
error: attribute should be applied to a function definition
55+
error: `#[naked]` attribute cannot be used on required trait methods
56+
--> $DIR/naked-invalid-attr.rs:22:5
57+
|
58+
LL | #[unsafe(naked)]
59+
| ^^^^^^^^^^^^^^^^
60+
|
61+
help: `#[naked]` can be applied to functions, inherent methods, provided trait methods, trait methods in impl blocks
4662
--> $DIR/naked-invalid-attr.rs:22:5
4763
|
4864
LL | #[unsafe(naked)]
4965
| ^^^^^^^^^^^^^^^^
50-
LL | extern "C" fn invoke(&self);
51-
| ---------------------------- not a function definition
5266

53-
error: attribute should be applied to a function definition
54-
--> $DIR/naked-invalid-attr.rs:9:5
67+
error: `#[naked]` attribute cannot be used on closures
68+
--> $DIR/naked-invalid-attr.rs:51:5
69+
|
70+
LL | #[unsafe(naked)]
71+
| ^^^^^^^^^^^^^^^^
72+
|
73+
help: `#[naked]` can be applied to methods, functions
74+
--> $DIR/naked-invalid-attr.rs:51:5
5575
|
5676
LL | #[unsafe(naked)]
5777
| ^^^^^^^^^^^^^^^^
58-
LL | fn f();
59-
| ------- not a function definition
6078

61-
error: attribute should be applied to a function definition
62-
--> $DIR/naked-invalid-attr.rs:4:1
79+
error[E0736]: attribute incompatible with `#[unsafe(naked)]`
80+
--> $DIR/naked-invalid-attr.rs:56:3
6381
|
64-
LL | #![unsafe(naked)]
65-
| ^^^^^^^^^^^^^^^^^ cannot be applied to crates
82+
LL | #[::a]
83+
| ^^^ the `::a` attribute is incompatible with `#[unsafe(naked)]`
84+
...
85+
LL | #[unsafe(naked)]
86+
| ---------------- function marked with `#[unsafe(naked)]` here
6687

6788
error: aborting due to 8 previous errors
6889

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This checks that incorrect params on function parameters are caught
22

33
fn function(#[inline] param: u32) {
4-
//~^ ERROR attribute should be applied to function or closure
4+
//~^ ERROR attribute cannot be used on
55
//~| ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes
66
}
77

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed
44
LL | fn function(#[inline] param: u32) {
55
| ^^^^^^^^^
66

7-
error[E0518]: attribute should be applied to function or closure
7+
error: `#[inline]` attribute cannot be used on function params
88
--> $DIR/attrs-on-params.rs:3:13
99
|
1010
LL | fn function(#[inline] param: u32) {
11-
| ^^^^^^^^^-----------
12-
| |
13-
| not a function or closure
11+
| ^^^^^^^^^
12+
|
13+
help: `#[inline]` can be applied to functions
14+
--> $DIR/attrs-on-params.rs:3:13
15+
|
16+
LL | fn function(#[inline] param: u32) {
17+
| ^^^^^^^^^
1418

1519
error: aborting due to 2 previous errors
1620

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

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
#![deny(unused_attributes)] //~ NOTE lint level is defined here
33

44
#[cold]
5-
//~^ ERROR attribute should be applied to a function
6-
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
7-
struct Foo; //~ NOTE not a function
5+
//~^ ERROR attribute cannot be used on
6+
//~| WARN previously accepted
7+
struct Foo;
88

99
fn main() {
1010
#[cold]
11-
//~^ ERROR attribute should be applied to a function
12-
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
13-
5; //~ NOTE not a function
11+
//~^ ERROR attribute cannot be used on
12+
//~| WARN previously accepted
13+
5;
1414
}
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
1-
error: attribute should be applied to a function definition
1+
error: `#[cold]` attribute cannot be used on structs
22
--> $DIR/cold-attribute-application-54044.rs:4:1
33
|
44
LL | #[cold]
55
| ^^^^^^^
6-
...
7-
LL | struct Foo;
8-
| ----------- not a function definition
96
|
107
= 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...
119
note: the lint level is defined here
1210
--> $DIR/cold-attribute-application-54044.rs:2:9
1311
|
1412
LL | #![deny(unused_attributes)]
1513
| ^^^^^^^^^^^^^^^^^
1614

17-
error: attribute should be applied to a function definition
15+
error: `#[cold]` attribute cannot be used on expressions
1816
--> $DIR/cold-attribute-application-54044.rs:10:5
1917
|
2018
LL | #[cold]
2119
| ^^^^^^^
22-
...
23-
LL | 5;
24-
| - not a function definition
2520
|
2621
= 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...
2723

2824
error: aborting due to 2 previous errors
2925

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
enum Foo {
44
#[inline]
5-
//~^ ERROR attribute should be applied
5+
//~^ ERROR attribute cannot be used on
66
Variant,
77
}
88

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
error[E0518]: attribute should be applied to function or closure
1+
error: `#[inline]` attribute cannot be used on enum variants
2+
--> $DIR/inline-attribute-enum-variant-error.rs:4:5
3+
|
4+
LL | #[inline]
5+
| ^^^^^^^^^
6+
|
7+
help: `#[inline]` can be applied to functions
28
--> $DIR/inline-attribute-enum-variant-error.rs:4:5
39
|
410
LL | #[inline]
511
| ^^^^^^^^^
6-
LL |
7-
LL | Variant,
8-
| ------- not a function or closure
912

1013
error: aborting due to 1 previous error
1114

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#[inline]
55
fn f() {}
66

7-
#[inline] //~ ERROR: attribute should be applied to function or closure
7+
#[inline] //~ ERROR: attribute cannot be used on
88
struct S;
99

1010
struct I {

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
error[E0518]: attribute should be applied to function or closure
1+
error: `#[inline]` attribute cannot be used on structs
2+
--> $DIR/attr-usage-inline.rs:7:1
3+
|
4+
LL | #[inline]
5+
| ^^^^^^^^^
6+
|
7+
help: `#[inline]` can be applied to functions
28
--> $DIR/attr-usage-inline.rs:7:1
39
|
410
LL | #[inline]
511
| ^^^^^^^^^
6-
LL | struct S;
7-
| --------- not a function or closure
812

913
error[E0518]: attribute should be applied to function or closure
1014
--> $DIR/attr-usage-inline.rs:21:1

0 commit comments

Comments
 (0)