]> git.lizzy.rs Git - rust.git/blobdiff - src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs
Add a test for foreign empty enums
[rust.git] / src / test / ui / pattern / usefulness / match-empty-exhaustive_patterns.rs
index 57b6b910ca1dad857637b5bfafeb26e4608ea7c4..c5c3a214f9aff1d4f8a566040b2c12e597d0c2b5 100644 (file)
@@ -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::<Foo> {
+    match None::<EmptyEnum> {
         None => {}
         Some(_) => {} //~ ERROR unreachable pattern
     }