Skip to content

Commit 586bd3f

Browse files
committed
refactor to avoid potential ICE
1 parent cca9938 commit 586bd3f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

clippy_lints/src/excessive_bools.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,22 @@ impl EarlyLintPass for ExcessiveBools {
141141
return;
142142
}
143143

144-
let struct_bools = variant_data
144+
if let Ok(struct_bools) = variant_data
145145
.fields()
146146
.iter()
147147
.filter(|field| is_bool_ty(&field.ty))
148148
.count()
149-
.try_into()
150-
.unwrap();
151-
if self.max_struct_bools < struct_bools {
149+
.try_into() && self.max_struct_bools < struct_bools
150+
{
152151
span_lint_and_help(
153152
cx,
154153
STRUCT_EXCESSIVE_BOOLS,
155154
item.span,
156155
&format!("more than {} bools in a struct", self.max_struct_bools),
157156
None,
158157
"consider using a state machine or refactoring bools into two-variant enums",
159-
);
160-
}
158+
)
159+
}
161160
},
162161
ItemKind::Impl(box Impl {
163162
of_trait: None, items, ..

0 commit comments

Comments
 (0)