diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-12-12 06:37:42 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-12-19 03:29:30 -0500 |
| commit | ed4952ef392952dc4a7d0241386daf575dea5d6e (patch) | |
| tree | cab4a20cbb3bc4e4d70db618fe32f8e179204e2a | |
| parent | 416e62924e200eb75dff4b7d622b5aa7ea8b691a (diff) | |
| download | rust-ed4952ef392952dc4a7d0241386daf575dea5d6e.tar.gz rust-ed4952ef392952dc4a7d0241386daf575dea5d6e.zip | |
Add (currently unused) helper routine for skolemizing bound regions.
| -rw-r--r-- | src/librustc/middle/infer/mod.rs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index c58b99e0ae2..4eda0d01ebb 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -90,6 +90,10 @@ pub struct InferCtxt<'a, 'tcx: 'a> { RegionVarBindings<'a, 'tcx>, } +/// A map returned by `skolemize_bound_regions()` indicating the skolemized +/// region that each late-bound region was replaced with. +pub type SkolemizationMap = FnvHashMap<ty::BoundRegion,ty::Region>; + /// Why did we require that the two types be related? /// /// See `error_reporting.rs` for more details @@ -698,9 +702,25 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { self.sub(a_is_expected, trace).poly_trait_refs(&*a, &*b).to_ures() }) } -} -impl<'a, 'tcx> InferCtxt<'a, 'tcx> { + pub fn skolemize_bound_regions<T>(&self, + value: &ty::Binder<T>, + snapshot: &CombinedSnapshot) + -> (T, SkolemizationMap) + where T : TypeFoldable<'tcx> + { + let (result_binder, map) = replace_late_bound_regions(self.tcx, value, |br, _| { + self.region_vars.new_skolemized(br, &snapshot.region_vars_snapshot) + }); + + debug!("skolemize_bound_regions(value={}, result={}, map={})", + value.repr(self.tcx), + result_binder.value.repr(self.tcx), + map.repr(self.tcx)); + + (result_binder.value, map) + } + pub fn next_ty_var_id(&self, diverging: bool) -> TyVid { self.type_variables .borrow_mut() |
