refactor to avoid potential ICE
This commit is contained in:
parent
cca9938694
commit
586bd3f735
@ -141,14 +141,13 @@ impl EarlyLintPass for ExcessiveBools {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let struct_bools = variant_data
|
if let Ok(struct_bools) = variant_data
|
||||||
.fields()
|
.fields()
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|field| is_bool_ty(&field.ty))
|
.filter(|field| is_bool_ty(&field.ty))
|
||||||
.count()
|
.count()
|
||||||
.try_into()
|
.try_into() && self.max_struct_bools < struct_bools
|
||||||
.unwrap();
|
{
|
||||||
if self.max_struct_bools < struct_bools {
|
|
||||||
span_lint_and_help(
|
span_lint_and_help(
|
||||||
cx,
|
cx,
|
||||||
STRUCT_EXCESSIVE_BOOLS,
|
STRUCT_EXCESSIVE_BOOLS,
|
||||||
@ -156,8 +155,8 @@ impl EarlyLintPass for ExcessiveBools {
|
|||||||
&format!("more than {} bools in a struct", self.max_struct_bools),
|
&format!("more than {} bools in a struct", self.max_struct_bools),
|
||||||
None,
|
None,
|
||||||
"consider using a state machine or refactoring bools into two-variant enums",
|
"consider using a state machine or refactoring bools into two-variant enums",
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ItemKind::Impl(box Impl {
|
ItemKind::Impl(box Impl {
|
||||||
of_trait: None, items, ..
|
of_trait: None, items, ..
|
||||||
|
Loading…
x
Reference in New Issue
Block a user