@@ -410,7 +410,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
410410 pub fn erase_late_bound_regions < T > ( self , value : & Binder < T > ) -> T
411411 where T : TypeFoldable < ' tcx >
412412 {
413- self . replace_late_bound_regions ( value, |_| self . mk_region ( ty :: ReErased ) ) . 0
413+ self . replace_late_bound_regions ( value, |_| self . types . re_erased ) . 0
414414 }
415415
416416 /// Rewrite any late-bound regions so that they are anonymous. Region numbers are
@@ -538,7 +538,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
538538 // whenever a substitution occurs.
539539 match * r {
540540 ty:: ReLateBound ( ..) => r,
541- _ => self . tcx ( ) . mk_region ( ty :: ReErased )
541+ _ => self . tcx ( ) . types . re_erased
542542 }
543543 }
544544 }
@@ -565,6 +565,22 @@ pub fn shift_region(region: ty::Region, amount: u32) -> ty::Region {
565565 }
566566}
567567
568+ pub fn shift_region_ref < ' a , ' gcx , ' tcx > (
569+ tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
570+ region : & ' tcx ty:: Region ,
571+ amount : u32 )
572+ -> & ' tcx ty:: Region
573+ {
574+ match region {
575+ & ty:: ReLateBound ( debruijn, br) if amount > 0 => {
576+ tcx. mk_region ( ty:: ReLateBound ( debruijn. shifted ( amount) , br) )
577+ }
578+ _ => {
579+ region
580+ }
581+ }
582+ }
583+
568584pub fn shift_regions < ' a , ' gcx , ' tcx , T > ( tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
569585 amount : u32 , value : & T ) -> T
570586 where T : TypeFoldable < ' tcx >
@@ -573,7 +589,7 @@ pub fn shift_regions<'a, 'gcx, 'tcx, T>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
573589 value, amount) ;
574590
575591 value. fold_with ( & mut RegionFolder :: new ( tcx, & mut false , & mut |region, _current_depth| {
576- tcx . mk_region ( shift_region ( * region, amount) )
592+ shift_region_ref ( tcx , region, amount)
577593 } ) )
578594}
579595
0 commit comments