]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/match_wildcard_for_single_variants.fixed
Add more test cases for match_wildcard_for_single_variants
[rust.git] / tests / ui / match_wildcard_for_single_variants.fixed
index 5f1a559f5914307e1d860d2e084546a2e4bcebdd..519200977a798d4356e29bf8bea1b55dcce5fa16 100644 (file)
@@ -9,10 +9,51 @@ enum Foo {
     C,
 }
 
+enum Color {
+    Red,
+    Green,
+    Blue,
+    Rgb(u8, u8, u8),
+}
+
 fn main() {
-    match Foo::A {
+    let f = Foo::A;
+    match f {
         Foo::A => {},
         Foo::B => {},
         Foo::C => {},
     }
+
+    let color = Color::Red;
+
+    // check exhaustive bindings
+    match color {
+        Color::Red => {},
+        Color::Green => {},
+        Color::Rgb(_r, _g, _b) => {},
+        Color::Blue => {},
+    }
+
+    // check exhaustive wild
+    match color {
+        Color::Red => {},
+        Color::Green => {},
+        Color::Rgb(..) => {},
+        Color::Blue => {},
+    }
+    match color {
+        Color::Red => {},
+        Color::Green => {},
+        Color::Rgb(_, _, _) => {},
+        Color::Blue => {},
+    }
+
+    // shouldn't lint as there is one missing variant
+    // and one that isn't exhaustively covered
+    match color {
+        Color::Red => {},
+        Color::Green => {},
+        Color::Rgb(255, _, _) => {},
+        _ => {},
+    }
 }