diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2025-07-04 23:56:16 +0200 |
|---|---|---|
| committer | Folkert de Vries <folkert@folkertdev.nl> | 2025-07-13 14:34:40 +0200 |
| commit | 3689b80b75bb400e740897ec83e64be332098c0d (patch) | |
| tree | db23b5f9d95c0f4613ae1599111c0c7c595be85a /tests/ui/macros | |
| parent | 1b0bc594a75dfc1cdedc6c17052cf44de101e632 (diff) | |
| download | rust-3689b80b75bb400e740897ec83e64be332098c0d.tar.gz rust-3689b80b75bb400e740897ec83e64be332098c0d.zip | |
make `cfg_select` a builtin macro
Diffstat (limited to 'tests/ui/macros')
| -rw-r--r-- | tests/ui/macros/cfg_select.rs | 27 | ||||
| -rw-r--r-- | tests/ui/macros/cfg_select.stderr | 25 |
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/ui/macros/cfg_select.rs b/tests/ui/macros/cfg_select.rs new file mode 100644 index 00000000000..a4d94836a09 --- /dev/null +++ b/tests/ui/macros/cfg_select.rs @@ -0,0 +1,27 @@ +#![feature(cfg_select)] +#![crate_type = "lib"] + +fn print() { + println!(cfg_select! { + unix => { "unix" } + _ => { "not unix" } + }); +} + +fn arm_rhs_must_be_in_braces() -> i32 { + cfg_select! { + true => 1 + //~^ ERROR: expected `{`, found `1` + } +} + +cfg_select! { + _ => {} + true => {} + //~^ WARN unreachable rule +} + +cfg_select! { + //~^ ERROR none of the rules in this `cfg_select` evaluated to true + false => {} +} diff --git a/tests/ui/macros/cfg_select.stderr b/tests/ui/macros/cfg_select.stderr new file mode 100644 index 00000000000..fef5e95a6bc --- /dev/null +++ b/tests/ui/macros/cfg_select.stderr @@ -0,0 +1,25 @@ +error: expected `{`, found `1` + --> $DIR/cfg_select.rs:13:17 + | +LL | true => 1 + | ^ expected `{` + +warning: unreachable rule + --> $DIR/cfg_select.rs:20:5 + | +LL | _ => {} + | - always matches +LL | true => {} + | ^^^^ this rules is never reached + +error: none of the rules in this `cfg_select` evaluated to true + --> $DIR/cfg_select.rs:24:1 + | +LL | / cfg_select! { +LL | | +LL | | false => {} +LL | | } + | |_^ + +error: aborting due to 2 previous errors; 1 warning emitted + |
