mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
Auto merge of #11552 - jonboh:ice_threshold_0_enum_variants, r=y21
prevent ice when threshold is 0 and enum has no variants changelog: [`enum_variant_names`]: prevent ice when threshold is 0 and enum has no variants r? `@y21` Fixes the same ice issue raised during review of https://github.com/rust-lang/rust-clippy/pull/11496
This commit is contained in:
commit
aa137a7e57
3 changed files with 8 additions and 1 deletions
|
@ -167,7 +167,10 @@ fn check_variant(cx: &LateContext<'_>, threshold: u64, def: &EnumDef<'_>, item_n
|
|||
return;
|
||||
}
|
||||
|
||||
let first = &def.variants[0].ident.name.as_str();
|
||||
let first = match def.variants.first() {
|
||||
Some(variant) => variant.ident.name.as_str(),
|
||||
None => return,
|
||||
};
|
||||
let mut pre = camel_case_split(first);
|
||||
let mut post = pre.clone();
|
||||
post.reverse();
|
||||
|
|
1
tests/ui-toml/enum_variants_threshold0/clippy.toml
Normal file
1
tests/ui-toml/enum_variants_threshold0/clippy.toml
Normal file
|
@ -0,0 +1 @@
|
|||
enum-variant-name-threshold = 0
|
|
@ -0,0 +1,3 @@
|
|||
enum Actions {}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in a new issue