Skip to content

Commit 0eb2260

Browse files
committed
Add a test for invalid syntax in attribute
1 parent 35dcd82 commit 0eb2260

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use enumflags2::bitflags;
2+
3+
#[bitflags(default = A + B)]
4+
enum Test {
5+
A = 1,
6+
B = 2,
7+
}
8+
9+
#[bitflags(default = A |)]
10+
enum Test {
11+
A = 1,
12+
B = 2,
13+
}
14+
15+
#[bitflags(default =)]
16+
enum Test {
17+
A = 1,
18+
B = 2,
19+
}
20+
21+
#[bitflags(default)]
22+
enum Test {
23+
A = 1,
24+
B = 2,
25+
}
26+
27+
#[bitflags(yes)]
28+
enum Test {
29+
A = 1,
30+
B = 2,
31+
}
32+
33+
fn main() {}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
error: expected `|`
2+
--> $DIR/invalid_attribute_syntax.rs:3:24
3+
|
4+
3 | #[bitflags(default = A + B)]
5+
| ^
6+
7+
error: unexpected end of input, expected identifier
8+
--> $DIR/invalid_attribute_syntax.rs:9:1
9+
|
10+
9 | #[bitflags(default = A |)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
|
13+
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
14+
15+
error: unexpected end of input, expected identifier
16+
--> $DIR/invalid_attribute_syntax.rs:15:1
17+
|
18+
15 | #[bitflags(default =)]
19+
| ^^^^^^^^^^^^^^^^^^^^^^
20+
|
21+
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
22+
23+
error: expected `=`
24+
--> $DIR/invalid_attribute_syntax.rs:21:1
25+
|
26+
21 | #[bitflags(default)]
27+
| ^^^^^^^^^^^^^^^^^^^^
28+
|
29+
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
30+
31+
error: expected `default`
32+
--> $DIR/invalid_attribute_syntax.rs:27:12
33+
|
34+
27 | #[bitflags(yes)]
35+
| ^^^

0 commit comments

Comments
 (0)