Delay ICE in fold_region so feature gate has chance to stop compilation cleanly.

This commit is contained in:
Felix S. Klock II 2019-05-24 13:56:26 +02:00
parent 46805805ab
commit 698e50f985
1 changed files with 5 additions and 4 deletions

View File

@ -479,21 +479,22 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx> {
// the specialized routine `ty::replace_late_regions()`.
match *r {
ty::ReEarlyBound(data) => {
let r = self.substs.get(data.index as usize).map(|k| k.unpack());
match r {
let rk = self.substs.get(data.index as usize).map(|k| k.unpack());
match rk {
Some(UnpackedKind::Lifetime(lt)) => {
self.shift_region_through_binders(lt)
}
_ => {
let span = self.span.unwrap_or(DUMMY_SP);
span_bug!(
span,
let msg = format!(
"Region parameter out of range \
when substituting in region {} (root type={:?}) \
(index={})",
data.name,
self.root_ty,
data.index);
self.tcx.sess.delay_span_bug(span, &msg);
r
}
}
}