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:
bors 2023-09-24 20:58:58 +00:00
commit aa137a7e57
3 changed files with 8 additions and 1 deletions

View file

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

View file

@ -0,0 +1 @@
enum-variant-name-threshold = 0

View file

@ -0,0 +1,3 @@
enum Actions {}
fn main() {}