Skip to content

Commit d3e88a5

Browse files
committed
Fix ICE #4775
1 parent 0be213b commit d3e88a5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

clippy_lints/src/loops.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,13 @@ fn is_ref_iterable_type(cx: &LateContext<'_, '_>, e: &Expr) -> bool {
19931993
fn is_iterable_array<'tcx>(ty: Ty<'tcx>, cx: &LateContext<'_, 'tcx>) -> bool {
19941994
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
19951995
match ty.kind {
1996-
ty::Array(_, n) => (0..=32).contains(&n.eval_usize(cx.tcx, cx.param_env)),
1996+
ty::Array(_, n) => {
1997+
if let Some(val) = n.try_eval_usize(cx.tcx, cx.param_env) {
1998+
(0..=32).contains(&val)
1999+
} else {
2000+
false
2001+
}
2002+
},
19972003
_ => false,
19982004
}
19992005
}

0 commit comments

Comments
 (0)