Split-off the passing tests to ensure they pass
This commit is contained in:
parent
d8b72e796e
commit
ff6fa67a9d
@ -1,5 +1,5 @@
|
||||
error: mismatched types
|
||||
--> $DIR/typeck.rs:21:9
|
||||
--> $DIR/typeck.rs:25:9
|
||||
|
|
||||
LL | !,
|
||||
| ^ a never pattern must be used on an uninhabited type
|
||||
@ -7,7 +7,7 @@ LL | !,
|
||||
= note: the matched value is of type `()`
|
||||
|
||||
error: mismatched types
|
||||
--> $DIR/typeck.rs:25:9
|
||||
--> $DIR/typeck.rs:29:9
|
||||
|
|
||||
LL | !,
|
||||
| ^ a never pattern must be used on an uninhabited type
|
||||
@ -15,7 +15,7 @@ LL | !,
|
||||
= note: the matched value is of type `(i32, bool)`
|
||||
|
||||
error: mismatched types
|
||||
--> $DIR/typeck.rs:29:13
|
||||
--> $DIR/typeck.rs:33:13
|
||||
|
|
||||
LL | (_, !),
|
||||
| ^ a never pattern must be used on an uninhabited type
|
||||
@ -23,7 +23,7 @@ LL | (_, !),
|
||||
= note: the matched value is of type `bool`
|
||||
|
||||
error: mismatched types
|
||||
--> $DIR/typeck.rs:34:14
|
||||
--> $DIR/typeck.rs:38:14
|
||||
|
|
||||
LL | Some(!),
|
||||
| ^ a never pattern must be used on an uninhabited type
|
||||
@ -31,7 +31,7 @@ LL | Some(!),
|
||||
= note: the matched value is of type `i32`
|
||||
|
||||
error: mismatched types
|
||||
--> $DIR/typeck.rs:41:9
|
||||
--> $DIR/typeck.rs:45:9
|
||||
|
|
||||
LL | !,
|
||||
| ^ a never pattern must be used on an uninhabited type
|
||||
@ -39,7 +39,7 @@ LL | !,
|
||||
= note: the matched value is of type `()`
|
||||
|
||||
error: mismatched types
|
||||
--> $DIR/typeck.rs:48:9
|
||||
--> $DIR/typeck.rs:52:9
|
||||
|
|
||||
LL | !,
|
||||
| ^ a never pattern must be used on an uninhabited type
|
||||
@ -47,7 +47,7 @@ LL | !,
|
||||
= note: the matched value is of type `Option<Void>`
|
||||
|
||||
error: mismatched types
|
||||
--> $DIR/typeck.rs:53:9
|
||||
--> $DIR/typeck.rs:57:9
|
||||
|
|
||||
LL | !,
|
||||
| ^ a never pattern must be used on an uninhabited type
|
||||
@ -55,7 +55,7 @@ LL | !,
|
||||
= note: the matched value is of type `[Void]`
|
||||
|
||||
error: mismatched types
|
||||
--> $DIR/typeck.rs:59:9
|
||||
--> $DIR/typeck.rs:63:9
|
||||
|
|
||||
LL | !,
|
||||
| ^ a never pattern must be used on an uninhabited type
|
@ -1,3 +1,6 @@
|
||||
// revisions: pass fail
|
||||
//[pass] check-pass
|
||||
//[fail] check-fail
|
||||
#![feature(never_patterns)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![allow(incomplete_features)]
|
||||
@ -15,51 +18,55 @@ fn safe_unwrap_result<T: Copy>(res: Result<T, Void>) {
|
||||
}
|
||||
|
||||
// Check we only accept `!` where we want to.
|
||||
fn never_pattern_typeck(void: Void) {
|
||||
#[cfg(fail)]
|
||||
fn never_pattern_typeck_fail(void: Void) {
|
||||
// Don't accept on a non-empty type.
|
||||
match () {
|
||||
!,
|
||||
//~^ ERROR: mismatched types
|
||||
//[fail]~^ ERROR: mismatched types
|
||||
}
|
||||
match (0, false) {
|
||||
!,
|
||||
//~^ ERROR: mismatched types
|
||||
//[fail]~^ ERROR: mismatched types
|
||||
}
|
||||
match (0, false) {
|
||||
(_, !),
|
||||
//~^ ERROR: mismatched types
|
||||
//[fail]~^ ERROR: mismatched types
|
||||
}
|
||||
match Some(0) {
|
||||
None => {}
|
||||
Some(!),
|
||||
//~^ ERROR: mismatched types
|
||||
//[fail]~^ ERROR: mismatched types
|
||||
}
|
||||
|
||||
// Don't accept on an arbitrary type, even if there are no more branches.
|
||||
match () {
|
||||
() => {}
|
||||
!,
|
||||
//~^ ERROR: mismatched types
|
||||
//[fail]~^ ERROR: mismatched types
|
||||
}
|
||||
|
||||
// Don't accept even on an empty branch.
|
||||
match None::<Void> {
|
||||
None => {}
|
||||
!,
|
||||
//~^ ERROR: mismatched types
|
||||
//[fail]~^ ERROR: mismatched types
|
||||
}
|
||||
match (&[] as &[Void]) {
|
||||
[] => {}
|
||||
!,
|
||||
//~^ ERROR: mismatched types
|
||||
//[fail]~^ ERROR: mismatched types
|
||||
}
|
||||
// Let alone if the emptiness is behind a reference.
|
||||
match None::<&Void> {
|
||||
None => {}
|
||||
!,
|
||||
//~^ ERROR: mismatched types
|
||||
//[fail]~^ ERROR: mismatched types
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(pass)]
|
||||
fn never_pattern_typeck_pass(void: Void) {
|
||||
// Participate in match ergonomics.
|
||||
match &void {
|
||||
!,
|
||||
|
Loading…
x
Reference in New Issue
Block a user