prevent ice when threshold is 0 and enum has no variants

This commit is contained in:
jonboh 2023-09-22 17:18:49 +02:00
parent 33f084ef78
commit f3a27d20f6

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.get(0) {
Some(variant) => variant.ident.name.as_str(),
None => return,
};
let mut pre = camel_case_split(first);
let mut post = pre.clone();
post.reverse();