14 files changed +45
-20
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ //! Check that we permit a crate-level inner attribute but reject a dangling outer attribute which
2
+ //! does not have a following thing that it can target.
3
+ //!
4
+ //! See <https://doc.rust-lang.org/reference/attributes.html>.
5
+
6
+ //@ error-pattern: expected item
7
+
8
+ #![ attr = "val" ]
9
+ #[ attr = "val" ] // Unterminated
Original file line number Diff line number Diff line change 1
1
error: expected item after attributes
2
- --> $DIR/attr-bad-crate-attr.rs:4 :1
2
+ --> $DIR/attr-bad-crate-attr.rs:9 :1
3
3
|
4
4
LL | #[attr = "val"] // Unterminated
5
5
| ^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change
1
+ //! Check that we accept crate-level inner attributes with the `#![..]` shebang syntax.
2
+
3
+ //@ check-pass
4
+
5
+ #![ allow( stable_features) ]
6
+ #![ feature( rust1) ]
7
+ pub fn main ( ) { }
Original file line number Diff line number Diff line change 1
- #![ allow( dead_code) ]
1
+ //! Check that `#[inline]` attribute can only be applied to fn-like targets (e.g. function or
2
+ //! closure), and when misapplied to other targets an error is emitted.
2
3
3
4
#[ inline]
4
5
fn f ( ) { }
Original file line number Diff line number Diff line change 1
1
error[E0518]: attribute should be applied to function or closure
2
- --> $DIR/attr-usage-inline.rs:6 :1
2
+ --> $DIR/attr-usage-inline.rs:7 :1
3
3
|
4
4
LL | #[inline]
5
5
| ^^^^^^^^^
6
6
LL | struct S;
7
7
| --------- not a function or closure
8
8
9
9
error[E0518]: attribute should be applied to function or closure
10
- --> $DIR/attr-usage-inline.rs:20 :1
10
+ --> $DIR/attr-usage-inline.rs:21 :1
11
11
|
12
12
LL | #[inline]
13
13
| ^^^^^^^^^ not a function or closure
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ //! Check that certain positions (listed below) only permit *non-macro* attributes and reject
2
+ //! attribute macros:
3
+ //!
4
+ //! - Enum variants
5
+ //! - Struct fields
6
+ //! - Field in a struct pattern
7
+ //! - Match arm
8
+ //! - Field in struct initialization expression
9
+
1
10
enum FooEnum {
2
11
#[ test]
3
12
//~^ ERROR expected non-macro attribute, found attribute macro
@@ -32,7 +41,7 @@ fn main() {
32
41
_ => { }
33
42
}
34
43
35
- let _another_foo_strunct = FooStruct {
44
+ let _another_foo_struct = FooStruct {
36
45
#[ test]
37
46
//~^ ERROR expected non-macro attribute, found attribute macro
38
47
bar : 1 ,
Original file line number Diff line number Diff line change 1
1
error: expected non-macro attribute, found attribute macro `test`
2
- --> $DIR/attrs-resolution-errors .rs:2 :7
2
+ --> $DIR/attr-macros-positional-rejection .rs:11 :7
3
3
|
4
4
LL | #[test]
5
5
| ^^^^ not a non-macro attribute
6
6
7
7
error: expected non-macro attribute, found attribute macro `test`
8
- --> $DIR/attrs-resolution-errors .rs:8 :7
8
+ --> $DIR/attr-macros-positional-rejection .rs:17 :7
9
9
|
10
10
LL | #[test]
11
11
| ^^^^ not a non-macro attribute
12
12
13
13
error: expected non-macro attribute, found attribute macro `test`
14
- --> $DIR/attrs-resolution-errors .rs:23 :15
14
+ --> $DIR/attr-macros-positional-rejection .rs:32 :15
15
15
|
16
16
LL | #[test] bar
17
17
| ^^^^ not a non-macro attribute
18
18
19
19
error: expected non-macro attribute, found attribute macro `test`
20
- --> $DIR/attrs-resolution-errors .rs:30 :11
20
+ --> $DIR/attr-macros-positional-rejection .rs:39 :11
21
21
|
22
22
LL | #[test]
23
23
| ^^^^ not a non-macro attribute
24
24
25
25
error: expected non-macro attribute, found attribute macro `test`
26
- --> $DIR/attrs-resolution-errors .rs:36 :11
26
+ --> $DIR/attr-macros-positional-rejection .rs:45 :11
27
27
|
28
28
LL | #[test]
29
29
| ^^^^ not a non-macro attribute
Original file line number Diff line number Diff line change
1
+ //! Check that certain positions (listed below) permit *non-macro* attributes.
2
+ //!
3
+ //! - Enum variants
4
+ //! - Struct fields
5
+ //! - Field in a struct pattern
6
+ //! - Match arm
7
+ //! - Field in struct initialization expression
8
+
1
9
//@ check-pass
2
10
3
11
enum FooEnum {
@@ -30,7 +38,7 @@ fn main() {
30
38
_ => { }
31
39
}
32
40
33
- let _another_foo_strunct = FooStruct {
41
+ let _another_foo_struct = FooStruct {
34
42
#[ rustfmt:: skip]
35
43
bar : 1 ,
36
44
} ;
File renamed without changes.
File renamed without changes.
0 commit comments