Fix message for match_wildcard_for_single_variant

This commit is contained in:
Jason Newcomb 2021-03-16 12:56:08 -04:00
parent 6cc9cac4bc
commit d5a7941ead
No known key found for this signature in database
GPG key ID: DA59E8643A37ED06
3 changed files with 16 additions and 16 deletions

View file

@ -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(

View file

@ -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 | _ => (),

View file

@ -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 | _ => {},