Add tests
This commit is contained in:
parent
d8b44d2802
commit
342ea15490
4 changed files with 72 additions and 56 deletions
|
@ -74,26 +74,3 @@ fn never_pattern_location(void: Void) {
|
|||
Some(&(_, !)),
|
||||
}
|
||||
}
|
||||
|
||||
fn never_and_bindings() {
|
||||
let x: Result<bool, &(u32, Void)> = Ok(false);
|
||||
|
||||
// FIXME(never_patterns): Never patterns in or-patterns don't need to share the same bindings.
|
||||
match x {
|
||||
Ok(_x) | Err(&!) => {}
|
||||
//~^ ERROR: is not bound in all patterns
|
||||
}
|
||||
let (Ok(_x) | Err(&!)) = x;
|
||||
//~^ ERROR: is not bound in all patterns
|
||||
|
||||
// FIXME(never_patterns): A never pattern mustn't have bindings.
|
||||
match x {
|
||||
Ok(_) => {}
|
||||
Err(&(_b, !)),
|
||||
}
|
||||
match x {
|
||||
Ok(_a) | Err(&(_b, !)) => {}
|
||||
//~^ ERROR: is not bound in all patterns
|
||||
//~| ERROR: is not bound in all patterns
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,38 +14,6 @@ LL | let (Ok(_x) | Err(&!)) = res.as_ref();
|
|||
| |
|
||||
| variable not in all patterns
|
||||
|
||||
error[E0408]: variable `_x` is not bound in all patterns
|
||||
--> $DIR/never_patterns.rs:83:18
|
||||
|
|
||||
LL | Ok(_x) | Err(&!) => {}
|
||||
| -- ^^^^^^^ pattern doesn't bind `_x`
|
||||
| |
|
||||
| variable not in all patterns
|
||||
|
||||
error[E0408]: variable `_x` is not bound in all patterns
|
||||
--> $DIR/never_patterns.rs:86:19
|
||||
|
|
||||
LL | let (Ok(_x) | Err(&!)) = x;
|
||||
| -- ^^^^^^^ pattern doesn't bind `_x`
|
||||
| |
|
||||
| variable not in all patterns
|
||||
|
||||
error[E0408]: variable `_b` is not bound in all patterns
|
||||
--> $DIR/never_patterns.rs:95:9
|
||||
|
|
||||
LL | Ok(_a) | Err(&(_b, !)) => {}
|
||||
| ^^^^^^ -- variable not in all patterns
|
||||
| |
|
||||
| pattern doesn't bind `_b`
|
||||
|
||||
error[E0408]: variable `_a` is not bound in all patterns
|
||||
--> $DIR/never_patterns.rs:95:18
|
||||
|
|
||||
LL | Ok(_a) | Err(&(_b, !)) => {}
|
||||
| -- ^^^^^^^^^^^^^ pattern doesn't bind `_a`
|
||||
| |
|
||||
| variable not in all patterns
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0408`.
|
||||
|
|
28
tests/ui/rfcs/rfc-0000-never_patterns/bindings.rs
Normal file
28
tests/ui/rfcs/rfc-0000-never_patterns/bindings.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
#![feature(never_patterns)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
enum Void {}
|
||||
|
||||
fn main() {
|
||||
let x: Result<bool, &(u32, u32, Void)> = Ok(false);
|
||||
|
||||
// FIXME(never_patterns): Never patterns in or-patterns don't need to share the same bindings.
|
||||
match x {
|
||||
Ok(_x) | Err(&!) => {}
|
||||
//~^ ERROR: is not bound in all patterns
|
||||
}
|
||||
let (Ok(_x) | Err(&!)) = x;
|
||||
//~^ ERROR: is not bound in all patterns
|
||||
|
||||
// FIXME(never_patterns): A never pattern mustn't have bindings.
|
||||
match x {
|
||||
Ok(_) => {}
|
||||
Err(&(_a, _b, !)),
|
||||
}
|
||||
match x {
|
||||
Ok(_ok) | Err(&(_a, _b, !)) => {}
|
||||
//~^ ERROR: is not bound in all patterns
|
||||
//~| ERROR: is not bound in all patterns
|
||||
//~| ERROR: is not bound in all patterns
|
||||
}
|
||||
}
|
43
tests/ui/rfcs/rfc-0000-never_patterns/bindings.stderr
Normal file
43
tests/ui/rfcs/rfc-0000-never_patterns/bindings.stderr
Normal file
|
@ -0,0 +1,43 @@
|
|||
error[E0408]: variable `_x` is not bound in all patterns
|
||||
--> $DIR/bindings.rs:11:18
|
||||
|
|
||||
LL | Ok(_x) | Err(&!) => {}
|
||||
| -- ^^^^^^^ pattern doesn't bind `_x`
|
||||
| |
|
||||
| variable not in all patterns
|
||||
|
||||
error[E0408]: variable `_x` is not bound in all patterns
|
||||
--> $DIR/bindings.rs:14:19
|
||||
|
|
||||
LL | let (Ok(_x) | Err(&!)) = x;
|
||||
| -- ^^^^^^^ pattern doesn't bind `_x`
|
||||
| |
|
||||
| variable not in all patterns
|
||||
|
||||
error[E0408]: variable `_a` is not bound in all patterns
|
||||
--> $DIR/bindings.rs:23:9
|
||||
|
|
||||
LL | Ok(_ok) | Err(&(_a, _b, !)) => {}
|
||||
| ^^^^^^^ -- variable not in all patterns
|
||||
| |
|
||||
| pattern doesn't bind `_a`
|
||||
|
||||
error[E0408]: variable `_b` is not bound in all patterns
|
||||
--> $DIR/bindings.rs:23:9
|
||||
|
|
||||
LL | Ok(_ok) | Err(&(_a, _b, !)) => {}
|
||||
| ^^^^^^^ -- variable not in all patterns
|
||||
| |
|
||||
| pattern doesn't bind `_b`
|
||||
|
||||
error[E0408]: variable `_ok` is not bound in all patterns
|
||||
--> $DIR/bindings.rs:23:19
|
||||
|
|
||||
LL | Ok(_ok) | Err(&(_a, _b, !)) => {}
|
||||
| --- ^^^^^^^^^^^^^^^^^ pattern doesn't bind `_ok`
|
||||
| |
|
||||
| variable not in all patterns
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0408`.
|
Loading…
Add table
Reference in a new issue