diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2023-11-27 01:08:39 +0100 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2023-12-02 03:41:37 +0100 |
| commit | caa488b96e65131e4d70f219d5e89008031f9229 (patch) | |
| tree | a0a55e71028fad7d4b1b2c87fb2142d2f45fb81d /tests/ui/parser | |
| parent | bd3a22115fa3b7c572333783cd315c134b48e967 (diff) | |
| download | rust-caa488b96e65131e4d70f219d5e89008031f9229.tar.gz rust-caa488b96e65131e4d70f219d5e89008031f9229.zip | |
Add tests
Diffstat (limited to 'tests/ui/parser')
| -rw-r--r-- | tests/ui/parser/match-arm-without-body.rs | 68 | ||||
| -rw-r--r-- | tests/ui/parser/match-arm-without-body.stderr | 122 |
2 files changed, 190 insertions, 0 deletions
diff --git a/tests/ui/parser/match-arm-without-body.rs b/tests/ui/parser/match-arm-without-body.rs new file mode 100644 index 00000000000..5f009c7a355 --- /dev/null +++ b/tests/ui/parser/match-arm-without-body.rs @@ -0,0 +1,68 @@ +macro_rules! pat { + () => { Some(_) } +} + +fn main() { + match Some(false) { + Some(_) + } + //~^ ERROR expected one of + match Some(false) { + Some(_) + _ => {} + //~^ ERROR expected one of + } + match Some(false) { + Some(_), + //~^ ERROR unexpected `,` in pattern + //~| HELP try adding parentheses to match on a tuple + //~| HELP or a vertical bar to match on multiple alternatives + } + match Some(false) { + Some(_), + //~^ ERROR unexpected `,` in pattern + //~| HELP try adding parentheses to match on a tuple + //~| HELP or a vertical bar to match on multiple alternatives + _ => {} + } + match Some(false) { + Some(_) if true + } + //~^ ERROR expected one of + match Some(false) { + Some(_) if true + _ => {} + //~^ ERROR expected one of + } + match Some(false) { + Some(_) if true, + //~^ ERROR expected one of + } + match Some(false) { + Some(_) if true, + //~^ ERROR expected one of + _ => {} + } + match Some(false) { + pat!() + } + //~^ ERROR expected one of + match Some(false) { + pat!(), + //~^ ERROR unexpected `,` in pattern + } + match Some(false) { + pat!() if true, + //~^ ERROR expected one of + } + match Some(false) { + pat!() + _ => {} + //~^ ERROR expected one of + } + match Some(false) { + pat!(), + //~^ ERROR unexpected `,` in pattern + _ => {} + } +} diff --git a/tests/ui/parser/match-arm-without-body.stderr b/tests/ui/parser/match-arm-without-body.stderr new file mode 100644 index 00000000000..210007628db --- /dev/null +++ b/tests/ui/parser/match-arm-without-body.stderr @@ -0,0 +1,122 @@ +error: expected one of `=>`, `if`, or `|`, found `}` + --> $DIR/match-arm-without-body.rs:8:5 + | +LL | Some(_) + | - expected one of `=>`, `if`, or `|` +LL | } + | ^ unexpected token + +error: expected one of `=>`, `if`, or `|`, found reserved identifier `_` + --> $DIR/match-arm-without-body.rs:12:9 + | +LL | Some(_) + | - expected one of `=>`, `if`, or `|` +LL | _ => {} + | ^ unexpected token + +error: unexpected `,` in pattern + --> $DIR/match-arm-without-body.rs:16:16 + | +LL | Some(_), + | ^ + | +help: try adding parentheses to match on a tuple... + | +LL | (Some(_),) + | + + +help: ...or a vertical bar to match on multiple alternatives + | +LL | Some(_) | + | + +error: unexpected `,` in pattern + --> $DIR/match-arm-without-body.rs:22:16 + | +LL | Some(_), + | ^ + | +help: try adding parentheses to match on a tuple... + | +LL ~ (Some(_), +LL | +LL | +LL | +LL ~ _) => {} + | +help: ...or a vertical bar to match on multiple alternatives + | +LL ~ Some(_) | +LL + +LL + +LL + +LL ~ _ => {} + | + +error: expected one of `.`, `=>`, `?`, or an operator, found `}` + --> $DIR/match-arm-without-body.rs:30:5 + | +LL | Some(_) if true + | - expected one of `.`, `=>`, `?`, or an operator +LL | } + | ^ unexpected token + +error: expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_` + --> $DIR/match-arm-without-body.rs:34:9 + | +LL | Some(_) if true + | - expected one of `.`, `=>`, `?`, or an operator +LL | _ => {} + | ^ unexpected token + +error: expected one of `.`, `=>`, `?`, or an operator, found `,` + --> $DIR/match-arm-without-body.rs:38:24 + | +LL | Some(_) if true, + | ^ expected one of `.`, `=>`, `?`, or an operator + +error: expected one of `.`, `=>`, `?`, or an operator, found `,` + --> $DIR/match-arm-without-body.rs:42:24 + | +LL | Some(_) if true, + | ^ expected one of `.`, `=>`, `?`, or an operator + +error: expected one of `=>`, `if`, or `|`, found `}` + --> $DIR/match-arm-without-body.rs:48:5 + | +LL | pat!() + | - expected one of `=>`, `if`, or `|` +LL | } + | ^ unexpected token + +error: unexpected `,` in pattern + --> $DIR/match-arm-without-body.rs:51:15 + | +LL | pat!(), + | ^ + | + = note: macros cannot expand to match arms + +error: expected one of `.`, `=>`, `?`, or an operator, found `,` + --> $DIR/match-arm-without-body.rs:55:23 + | +LL | pat!() if true, + | ^ expected one of `.`, `=>`, `?`, or an operator + +error: expected one of `=>`, `if`, or `|`, found reserved identifier `_` + --> $DIR/match-arm-without-body.rs:60:9 + | +LL | pat!() + | - expected one of `=>`, `if`, or `|` +LL | _ => {} + | ^ unexpected token + +error: unexpected `,` in pattern + --> $DIR/match-arm-without-body.rs:64:15 + | +LL | pat!(), + | ^ + | + = note: macros cannot expand to match arms + +error: aborting due to 13 previous errors + |
