about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkoka <koka.code@gmail.com>2022-12-11 12:20:46 +0900
committerkoka <koka.code@gmail.com>2022-12-18 21:07:18 +0900
commitebb0759bb3a9341ff662551366efb1844c91d3ca (patch)
treec856f4b814903387af3ece1dca5b815fb05f9da0
parent055f349670155d88ae3a2f0a40baa47f524efa88 (diff)
downloadrust-ebb0759bb3a9341ff662551366efb1844c91d3ca.tar.gz
rust-ebb0759bb3a9341ff662551366efb1844c91d3ca.zip
Add a test for regular wildcard
fix
-rw-r--r--tests/ui/match_wildcard_for_single_variants.fixed6
-rw-r--r--tests/ui/match_wildcard_for_single_variants.rs6
-rw-r--r--tests/ui/match_wildcard_for_single_variants.stderr8
3 files changed, 19 insertions, 1 deletions
diff --git a/tests/ui/match_wildcard_for_single_variants.fixed b/tests/ui/match_wildcard_for_single_variants.fixed
index c508b7cc3b2..fc252cdd352 100644
--- a/tests/ui/match_wildcard_for_single_variants.fixed
+++ b/tests/ui/match_wildcard_for_single_variants.fixed
@@ -146,5 +146,11 @@ mod issue9993 {
             Foo::A(false) => 2,
             Foo::B => 3,
         };
+
+        let _ = match Foo::B {
+            _ if false => 0,
+            Foo::A(_) => 1,
+            Foo::B => 2,
+        };
     }
 }
diff --git a/tests/ui/match_wildcard_for_single_variants.rs b/tests/ui/match_wildcard_for_single_variants.rs
index ad03f797129..9a5c849e6ec 100644
--- a/tests/ui/match_wildcard_for_single_variants.rs
+++ b/tests/ui/match_wildcard_for_single_variants.rs
@@ -146,5 +146,11 @@ mod issue9993 {
             Foo::A(false) => 2,
             Foo::B => 3,
         };
+
+        let _ = match Foo::B {
+            _ if false => 0,
+            Foo::A(_) => 1,
+            _ => 2,
+        };
     }
 }
diff --git a/tests/ui/match_wildcard_for_single_variants.stderr b/tests/ui/match_wildcard_for_single_variants.stderr
index 34538dea8e5..6fa313dc911 100644
--- a/tests/ui/match_wildcard_for_single_variants.stderr
+++ b/tests/ui/match_wildcard_for_single_variants.stderr
@@ -48,5 +48,11 @@ error: wildcard matches only a single variant and will also match any future add
 LL |         _ => (),
    |         ^ help: try this: `Color::Blue`
 
-error: aborting due to 8 previous errors
+error: wildcard matches only a single variant and will also match any future added variants
+  --> $DIR/match_wildcard_for_single_variants.rs:153:13
+   |
+LL |             _ => 2,
+   |             ^ help: try this: `Foo::B`
+
+error: aborting due to 9 previous errors