about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJason Newcomb <jsnewcomb@pm.me>2021-03-16 12:56:08 -0400
committerJason Newcomb <jsnewcomb@pm.me>2021-03-17 12:42:18 -0400
commitd5a7941ead06e1cb89a0a2cc6ea5c19810daea03 (patch)
treeff4d80b8d7db6d8e3d7a56da8fd1397778286576
parent6cc9cac4bc7a2eca8528bfa78383dac68cc5b7bf (diff)
downloadrust-d5a7941ead06e1cb89a0a2cc6ea5c19810daea03.tar.gz
rust-d5a7941ead06e1cb89a0a2cc6ea5c19810daea03.zip
Fix message for `match_wildcard_for_single_variant`
-rw-r--r--clippy_lints/src/matches.rs6
-rw-r--r--tests/ui/match_wildcard_for_single_variants.stderr16
-rw-r--r--tests/ui/wildcard_enum_match_arm.stderr10
3 files changed, 16 insertions, 16 deletions
diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs
index e9926e0bca5..d43cb32ee51 100644
--- a/clippy_lints/src/matches.rs
+++ b/clippy_lints/src/matches.rs
@@ -1106,7 +1106,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
             cx,
             MATCH_WILDCARD_FOR_SINGLE_VARIANTS,
             wildcard_span,
-            "match on non-exhaustive enum doesn't explicitly match all known variants",
+            "wildcard matches only a single variant and will also match any future added variants",
             "try this",
             format_suggestion(x),
             Applicability::MaybeIncorrect,
@@ -1115,9 +1115,9 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
             let mut suggestions: Vec<_> = variants.iter().cloned().map(format_suggestion).collect();
             let message = if adt_def.is_variant_list_non_exhaustive() {
                 suggestions.push("_".into());
-                "match on non-exhaustive enum doesn't explicitly match all known variants"
+                "wildcard matches known variants and will also match future added variants"
             } else {
-                "wildcard match will miss any future added variants"
+                "wildcard match will also match any future added variants"
             };
 
             span_lint_and_sugg(
diff --git a/tests/ui/match_wildcard_for_single_variants.stderr b/tests/ui/match_wildcard_for_single_variants.stderr
index e0900c970c3..34538dea8e5 100644
--- a/tests/ui/match_wildcard_for_single_variants.stderr
+++ b/tests/ui/match_wildcard_for_single_variants.stderr
@@ -1,4 +1,4 @@
-error: match on non-exhaustive enum doesn't explicitly match all known variants
+error: wildcard matches only a single variant and will also match any future added variants
   --> $DIR/match_wildcard_for_single_variants.rs:24:13
    |
 LL |             _ => (),
@@ -6,43 +6,43 @@ LL |             _ => (),
    |
    = note: `-D clippy::match-wildcard-for-single-variants` implied by `-D warnings`
 
-error: match on non-exhaustive enum doesn't explicitly match all known variants
+error: wildcard matches only a single variant and will also match any future added variants
   --> $DIR/match_wildcard_for_single_variants.rs:34:9
    |
 LL |         _ => {},
    |         ^ help: try this: `Foo::C`
 
-error: match on non-exhaustive enum doesn't explicitly match all known variants
+error: wildcard matches only a single variant and will also match any future added variants
   --> $DIR/match_wildcard_for_single_variants.rs:44:9
    |
 LL |         _ => {},
    |         ^ help: try this: `Color::Blue`
 
-error: match on non-exhaustive enum doesn't explicitly match all known variants
+error: wildcard matches only a single variant and will also match any future added variants
   --> $DIR/match_wildcard_for_single_variants.rs:52:9
    |
 LL |         _ => {},
    |         ^ help: try this: `Color::Blue`
 
-error: match on non-exhaustive enum doesn't explicitly match all known variants
+error: wildcard matches only a single variant and will also match any future added variants
   --> $DIR/match_wildcard_for_single_variants.rs:58:9
    |
 LL |         _ => {},
    |         ^ help: try this: `Color::Blue`
 
-error: match on non-exhaustive enum doesn't explicitly match all known variants
+error: wildcard matches only a single variant and will also match any future added variants
   --> $DIR/match_wildcard_for_single_variants.rs:75:9
    |
 LL |         &_ => (),
    |         ^^ help: try this: `Color::Blue`
 
-error: match on non-exhaustive enum doesn't explicitly match all known variants
+error: wildcard matches only a single variant and will also match any future added variants
   --> $DIR/match_wildcard_for_single_variants.rs:84:9
    |
 LL |         _ => (),
    |         ^ help: try this: `C::Blue`
 
-error: match on non-exhaustive enum doesn't explicitly match all known variants
+error: wildcard matches only a single variant and will also match any future added variants
   --> $DIR/match_wildcard_for_single_variants.rs:91:9
    |
 LL |         _ => (),
diff --git a/tests/ui/wildcard_enum_match_arm.stderr b/tests/ui/wildcard_enum_match_arm.stderr
index 8d880b7ce0a..a513a62c748 100644
--- a/tests/ui/wildcard_enum_match_arm.stderr
+++ b/tests/ui/wildcard_enum_match_arm.stderr
@@ -1,4 +1,4 @@
-error: wildcard match will miss any future added variants
+error: wildcard match will also match any future added variants
   --> $DIR/wildcard_enum_match_arm.rs:39:9
    |
 LL |         _ => eprintln!("Not red"),
@@ -10,25 +10,25 @@ note: the lint level is defined here
 LL | #![deny(clippy::wildcard_enum_match_arm)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: wildcard match will miss any future added variants
+error: wildcard match will also match any future added variants
   --> $DIR/wildcard_enum_match_arm.rs:43:9
    |
 LL |         _not_red => eprintln!("Not red"),
    |         ^^^^^^^^ help: try this: `_not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan`
 
-error: wildcard match will miss any future added variants
+error: wildcard match will also match any future added variants
   --> $DIR/wildcard_enum_match_arm.rs:47:9
    |
 LL |         not_red => format!("{:?}", not_red),
    |         ^^^^^^^ help: try this: `not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan`
 
-error: wildcard match will miss any future added variants
+error: wildcard match will also match any future added variants
   --> $DIR/wildcard_enum_match_arm.rs:63:9
    |
 LL |         _ => "No red",
    |         ^ help: try this: `Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan`
 
-error: match on non-exhaustive enum doesn't explicitly match all known variants
+error: wildcard matches known variants and will also match future added variants
   --> $DIR/wildcard_enum_match_arm.rs:80:9
    |
 LL |         _ => {},