Skip to content

Commit c111ccc

Browse files
Add more tests for cfg_select parsing
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
1 parent a5814a5 commit c111ccc

File tree

2 files changed

+98
-1
lines changed

2 files changed

+98
-1
lines changed

tests/ui/macros/cfg_select.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,38 @@ cfg_select! {
6060

6161
cfg_select! {}
6262
//~^ ERROR none of the predicates in this `cfg_select` evaluated to true
63+
64+
cfg_select! {
65+
=> {}
66+
//~^ ERROR expected unsuffixed literal, found `=>`
67+
}
68+
69+
cfg_select! {
70+
() => {}
71+
//~^ ERROR expected unsuffixed literal, found `(`
72+
}
73+
74+
cfg_select! { //~ ERROR none of the predicates in this `cfg_select` evaluated to true
75+
"str" => {}
76+
//~^ ERROR literal in `cfg` predicate value must be a boolean
77+
}
78+
79+
cfg_select! {
80+
a::b => {}
81+
//~^ ERROR `cfg` predicate key must be an identifier
82+
}
83+
84+
cfg_select! { //~ ERROR none of the predicates in this `cfg_select` evaluated to true
85+
a() => {}
86+
//~^ ERROR invalid predicate `a` [E0537]
87+
}
88+
89+
cfg_select! {
90+
a + 1 => {}
91+
//~^ ERROR expected one of `(`, `::`, `=>`, or `=`, found `+`
92+
}
93+
94+
cfg_select! {
95+
cfg!() => {}
96+
//~^ ERROR expected one of `(`, `::`, `=>`, or `=`, found `!`
97+
}

tests/ui/macros/cfg_select.stderr

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,67 @@ error: none of the predicates in this `cfg_select` evaluated to true
2121
LL | cfg_select! {}
2222
| ^^^^^^^^^^^^^^
2323

24-
error: aborting due to 2 previous errors; 1 warning emitted
24+
error: expected unsuffixed literal, found `=>`
25+
--> $DIR/cfg_select.rs:65:5
26+
|
27+
LL | => {}
28+
| ^^
29+
30+
error: expected unsuffixed literal, found `(`
31+
--> $DIR/cfg_select.rs:70:5
32+
|
33+
LL | () => {}
34+
| ^
35+
36+
error[E0565]: literal in `cfg` predicate value must be a boolean
37+
--> $DIR/cfg_select.rs:75:5
38+
|
39+
LL | "str" => {}
40+
| ^^^^^
41+
42+
error: none of the predicates in this `cfg_select` evaluated to true
43+
--> $DIR/cfg_select.rs:74:1
44+
|
45+
LL | / cfg_select! {
46+
LL | | "str" => {}
47+
LL | |
48+
LL | | }
49+
| |_^
50+
51+
error: `cfg` predicate key must be an identifier
52+
--> $DIR/cfg_select.rs:80:5
53+
|
54+
LL | a::b => {}
55+
| ^^^^
56+
57+
error[E0537]: invalid predicate `a`
58+
--> $DIR/cfg_select.rs:85:5
59+
|
60+
LL | a() => {}
61+
| ^^^
62+
63+
error: none of the predicates in this `cfg_select` evaluated to true
64+
--> $DIR/cfg_select.rs:84:1
65+
|
66+
LL | / cfg_select! {
67+
LL | | a() => {}
68+
LL | |
69+
LL | | }
70+
| |_^
71+
72+
error: expected one of `(`, `::`, `=>`, or `=`, found `+`
73+
--> $DIR/cfg_select.rs:90:7
74+
|
75+
LL | a + 1 => {}
76+
| ^ expected one of `(`, `::`, `=>`, or `=`
77+
78+
error: expected one of `(`, `::`, `=>`, or `=`, found `!`
79+
--> $DIR/cfg_select.rs:95:8
80+
|
81+
LL | cfg!() => {}
82+
| ^ expected one of `(`, `::`, `=>`, or `=`
83+
84+
error: aborting due to 11 previous errors; 1 warning emitted
2585

86+
Some errors have detailed explanations: E0537, E0565.
87+
For more information about an error, try `rustc --explain E0537`.

0 commit comments

Comments
 (0)