diff options
| author | flip1995 <hello@philkrones.com> | 2019-11-06 18:14:47 +0100 |
|---|---|---|
| committer | flip1995 <hello@philkrones.com> | 2019-11-06 18:14:47 +0100 |
| commit | d3e88a58b9fad8c68e19c7603ec2725ee26bac29 (patch) | |
| tree | b3e9180ee4c3da069c007b7f48843326a64420ea | |
| parent | 0be213bb79c7c476784e707880b2fae4ce5d5af7 (diff) | |
| download | rust-d3e88a58b9fad8c68e19c7603ec2725ee26bac29.tar.gz rust-d3e88a58b9fad8c68e19c7603ec2725ee26bac29.zip | |
Fix ICE #4775
| -rw-r--r-- | clippy_lints/src/loops.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 731dd92c82a..805e609cea6 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -1993,7 +1993,13 @@ fn is_ref_iterable_type(cx: &LateContext<'_, '_>, e: &Expr) -> bool { fn is_iterable_array<'tcx>(ty: Ty<'tcx>, cx: &LateContext<'_, 'tcx>) -> bool { // IntoIterator is currently only implemented for array sizes <= 32 in rustc match ty.kind { - ty::Array(_, n) => (0..=32).contains(&n.eval_usize(cx.tcx, cx.param_env)), + ty::Array(_, n) => { + if let Some(val) = n.try_eval_usize(cx.tcx, cx.param_env) { + (0..=32).contains(&val) + } else { + false + } + }, _ => false, } } |
