Add tests
This commit is contained in:
parent
bd3a22115f
commit
caa488b96e
30
tests/ui/never_patterns/check.rs
Normal file
30
tests/ui/never_patterns/check.rs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#![feature(never_patterns)]
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
|
enum Void {}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
|
|
||||||
|
macro_rules! never {
|
||||||
|
() => { ! }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn no_arms_or_guards(x: Void) {
|
||||||
|
match None::<Void> {
|
||||||
|
Some(!) => {}
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
match None::<Void> {
|
||||||
|
Some(!) if true,
|
||||||
|
//~^ ERROR expected one of
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
match None::<Void> {
|
||||||
|
Some(!) if true => {}
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
match None::<Void> {
|
||||||
|
Some(never!()) => {},
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
}
|
8
tests/ui/never_patterns/check.stderr
Normal file
8
tests/ui/never_patterns/check.stderr
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
error: expected one of `.`, `=>`, `?`, or an operator, found `,`
|
||||||
|
--> $DIR/check.rs:18:24
|
||||||
|
|
|
||||||
|
LL | Some(!) if true,
|
||||||
|
| ^ expected one of `.`, `=>`, `?`, or an operator
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
68
tests/ui/parser/match-arm-without-body.rs
Normal file
68
tests/ui/parser/match-arm-without-body.rs
Normal file
@ -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
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
122
tests/ui/parser/match-arm-without-body.stderr
Normal file
122
tests/ui/parser/match-arm-without-body.stderr
Normal file
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user