Skip to content

Commit

Permalink
Extract skolemize_regions() helper function.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Dec 19, 2014
1 parent ff35eeb commit 885f7ee
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/librustc/middle/infer/higher_ranked/mod.rs
Expand Up @@ -74,17 +74,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C

// Second, we instantiate each bound region in the supertype with a
// fresh concrete region.
let (b_prime, skol_map) = {
replace_late_bound_regions(self.tcx(), b, |br, _| {
let skol =
self.infcx().region_vars.new_skolemized(
br, &snapshot.region_vars_snapshot);
debug!("Bound region {} skolemized to {}",
bound_region_to_string(self.tcx(), "", false, br),
skol);
skol
})
};
let (b_prime, skol_map) = skolemize_regions(self.infcx(), b, snapshot);

debug!("a_prime={}", a_prime.repr(self.tcx()));
debug!("b_prime={}", b_prime.repr(self.tcx()));
Expand Down Expand Up @@ -538,3 +528,23 @@ impl<'a,'tcx> InferCtxtExt<'tcx> for InferCtxt<'a,'tcx> {
region_vars
}
}

fn skolemize_regions<'a,'tcx,HR>(infcx: &InferCtxt<'a,'tcx>,
value: &HR,
snapshot: &CombinedSnapshot)
-> (HR, FnvHashMap<ty::BoundRegion,ty::Region>)
where HR : HigherRankedFoldable<'tcx>
{
replace_late_bound_regions(infcx.tcx, value, |br, _| {
let skol =
infcx.region_vars.new_skolemized(
br,
&snapshot.region_vars_snapshot);

debug!("Bound region {} skolemized to {}",
bound_region_to_string(infcx.tcx, "", false, br),
skol);

skol
})
}

0 comments on commit 885f7ee

Please sign in to comment.