Skip to content

Commit a582d93

Browse files
Add regression test
1 parent e59a6f8 commit a582d93

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

tests/ui/macros/cfg_select.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,17 @@ cfg_select! {
9595
cfg!() => {}
9696
//~^ ERROR expected one of `(`, `::`, `=>`, or `=`, found `!`
9797
}
98+
99+
cfg_select! {
100+
true => {}
101+
invalid_cfg1 => {}
102+
//~^ WARN unexpected `cfg` condition name
103+
_ => {}
104+
}
105+
106+
cfg_select! {
107+
invalid_cfg2 => {}
108+
//~^ WARN unexpected `cfg` condition name
109+
true => {}
110+
_ => {}
111+
}

tests/ui/macros/cfg_select.stderr

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,27 @@ error: expected one of `(`, `::`, `=>`, or `=`, found `!`
6565
LL | cfg!() => {}
6666
| ^ expected one of `(`, `::`, `=>`, or `=`
6767

68-
error: aborting due to 9 previous errors; 1 warning emitted
68+
warning: unexpected `cfg` condition name: `invalid_cfg1`
69+
--> $DIR/cfg_select.rs:101:5
70+
|
71+
LL | invalid_cfg1 => {}
72+
| ^^^^^^^^^^^^
73+
|
74+
= help: expected names are: `FALSE` and `test` and 31 more
75+
= help: to expect this configuration use `--check-cfg=cfg(invalid_cfg1)`
76+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
77+
= note: `#[warn(unexpected_cfgs)]` on by default
78+
79+
warning: unexpected `cfg` condition name: `invalid_cfg2`
80+
--> $DIR/cfg_select.rs:107:5
81+
|
82+
LL | invalid_cfg2 => {}
83+
| ^^^^^^^^^^^^
84+
|
85+
= help: to expect this configuration use `--check-cfg=cfg(invalid_cfg2)`
86+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
87+
88+
error: aborting due to 9 previous errors; 3 warnings emitted
6989

7090
Some errors have detailed explanations: E0537, E0539.
7191
For more information about an error, try `rustc --explain E0537`.

0 commit comments

Comments
 (0)