Skip to content

Commit f3a27d2

Browse files
committed
prevent ice when threshold is 0 and enum has no variants
1 parent 33f084e commit f3a27d2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clippy_lints/src/enum_variants.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ fn check_variant(cx: &LateContext<'_>, threshold: u64, def: &EnumDef<'_>, item_n
167167
return;
168168
}
169169

170-
let first = &def.variants[0].ident.name.as_str();
170+
let first = match &def.variants.get(0) {
171+
Some(variant) => variant.ident.name.as_str(),
172+
None => return,
173+
};
171174
let mut pre = camel_case_split(first);
172175
let mut post = pre.clone();
173176
post.reverse();

0 commit comments

Comments
 (0)