Skip to content

Commit aa137a7

Browse files
committed
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 #11496
2 parents 94fc431 + 0433e45 commit aa137a7

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-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.first() {
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();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enum-variant-name-threshold = 0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
enum Actions {}
2+
3+
fn main() {}

0 commit comments

Comments
 (0)