X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftest%2Fui%2Fpattern%2Fusefulness%2Fmatch-empty-exhaustive_patterns.rs;h=c5c3a214f9aff1d4f8a566040b2c12e597d0c2b5;hb=69821cf8df86c8f4366e0c16a0a7de8d0135b90f;hp=57b6b910ca1dad857637b5bfafeb26e4608ea7c4;hpb=a0be3a683d40981b5ea19c94640621f0816c3b1a;p=rust.git diff --git a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs b/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs index 57b6b910ca1..c5c3a214f9a 100644 --- a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs +++ b/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs @@ -1,7 +1,12 @@ +// aux-build:empty.rs #![feature(never_type)] +#![feature(never_type_fallback)] #![feature(exhaustive_patterns)] #![deny(unreachable_patterns)] -enum Foo {} + +extern crate empty; + +enum EmptyEnum {} struct NonEmptyStruct(bool); //~ `NonEmptyStruct` defined here union NonEmptyUnion1 { //~ `NonEmptyUnion1` defined here @@ -41,8 +46,28 @@ macro_rules! match_false { }; } -fn foo(x: Foo) { - match_empty!(x); // ok +fn empty_enum(x: EmptyEnum) { + match x {} // ok + match x { + _ => {}, //~ ERROR unreachable pattern + } + match x { + _ if false => {}, //~ ERROR unreachable pattern + } +} + +fn empty_foreign_enum(x: empty::EmptyForeignEnum) { + match x {} // ok + match x { + _ => {}, //~ ERROR unreachable pattern + } + match x { + _ if false => {}, //~ ERROR unreachable pattern + } +} + +fn never(x: !) { + match x {} // ok match x { _ => {}, //~ ERROR unreachable pattern } @@ -56,7 +81,7 @@ fn main() { None => {} Some(_) => {} //~ ERROR unreachable pattern } - match None:: { + match None:: { None => {} Some(_) => {} //~ ERROR unreachable pattern }