Skip to content

Commit d5a7941

Browse files
committed
Fix message for match_wildcard_for_single_variant
1 parent 6cc9cac commit d5a7941

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

clippy_lints/src/matches.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
11061106
cx,
11071107
MATCH_WILDCARD_FOR_SINGLE_VARIANTS,
11081108
wildcard_span,
1109-
"match on non-exhaustive enum doesn't explicitly match all known variants",
1109+
"wildcard matches only a single variant and will also match any future added variants",
11101110
"try this",
11111111
format_suggestion(x),
11121112
Applicability::MaybeIncorrect,
@@ -1115,9 +1115,9 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
11151115
let mut suggestions: Vec<_> = variants.iter().cloned().map(format_suggestion).collect();
11161116
let message = if adt_def.is_variant_list_non_exhaustive() {
11171117
suggestions.push("_".into());
1118-
"match on non-exhaustive enum doesn't explicitly match all known variants"
1118+
"wildcard matches known variants and will also match future added variants"
11191119
} else {
1120-
"wildcard match will miss any future added variants"
1120+
"wildcard match will also match any future added variants"
11211121
};
11221122

11231123
span_lint_and_sugg(

tests/ui/match_wildcard_for_single_variants.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
error: match on non-exhaustive enum doesn't explicitly match all known variants
1+
error: wildcard matches only a single variant and will also match any future added variants
22
--> $DIR/match_wildcard_for_single_variants.rs:24:13
33
|
44
LL | _ => (),
55
| ^ help: try this: `Self::Rgb(..)`
66
|
77
= note: `-D clippy::match-wildcard-for-single-variants` implied by `-D warnings`
88

9-
error: match on non-exhaustive enum doesn't explicitly match all known variants
9+
error: wildcard matches only a single variant and will also match any future added variants
1010
--> $DIR/match_wildcard_for_single_variants.rs:34:9
1111
|
1212
LL | _ => {},
1313
| ^ help: try this: `Foo::C`
1414

15-
error: match on non-exhaustive enum doesn't explicitly match all known variants
15+
error: wildcard matches only a single variant and will also match any future added variants
1616
--> $DIR/match_wildcard_for_single_variants.rs:44:9
1717
|
1818
LL | _ => {},
1919
| ^ help: try this: `Color::Blue`
2020

21-
error: match on non-exhaustive enum doesn't explicitly match all known variants
21+
error: wildcard matches only a single variant and will also match any future added variants
2222
--> $DIR/match_wildcard_for_single_variants.rs:52:9
2323
|
2424
LL | _ => {},
2525
| ^ help: try this: `Color::Blue`
2626

27-
error: match on non-exhaustive enum doesn't explicitly match all known variants
27+
error: wildcard matches only a single variant and will also match any future added variants
2828
--> $DIR/match_wildcard_for_single_variants.rs:58:9
2929
|
3030
LL | _ => {},
3131
| ^ help: try this: `Color::Blue`
3232

33-
error: match on non-exhaustive enum doesn't explicitly match all known variants
33+
error: wildcard matches only a single variant and will also match any future added variants
3434
--> $DIR/match_wildcard_for_single_variants.rs:75:9
3535
|
3636
LL | &_ => (),
3737
| ^^ help: try this: `Color::Blue`
3838

39-
error: match on non-exhaustive enum doesn't explicitly match all known variants
39+
error: wildcard matches only a single variant and will also match any future added variants
4040
--> $DIR/match_wildcard_for_single_variants.rs:84:9
4141
|
4242
LL | _ => (),
4343
| ^ help: try this: `C::Blue`
4444

45-
error: match on non-exhaustive enum doesn't explicitly match all known variants
45+
error: wildcard matches only a single variant and will also match any future added variants
4646
--> $DIR/match_wildcard_for_single_variants.rs:91:9
4747
|
4848
LL | _ => (),

tests/ui/wildcard_enum_match_arm.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: wildcard match will miss any future added variants
1+
error: wildcard match will also match any future added variants
22
--> $DIR/wildcard_enum_match_arm.rs:39:9
33
|
44
LL | _ => eprintln!("Not red"),
@@ -10,25 +10,25 @@ note: the lint level is defined here
1010
LL | #![deny(clippy::wildcard_enum_match_arm)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

13-
error: wildcard match will miss any future added variants
13+
error: wildcard match will also match any future added variants
1414
--> $DIR/wildcard_enum_match_arm.rs:43:9
1515
|
1616
LL | _not_red => eprintln!("Not red"),
1717
| ^^^^^^^^ help: try this: `_not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan`
1818

19-
error: wildcard match will miss any future added variants
19+
error: wildcard match will also match any future added variants
2020
--> $DIR/wildcard_enum_match_arm.rs:47:9
2121
|
2222
LL | not_red => format!("{:?}", not_red),
2323
| ^^^^^^^ help: try this: `not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan`
2424

25-
error: wildcard match will miss any future added variants
25+
error: wildcard match will also match any future added variants
2626
--> $DIR/wildcard_enum_match_arm.rs:63:9
2727
|
2828
LL | _ => "No red",
2929
| ^ help: try this: `Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan`
3030

31-
error: match on non-exhaustive enum doesn't explicitly match all known variants
31+
error: wildcard matches known variants and will also match future added variants
3232
--> $DIR/wildcard_enum_match_arm.rs:80:9
3333
|
3434
LL | _ => {},

0 commit comments

Comments
 (0)