-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lintsC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesT-ASTType: Requires working with the ASTType: Requires working with the ASTgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
When matching an enum, if there is only one variant left, suggest using that instead of the wildcard pattern.
For example, for this enum:
enum E {
First,
Second,
Third,
}
When matching it like this:
match e {
E::First => {}
E::Second => {}
_ => {}
}
Suggest the following replacement:
match e {
E::First => {}
E::Second => {}
E::Third => {}
}
The lint should be under the pedantic
category.
Note that for #[non_exhaustive]
enums the wildcard arm should be kept.
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesT-ASTType: Requires working with the ASTType: Requires working with the ASTgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy