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
|
error: mismatched types
|
||||||
--> $DIR/typeck.rs:21:9
|
--> $DIR/typeck.rs:25:9
|
||||||
|
|
|
|
||||||
LL | !,
|
LL | !,
|
||||||
| ^ a never pattern must be used on an uninhabited type
|
| ^ a never pattern must be used on an uninhabited type
|
||||||
@ -7,7 +7,7 @@ LL | !,
|
|||||||
= note: the matched value is of type `()`
|
= note: the matched value is of type `()`
|
||||||
|
|
||||||
error: mismatched types
|
error: mismatched types
|
||||||
--> $DIR/typeck.rs:25:9
|
--> $DIR/typeck.rs:29:9
|
||||||
|
|
|
|
||||||
LL | !,
|
LL | !,
|
||||||
| ^ a never pattern must be used on an uninhabited type
|
| ^ a never pattern must be used on an uninhabited type
|
||||||
@ -15,7 +15,7 @@ LL | !,
|
|||||||
= note: the matched value is of type `(i32, bool)`
|
= note: the matched value is of type `(i32, bool)`
|
||||||
|
|
||||||
error: mismatched types
|
error: mismatched types
|
||||||
--> $DIR/typeck.rs:29:13
|
--> $DIR/typeck.rs:33:13
|
||||||
|
|
|
|
||||||
LL | (_, !),
|
LL | (_, !),
|
||||||
| ^ a never pattern must be used on an uninhabited type
|
| ^ a never pattern must be used on an uninhabited type
|
||||||
@ -23,7 +23,7 @@ LL | (_, !),
|
|||||||
= note: the matched value is of type `bool`
|
= note: the matched value is of type `bool`
|
||||||
|
|
||||||
error: mismatched types
|
error: mismatched types
|
||||||
--> $DIR/typeck.rs:34:14
|
--> $DIR/typeck.rs:38:14
|
||||||
|
|
|
|
||||||
LL | Some(!),
|
LL | Some(!),
|
||||||
| ^ a never pattern must be used on an uninhabited type
|
| ^ a never pattern must be used on an uninhabited type
|
||||||
@ -31,7 +31,7 @@ LL | Some(!),
|
|||||||
= note: the matched value is of type `i32`
|
= note: the matched value is of type `i32`
|
||||||
|
|
||||||
error: mismatched types
|
error: mismatched types
|
||||||
--> $DIR/typeck.rs:41:9
|
--> $DIR/typeck.rs:45:9
|
||||||
|
|
|
|
||||||
LL | !,
|
LL | !,
|
||||||
| ^ a never pattern must be used on an uninhabited type
|
| ^ a never pattern must be used on an uninhabited type
|
||||||
@ -39,7 +39,7 @@ LL | !,
|
|||||||
= note: the matched value is of type `()`
|
= note: the matched value is of type `()`
|
||||||
|
|
||||||
error: mismatched types
|
error: mismatched types
|
||||||
--> $DIR/typeck.rs:48:9
|
--> $DIR/typeck.rs:52:9
|
||||||
|
|
|
|
||||||
LL | !,
|
LL | !,
|
||||||
| ^ a never pattern must be used on an uninhabited type
|
| ^ a never pattern must be used on an uninhabited type
|
||||||
@ -47,7 +47,7 @@ LL | !,
|
|||||||
= note: the matched value is of type `Option<Void>`
|
= note: the matched value is of type `Option<Void>`
|
||||||
|
|
||||||
error: mismatched types
|
error: mismatched types
|
||||||
--> $DIR/typeck.rs:53:9
|
--> $DIR/typeck.rs:57:9
|
||||||
|
|
|
|
||||||
LL | !,
|
LL | !,
|
||||||
| ^ a never pattern must be used on an uninhabited type
|
| ^ a never pattern must be used on an uninhabited type
|
||||||
@ -55,7 +55,7 @@ LL | !,
|
|||||||
= note: the matched value is of type `[Void]`
|
= note: the matched value is of type `[Void]`
|
||||||
|
|
||||||
error: mismatched types
|
error: mismatched types
|
||||||
--> $DIR/typeck.rs:59:9
|
--> $DIR/typeck.rs:63:9
|
||||||
|
|
|
|
||||||
LL | !,
|
LL | !,
|
||||||
| ^ a never pattern must be used on an uninhabited type
|
| ^ 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(never_patterns)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
#![allow(incomplete_features)]
|
#![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.
|
// 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.
|
// Don't accept on a non-empty type.
|
||||||
match () {
|
match () {
|
||||||
!,
|
!,
|
||||||
//~^ ERROR: mismatched types
|
//[fail]~^ ERROR: mismatched types
|
||||||
}
|
}
|
||||||
match (0, false) {
|
match (0, false) {
|
||||||
!,
|
!,
|
||||||
//~^ ERROR: mismatched types
|
//[fail]~^ ERROR: mismatched types
|
||||||
}
|
}
|
||||||
match (0, false) {
|
match (0, false) {
|
||||||
(_, !),
|
(_, !),
|
||||||
//~^ ERROR: mismatched types
|
//[fail]~^ ERROR: mismatched types
|
||||||
}
|
}
|
||||||
match Some(0) {
|
match Some(0) {
|
||||||
None => {}
|
None => {}
|
||||||
Some(!),
|
Some(!),
|
||||||
//~^ ERROR: mismatched types
|
//[fail]~^ ERROR: mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't accept on an arbitrary type, even if there are no more branches.
|
// Don't accept on an arbitrary type, even if there are no more branches.
|
||||||
match () {
|
match () {
|
||||||
() => {}
|
() => {}
|
||||||
!,
|
!,
|
||||||
//~^ ERROR: mismatched types
|
//[fail]~^ ERROR: mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't accept even on an empty branch.
|
// Don't accept even on an empty branch.
|
||||||
match None::<Void> {
|
match None::<Void> {
|
||||||
None => {}
|
None => {}
|
||||||
!,
|
!,
|
||||||
//~^ ERROR: mismatched types
|
//[fail]~^ ERROR: mismatched types
|
||||||
}
|
}
|
||||||
match (&[] as &[Void]) {
|
match (&[] as &[Void]) {
|
||||||
[] => {}
|
[] => {}
|
||||||
!,
|
!,
|
||||||
//~^ ERROR: mismatched types
|
//[fail]~^ ERROR: mismatched types
|
||||||
}
|
}
|
||||||
// Let alone if the emptiness is behind a reference.
|
// Let alone if the emptiness is behind a reference.
|
||||||
match None::<&Void> {
|
match None::<&Void> {
|
||||||
None => {}
|
None => {}
|
||||||
!,
|
!,
|
||||||
//~^ ERROR: mismatched types
|
//[fail]~^ ERROR: mismatched types
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(pass)]
|
||||||
|
fn never_pattern_typeck_pass(void: Void) {
|
||||||
// Participate in match ergonomics.
|
// Participate in match ergonomics.
|
||||||
match &void {
|
match &void {
|
||||||
!,
|
!,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user