Skip to content

Commit

Permalink
middle::subst: Better handling of parameter lookup failure
Browse files Browse the repository at this point in the history
  • Loading branch information
bgamari committed Jul 15, 2014
1 parent 741bb1a commit c6c1a22
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/librustc/middle/subst.rs
Expand Up @@ -570,10 +570,22 @@ impl<'a> TypeFolder for SubstFolder<'a> {
// the specialized routine
// `middle::typeck::check::regionmanip::replace_late_regions_in_fn_sig()`.
match r {
ty::ReEarlyBound(_, space, i, _) => {
ty::ReEarlyBound(_, space, i, region_name) => {
match self.substs.regions {
ErasedRegions => ty::ReStatic,
NonerasedRegions(ref regions) => *regions.get(space, i),
NonerasedRegions(ref regions) =>
match regions.opt_get(space, i) {
Some(t) => *t,
None => {
let span = self.span.unwrap_or(DUMMY_SP);
self.tcx().sess.span_bug(
span,
format!("Type parameter out of range \
when substituting in region {} (root type={})",
region_name.as_str(),
self.root_ty.repr(self.tcx())).as_slice());
}
}
}
}
_ => r
Expand Down

0 comments on commit c6c1a22

Please sign in to comment.