diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/typeck.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/typeck.fail.stderr similarity index 88% rename from tests/ui/rfcs/rfc-0000-never_patterns/typeck.stderr rename to tests/ui/rfcs/rfc-0000-never_patterns/typeck.fail.stderr index 8c0475894de..013a8b53a55 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/typeck.stderr +++ b/tests/ui/rfcs/rfc-0000-never_patterns/typeck.fail.stderr @@ -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` 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 diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/typeck.rs b/tests/ui/rfcs/rfc-0000-never_patterns/typeck.rs index 333108e92c0..31a23fa002c 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/typeck.rs +++ b/tests/ui/rfcs/rfc-0000-never_patterns/typeck.rs @@ -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(res: Result) { } // 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:: { 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 { !,