Skip to content

Commit ed4952e

Browse files
committed
Add (currently unused) helper routine for skolemizing bound regions.
1 parent 416e629 commit ed4952e

File tree

1 file changed

+22
-2
lines changed
  • src/librustc/middle/infer

1 file changed

+22
-2
lines changed

src/librustc/middle/infer/mod.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ pub struct InferCtxt<'a, 'tcx: 'a> {
9090
RegionVarBindings<'a, 'tcx>,
9191
}
9292

93+
/// A map returned by `skolemize_bound_regions()` indicating the skolemized
94+
/// region that each late-bound region was replaced with.
95+
pub type SkolemizationMap = FnvHashMap<ty::BoundRegion,ty::Region>;
96+
9397
/// Why did we require that the two types be related?
9498
///
9599
/// See `error_reporting.rs` for more details
@@ -698,9 +702,25 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
698702
self.sub(a_is_expected, trace).poly_trait_refs(&*a, &*b).to_ures()
699703
})
700704
}
701-
}
702705

703-
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
706+
pub fn skolemize_bound_regions<T>(&self,
707+
value: &ty::Binder<T>,
708+
snapshot: &CombinedSnapshot)
709+
-> (T, SkolemizationMap)
710+
where T : TypeFoldable<'tcx>
711+
{
712+
let (result_binder, map) = replace_late_bound_regions(self.tcx, value, |br, _| {
713+
self.region_vars.new_skolemized(br, &snapshot.region_vars_snapshot)
714+
});
715+
716+
debug!("skolemize_bound_regions(value={}, result={}, map={})",
717+
value.repr(self.tcx),
718+
result_binder.value.repr(self.tcx),
719+
map.repr(self.tcx));
720+
721+
(result_binder.value, map)
722+
}
723+
704724
pub fn next_ty_var_id(&self, diverging: bool) -> TyVid {
705725
self.type_variables
706726
.borrow_mut()

0 commit comments

Comments
 (0)