@@ -29,6 +29,7 @@ use ty::{self, TyCtxt};
2929use ty:: { ReEarlyBound , ReEmpty , ReErased , ReFree , ReStatic } ;
3030use ty:: { ReLateBound , ReScope , ReSkolemized , ReVar } ;
3131use ty:: { Region , RegionVid } ;
32+ use ty:: fold:: TypeFoldable ;
3233
3334mod graphviz;
3435
@@ -110,11 +111,15 @@ struct LexicalResolver<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
110111}
111112
112113impl < ' cx , ' gcx , ' tcx > LexicalResolver < ' cx , ' gcx , ' tcx > {
114+ fn tcx ( & self ) -> TyCtxt < ' cx , ' gcx , ' tcx > {
115+ self . region_rels . tcx
116+ }
117+
113118 fn infer_variable_values (
114119 & mut self ,
115120 errors : & mut Vec < RegionResolutionError < ' tcx > > ,
116121 ) -> LexicalRegionResolutions < ' tcx > {
117- let mut var_data = self . construct_var_data ( self . region_rels . tcx ) ;
122+ let mut var_data = self . construct_var_data ( self . tcx ( ) ) ;
118123
119124 // Dorky hack to cause `dump_constraints` to only get called
120125 // if debug mode is enabled:
@@ -255,7 +260,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
255260 }
256261
257262 fn lub_concrete_regions ( & self , a : Region < ' tcx > , b : Region < ' tcx > ) -> Region < ' tcx > {
258- let tcx = self . region_rels . tcx ;
263+ let tcx = self . tcx ( ) ;
259264 match ( a, b) {
260265 ( & ty:: ReCanonical ( ..) , _)
261266 | ( _, & ty:: ReCanonical ( ..) )
@@ -296,10 +301,10 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
296301 let fr_scope = match ( a, b) {
297302 ( & ReEarlyBound ( ref br) , _) | ( _, & ReEarlyBound ( ref br) ) => self . region_rels
298303 . region_scope_tree
299- . early_free_scope ( self . region_rels . tcx , br) ,
304+ . early_free_scope ( self . tcx ( ) , br) ,
300305 ( & ReFree ( ref fr) , _) | ( _, & ReFree ( ref fr) ) => self . region_rels
301306 . region_scope_tree
302- . free_scope ( self . region_rels . tcx , fr) ,
307+ . free_scope ( self . tcx ( ) , fr) ,
303308 _ => bug ! ( ) ,
304309 } ;
305310 let r_id = self . region_rels
@@ -408,7 +413,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
408413
409414 for verify in & self . data . verifys {
410415 debug ! ( "collect_errors: verify={:?}" , verify) ;
411- let sub = var_data. normalize ( verify. region ) ;
416+ let sub = var_data. normalize ( self . tcx ( ) , verify. region ) ;
412417
413418 // This was an inference variable which didn't get
414419 // constrained, therefore it can be assume to hold.
@@ -712,11 +717,11 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
712717 ) -> bool {
713718 match bound {
714719 VerifyBound :: AnyRegion ( rs) => rs. iter ( )
715- . map ( |& r| var_values. normalize ( r) )
720+ . map ( |& r| var_values. normalize ( self . tcx ( ) , r) )
716721 . any ( |r| self . region_rels . is_subregion_of ( min, r) ) ,
717722
718723 VerifyBound :: AllRegions ( rs) => rs. iter ( )
719- . map ( |& r| var_values. normalize ( r) )
724+ . map ( |& r| var_values. normalize ( self . tcx ( ) , r) )
720725 . all ( |r| self . region_rels . is_subregion_of ( min, r) ) ,
721726
722727 VerifyBound :: AnyBound ( bs) => bs. iter ( ) . any ( |b| self . bound_is_met ( b, var_values, min) ) ,
@@ -733,11 +738,14 @@ impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> {
733738}
734739
735740impl < ' tcx > LexicalRegionResolutions < ' tcx > {
736- fn normalize ( & self , r : ty:: Region < ' tcx > ) -> ty:: Region < ' tcx > {
737- match * r {
738- ty:: ReVar ( rid) => self . resolve_var ( rid) ,
741+ fn normalize < T > ( & self , tcx : TyCtxt < ' _ , ' _ , ' tcx > , value : T ) -> T
742+ where
743+ T : TypeFoldable < ' tcx > ,
744+ {
745+ tcx. fold_regions ( & value, & mut false , |r, _db| match r {
746+ ty:: ReVar ( rid) => self . resolve_var ( * rid) ,
739747 _ => r,
740- }
748+ } )
741749 }
742750
743751 fn value ( & self , rid : RegionVid ) -> & VarValue < ' tcx > {
0 commit comments