about summary refs log tree commit diff
diff options
context:
space:
mode:
authorflip1995 <hello@philkrones.com>2019-11-06 18:14:47 +0100
committerflip1995 <hello@philkrones.com>2019-11-06 18:14:47 +0100
commitd3e88a58b9fad8c68e19c7603ec2725ee26bac29 (patch)
treeb3e9180ee4c3da069c007b7f48843326a64420ea
parent0be213bb79c7c476784e707880b2fae4ce5d5af7 (diff)
downloadrust-d3e88a58b9fad8c68e19c7603ec2725ee26bac29.tar.gz
rust-d3e88a58b9fad8c68e19c7603ec2725ee26bac29.zip
Fix ICE #4775
-rw-r--r--clippy_lints/src/loops.rs8
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,
     }
 }