@@ -164,7 +164,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
164
164
. map ( |( & skol, & ( br, ref regions) ) | {
165
165
let representative =
166
166
regions. iter ( )
167
- . filter ( |r| !skol_resolution_map. contains_key ( r) )
167
+ . filter ( |& & r| !skol_resolution_map. contains_key ( r) )
168
168
. cloned ( )
169
169
. next ( )
170
170
. unwrap_or_else ( || { // [1]
@@ -268,9 +268,9 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
268
268
snapshot : & CombinedSnapshot ,
269
269
debruijn : ty:: DebruijnIndex ,
270
270
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 {
274
274
// Regions that pre-dated the LUB computation stay as they are.
275
275
if !is_var_in_set ( new_vars, r0) {
276
276
assert ! ( !r0. is_bound( ) ) ;
@@ -301,7 +301,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
301
301
debug ! ( "generalize_region(r0={:?}): \
302
302
replacing with {:?}, tainted={:?}",
303
303
r0, * a_br, tainted) ;
304
- return ty:: ReLateBound ( debruijn, * a_br) ;
304
+ return infcx . tcx . mk_region ( ty:: ReLateBound ( debruijn, * a_br) ) ;
305
305
}
306
306
}
307
307
@@ -364,10 +364,12 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
364
364
snapshot : & CombinedSnapshot ,
365
365
debruijn : ty:: DebruijnIndex ,
366
366
new_vars : & [ ty:: RegionVid ] ,
367
- a_map : & FnvHashMap < ty:: BoundRegion , ty:: Region > ,
367
+ a_map : & FnvHashMap < ty:: BoundRegion ,
368
+ & ' tcx ty:: Region > ,
368
369
a_vars : & [ ty:: RegionVid ] ,
369
370
b_vars : & [ ty:: RegionVid ] ,
370
- r0 : ty:: Region ) -> ty:: Region {
371
+ r0 : & ' tcx ty:: Region )
372
+ -> & ' tcx ty:: Region {
371
373
if !is_var_in_set ( new_vars, r0) {
372
374
assert ! ( !r0. is_bound( ) ) ;
373
375
return r0;
@@ -419,7 +421,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
419
421
420
422
if a_r. is_some ( ) && b_r. is_some ( ) && only_new_vars {
421
423
// 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 ( ) ) ;
423
425
} else if a_r. is_none ( ) && b_r. is_none ( ) {
424
426
// Not related to bound variables from either fn:
425
427
assert ! ( !r0. is_bound( ) ) ;
@@ -430,13 +432,14 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
430
432
}
431
433
}
432
434
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
436
439
{
437
440
for ( a_br, a_r) in a_map {
438
441
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) ) ;
440
443
}
441
444
}
442
445
span_bug ! (
@@ -445,19 +448,21 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
445
448
r) ;
446
449
}
447
450
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 {
449
454
infcx. region_vars . new_bound ( debruijn)
450
455
}
451
456
}
452
457
}
453
458
454
459
fn 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 > )
456
461
-> Vec < ty:: RegionVid > {
457
462
map. iter ( )
458
- . map ( |( _, r) | match * r {
463
+ . map ( |( _, & r) | match * r {
459
464
ty:: ReVar ( r) => { r }
460
- r => {
465
+ _ => {
461
466
span_bug ! (
462
467
fields. trace. origin. span( ) ,
463
468
"found non-region-vid: {:?}" ,
@@ -467,8 +472,8 @@ fn var_ids<'a, 'gcx, 'tcx>(fields: &CombineFields<'a, 'gcx, 'tcx>,
467
472
. collect ( )
468
473
}
469
474
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 {
472
477
ty:: ReVar ( ref v) => new_vars. iter ( ) . any ( |x| x == v) ,
473
478
_ => false
474
479
}
@@ -479,13 +484,13 @@ fn fold_regions_in<'a, 'gcx, 'tcx, T, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
479
484
mut fldr : F )
480
485
-> T
481
486
where T : TypeFoldable < ' tcx > ,
482
- F : FnMut ( ty:: Region , ty:: DebruijnIndex ) -> ty:: Region ,
487
+ F : FnMut ( & ' tcx ty:: Region , ty:: DebruijnIndex ) -> & ' tcx ty:: Region ,
483
488
{
484
489
tcx. fold_regions ( unbound_value, & mut false , |region, current_depth| {
485
490
// we should only be encountering "escaping" late-bound regions here,
486
491
// because the ones at the current level should have been replaced
487
492
// with fresh variables
488
- assert ! ( match region {
493
+ assert ! ( match * region {
489
494
ty:: ReLateBound ( ..) => false ,
490
495
_ => true
491
496
} ) ;
@@ -497,9 +502,9 @@ fn fold_regions_in<'a, 'gcx, 'tcx, T, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
497
502
impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
498
503
fn tainted_regions ( & self ,
499
504
snapshot : & CombinedSnapshot ,
500
- r : ty:: Region ,
505
+ r : & ' tcx ty:: Region ,
501
506
directions : TaintDirections )
502
- -> FnvHashSet < ty:: Region > {
507
+ -> FnvHashSet < & ' tcx ty:: Region > {
503
508
self . region_vars . tainted ( & snapshot. region_vars_snapshot , r, directions)
504
509
}
505
510
@@ -596,7 +601,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
596
601
pub fn skolemize_late_bound_regions < T > ( & self ,
597
602
binder : & ty:: Binder < T > ,
598
603
snapshot : & CombinedSnapshot )
599
- -> ( T , SkolemizationMap )
604
+ -> ( T , SkolemizationMap < ' tcx > )
600
605
where T : TypeFoldable < ' tcx >
601
606
{
602
607
let ( result, map) = self . tcx . replace_late_bound_regions ( binder, |br| {
@@ -619,7 +624,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
619
624
pub fn leak_check ( & self ,
620
625
overly_polymorphic : bool ,
621
626
span : Span ,
622
- skol_map : & SkolemizationMap ,
627
+ skol_map : & SkolemizationMap < ' tcx > ,
623
628
snapshot : & CombinedSnapshot )
624
629
-> RelateResult < ' tcx , ( ) >
625
630
{
@@ -673,7 +678,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
673
678
for & tainted_region in & incoming_taints {
674
679
// Each skolemized should only be relatable to itself
675
680
// or new variables:
676
- match tainted_region {
681
+ match * tainted_region {
677
682
ty:: ReVar ( vid) => {
678
683
if new_vars. contains ( & vid) {
679
684
warnings. extend (
@@ -742,7 +747,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
742
747
/// to the depth of the predicate, in this case 1, so that the final
743
748
/// predicate is `for<'a> &'a int : Clone`.
744
749
pub fn plug_leaks < T > ( & self ,
745
- skol_map : SkolemizationMap ,
750
+ skol_map : SkolemizationMap < ' tcx > ,
746
751
snapshot : & CombinedSnapshot ,
747
752
value : & T ) -> T
748
753
where T : TypeFoldable < ' tcx >
@@ -755,7 +760,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
755
760
// region back to the `ty::BoundRegion` that it originally
756
761
// represented. Because `leak_check` passed, we know that
757
762
// 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 > =
759
764
skol_map
760
765
. iter ( )
761
766
. flat_map ( |( & skol_br, & skol) | {
@@ -794,15 +799,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
794
799
// (which ought not to escape the snapshot, but we
795
800
// don't check that) or itself
796
801
assert ! (
797
- match r {
802
+ match * r {
798
803
ty:: ReVar ( _) => true ,
799
804
ty:: ReSkolemized ( _, ref br1) => br == br1,
800
805
_ => false ,
801
806
} ,
802
807
"leak-check would have us replace {:?} with {:?}" ,
803
808
r, br) ;
804
809
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 ( ) ) )
806
812
}
807
813
}
808
814
} ) ;
@@ -826,7 +832,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
826
832
///
827
833
/// Note: popping also occurs implicitly as part of `leak_check`.
828
834
pub fn pop_skolemized ( & self ,
829
- skol_map : SkolemizationMap ,
835
+ skol_map : SkolemizationMap < ' tcx > ,
830
836
snapshot : & CombinedSnapshot )
831
837
{
832
838
debug ! ( "pop_skolemized({:?})" , skol_map) ;
0 commit comments