Auto merge of #4780 - flip1995:ice_4775, r=phansch

Fix ICE #4775

Fixes #4775

changelog: Fix ICE with const_generics
This commit is contained in:
bors 2019-11-11 06:23:27 +00:00
commit 338f5e6801
2 changed files with 21 additions and 1 deletions

View file

@ -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,
}
}