@@ -90,6 +90,10 @@ pub struct InferCtxt<'a, 'tcx: 'a> {
90
90
RegionVarBindings < ' a , ' tcx > ,
91
91
}
92
92
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
+
93
97
/// Why did we require that the two types be related?
94
98
///
95
99
/// See `error_reporting.rs` for more details
@@ -698,9 +702,25 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
698
702
self . sub ( a_is_expected, trace) . poly_trait_refs ( & * a, & * b) . to_ures ( )
699
703
} )
700
704
}
701
- }
702
705
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
+
704
724
pub fn next_ty_var_id ( & self , diverging : bool ) -> TyVid {
705
725
self . type_variables
706
726
. borrow_mut ( )
0 commit comments