@@ -164,7 +164,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
164164 . map ( |( & skol, & ( br, ref regions) ) | {
165165 let representative =
166166 regions. iter ( )
167- . filter ( |r| !skol_resolution_map. contains_key ( r) )
167+ . filter ( |& & r| !skol_resolution_map. contains_key ( r) )
168168 . cloned ( )
169169 . next ( )
170170 . unwrap_or_else ( || { // [1]
@@ -268,9 +268,9 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
268268 snapshot : & CombinedSnapshot ,
269269 debruijn : ty:: DebruijnIndex ,
270270 new_vars : & [ ty:: RegionVid ] ,
271- a_map : & FnvHashMap < ty:: BoundRegion , ty:: Region > ,
272- r0 : ty:: Region )
273- -> ty:: Region {
271+ a_map : & FnvHashMap < ty:: BoundRegion , & ' tcx ty:: Region > ,
272+ r0 : & ' tcx ty:: Region )
273+ -> & ' tcx ty:: Region {
274274 // Regions that pre-dated the LUB computation stay as they are.
275275 if !is_var_in_set ( new_vars, r0) {
276276 assert ! ( !r0. is_bound( ) ) ;
@@ -301,7 +301,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
301301 debug ! ( "generalize_region(r0={:?}): \
302302 replacing with {:?}, tainted={:?}",
303303 r0, * a_br, tainted) ;
304- return ty:: ReLateBound ( debruijn, * a_br) ;
304+ return infcx . tcx . mk_region ( ty:: ReLateBound ( debruijn, * a_br) ) ;
305305 }
306306 }
307307
@@ -364,10 +364,12 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
364364 snapshot : & CombinedSnapshot ,
365365 debruijn : ty:: DebruijnIndex ,
366366 new_vars : & [ ty:: RegionVid ] ,
367- a_map : & FnvHashMap < ty:: BoundRegion , ty:: Region > ,
367+ a_map : & FnvHashMap < ty:: BoundRegion ,
368+ & ' tcx ty:: Region > ,
368369 a_vars : & [ ty:: RegionVid ] ,
369370 b_vars : & [ ty:: RegionVid ] ,
370- r0 : ty:: Region ) -> ty:: Region {
371+ r0 : & ' tcx ty:: Region )
372+ -> & ' tcx ty:: Region {
371373 if !is_var_in_set ( new_vars, r0) {
372374 assert ! ( !r0. is_bound( ) ) ;
373375 return r0;
@@ -419,7 +421,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
419421
420422 if a_r. is_some ( ) && b_r. is_some ( ) && only_new_vars {
421423 // Related to exactly one bound variable from each fn:
422- return rev_lookup ( span, a_map, a_r. unwrap ( ) ) ;
424+ return rev_lookup ( infcx , span, a_map, a_r. unwrap ( ) ) ;
423425 } else if a_r. is_none ( ) && b_r. is_none ( ) {
424426 // Not related to bound variables from either fn:
425427 assert ! ( !r0. is_bound( ) ) ;
@@ -430,13 +432,14 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
430432 }
431433 }
432434
433- fn rev_lookup ( span : Span ,
434- a_map : & FnvHashMap < ty:: BoundRegion , ty:: Region > ,
435- r : ty:: Region ) -> ty:: Region
435+ fn rev_lookup < ' a , ' gcx , ' tcx > ( infcx : & InferCtxt < ' a , ' gcx , ' tcx > ,
436+ span : Span ,
437+ a_map : & FnvHashMap < ty:: BoundRegion , & ' tcx ty:: Region > ,
438+ r : & ' tcx ty:: Region ) -> & ' tcx ty:: Region
436439 {
437440 for ( a_br, a_r) in a_map {
438441 if * a_r == r {
439- return ty:: ReLateBound ( ty:: DebruijnIndex :: new ( 1 ) , * a_br) ;
442+ return infcx . tcx . mk_region ( ty:: ReLateBound ( ty:: DebruijnIndex :: new ( 1 ) , * a_br) ) ;
440443 }
441444 }
442445 span_bug ! (
@@ -445,19 +448,21 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
445448 r) ;
446449 }
447450
448- fn fresh_bound_variable ( infcx : & InferCtxt , debruijn : ty:: DebruijnIndex ) -> ty:: Region {
451+ fn fresh_bound_variable < ' a , ' gcx , ' tcx > ( infcx : & InferCtxt < ' a , ' gcx , ' tcx > ,
452+ debruijn : ty:: DebruijnIndex )
453+ -> & ' tcx ty:: Region {
449454 infcx. region_vars . new_bound ( debruijn)
450455 }
451456 }
452457}
453458
454459fn var_ids < ' a , ' gcx , ' tcx > ( fields : & CombineFields < ' a , ' gcx , ' tcx > ,
455- map : & FnvHashMap < ty:: BoundRegion , ty:: Region > )
460+ map : & FnvHashMap < ty:: BoundRegion , & ' tcx ty:: Region > )
456461 -> Vec < ty:: RegionVid > {
457462 map. iter ( )
458- . map ( |( _, r) | match * r {
463+ . map ( |( _, & r) | match * r {
459464 ty:: ReVar ( r) => { r }
460- r => {
465+ _ => {
461466 span_bug ! (
462467 fields. trace. origin. span( ) ,
463468 "found non-region-vid: {:?}" ,
@@ -467,8 +472,8 @@ fn var_ids<'a, 'gcx, 'tcx>(fields: &CombineFields<'a, 'gcx, 'tcx>,
467472 . collect ( )
468473}
469474
470- fn is_var_in_set ( new_vars : & [ ty:: RegionVid ] , r : ty:: Region ) -> bool {
471- match r {
475+ fn is_var_in_set ( new_vars : & [ ty:: RegionVid ] , r : & ty:: Region ) -> bool {
476+ match * r {
472477 ty:: ReVar ( ref v) => new_vars. iter ( ) . any ( |x| x == v) ,
473478 _ => false
474479 }
@@ -479,13 +484,13 @@ fn fold_regions_in<'a, 'gcx, 'tcx, T, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
479484 mut fldr : F )
480485 -> T
481486 where T : TypeFoldable < ' tcx > ,
482- F : FnMut ( ty:: Region , ty:: DebruijnIndex ) -> ty:: Region ,
487+ F : FnMut ( & ' tcx ty:: Region , ty:: DebruijnIndex ) -> & ' tcx ty:: Region ,
483488{
484489 tcx. fold_regions ( unbound_value, & mut false , |region, current_depth| {
485490 // we should only be encountering "escaping" late-bound regions here,
486491 // because the ones at the current level should have been replaced
487492 // with fresh variables
488- assert ! ( match region {
493+ assert ! ( match * region {
489494 ty:: ReLateBound ( ..) => false ,
490495 _ => true
491496 } ) ;
@@ -497,9 +502,9 @@ fn fold_regions_in<'a, 'gcx, 'tcx, T, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
497502impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
498503 fn tainted_regions ( & self ,
499504 snapshot : & CombinedSnapshot ,
500- r : ty:: Region ,
505+ r : & ' tcx ty:: Region ,
501506 directions : TaintDirections )
502- -> FnvHashSet < ty:: Region > {
507+ -> FnvHashSet < & ' tcx ty:: Region > {
503508 self . region_vars . tainted ( & snapshot. region_vars_snapshot , r, directions)
504509 }
505510
@@ -596,7 +601,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
596601 pub fn skolemize_late_bound_regions < T > ( & self ,
597602 binder : & ty:: Binder < T > ,
598603 snapshot : & CombinedSnapshot )
599- -> ( T , SkolemizationMap )
604+ -> ( T , SkolemizationMap < ' tcx > )
600605 where T : TypeFoldable < ' tcx >
601606 {
602607 let ( result, map) = self . tcx . replace_late_bound_regions ( binder, |br| {
@@ -619,7 +624,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
619624 pub fn leak_check ( & self ,
620625 overly_polymorphic : bool ,
621626 span : Span ,
622- skol_map : & SkolemizationMap ,
627+ skol_map : & SkolemizationMap < ' tcx > ,
623628 snapshot : & CombinedSnapshot )
624629 -> RelateResult < ' tcx , ( ) >
625630 {
@@ -673,7 +678,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
673678 for & tainted_region in & incoming_taints {
674679 // Each skolemized should only be relatable to itself
675680 // or new variables:
676- match tainted_region {
681+ match * tainted_region {
677682 ty:: ReVar ( vid) => {
678683 if new_vars. contains ( & vid) {
679684 warnings. extend (
@@ -742,7 +747,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
742747 /// to the depth of the predicate, in this case 1, so that the final
743748 /// predicate is `for<'a> &'a int : Clone`.
744749 pub fn plug_leaks < T > ( & self ,
745- skol_map : SkolemizationMap ,
750+ skol_map : SkolemizationMap < ' tcx > ,
746751 snapshot : & CombinedSnapshot ,
747752 value : & T ) -> T
748753 where T : TypeFoldable < ' tcx >
@@ -755,7 +760,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
755760 // region back to the `ty::BoundRegion` that it originally
756761 // represented. Because `leak_check` passed, we know that
757762 // these taint sets are mutually disjoint.
758- let inv_skol_map: FnvHashMap < ty:: Region , ty:: BoundRegion > =
763+ let inv_skol_map: FnvHashMap < & ' tcx ty:: Region , ty:: BoundRegion > =
759764 skol_map
760765 . iter ( )
761766 . flat_map ( |( & skol_br, & skol) | {
@@ -794,15 +799,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
794799 // (which ought not to escape the snapshot, but we
795800 // don't check that) or itself
796801 assert ! (
797- match r {
802+ match * r {
798803 ty:: ReVar ( _) => true ,
799804 ty:: ReSkolemized ( _, ref br1) => br == br1,
800805 _ => false ,
801806 } ,
802807 "leak-check would have us replace {:?} with {:?}" ,
803808 r, br) ;
804809
805- ty:: ReLateBound ( ty:: DebruijnIndex :: new ( current_depth - 1 ) , br. clone ( ) )
810+ self . tcx . mk_region ( ty:: ReLateBound (
811+ ty:: DebruijnIndex :: new ( current_depth - 1 ) , br. clone ( ) ) )
806812 }
807813 }
808814 } ) ;
@@ -826,7 +832,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
826832 ///
827833 /// Note: popping also occurs implicitly as part of `leak_check`.
828834 pub fn pop_skolemized ( & self ,
829- skol_map : SkolemizationMap ,
835+ skol_map : SkolemizationMap < ' tcx > ,
830836 snapshot : & CombinedSnapshot )
831837 {
832838 debug ! ( "pop_skolemized({:?})" , skol_map) ;
0 commit comments