Add missing space when expanding a struct-like variant (#15096)
In `wildcard_enum_match_arm`, expanding a variant with struct-like fields was missing a space between the variant name and the opening bracket. Also, add a test for tuple-like variants with only one field, as those are expanded as `VariantName(_)` instead of `VariantName(..)`. changelog: none
This commit is contained in:
commit
76118ec84e
4 changed files with 39 additions and 3 deletions
|
|
@ -140,7 +140,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
|
|||
Some(CtorKind::Fn) if variant.fields.len() == 1 => "(_)",
|
||||
Some(CtorKind::Fn) => "(..)",
|
||||
Some(CtorKind::Const) => "",
|
||||
None => "{ .. }",
|
||||
None => " { .. }",
|
||||
}
|
||||
)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -90,6 +90,21 @@ fn main() {
|
|||
_ => {},
|
||||
}
|
||||
|
||||
{
|
||||
pub enum Enum {
|
||||
A,
|
||||
B,
|
||||
C(u8),
|
||||
D(u8, u8),
|
||||
E { e: u8 },
|
||||
};
|
||||
match Enum::A {
|
||||
Enum::A => (),
|
||||
Enum::B | Enum::C(_) | Enum::D(..) | Enum::E { .. } => (),
|
||||
//~^ wildcard_enum_match_arm
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
#![allow(clippy::manual_non_exhaustive)]
|
||||
pub enum Enum {
|
||||
|
|
|
|||
|
|
@ -90,6 +90,21 @@ fn main() {
|
|||
_ => {},
|
||||
}
|
||||
|
||||
{
|
||||
pub enum Enum {
|
||||
A,
|
||||
B,
|
||||
C(u8),
|
||||
D(u8, u8),
|
||||
E { e: u8 },
|
||||
};
|
||||
match Enum::A {
|
||||
Enum::A => (),
|
||||
_ => (),
|
||||
//~^ wildcard_enum_match_arm
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
#![allow(clippy::manual_non_exhaustive)]
|
||||
pub enum Enum {
|
||||
|
|
|
|||
|
|
@ -37,14 +37,20 @@ LL | _ => {},
|
|||
error: wildcard match will also match any future added variants
|
||||
--> tests/ui/wildcard_enum_match_arm.rs:103:13
|
||||
|
|
||||
LL | _ => (),
|
||||
| ^ help: try: `Enum::B | Enum::C(_) | Enum::D(..) | Enum::E { .. }`
|
||||
|
||||
error: wildcard match will also match any future added variants
|
||||
--> tests/ui/wildcard_enum_match_arm.rs:118:13
|
||||
|
|
||||
LL | _ => (),
|
||||
| ^ help: try: `Enum::B | Enum::__Private`
|
||||
|
||||
error: wildcard match will also match any future added variants
|
||||
--> tests/ui/wildcard_enum_match_arm.rs:118:9
|
||||
--> tests/ui/wildcard_enum_match_arm.rs:133:9
|
||||
|
|
||||
LL | r#type => {},
|
||||
| ^^^^^^ help: try: `r#type @ Foo::B | r#type @ Foo::C`
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue