@@ -18,7 +18,7 @@ use super::unify_key;
18
18
19
19
use rustc_data_structures:: indexed_vec:: { IndexVec , Idx } ;
20
20
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
21
- use rustc_data_structures:: unify:: { self , UnificationTable } ;
21
+ use rustc_data_structures:: unify as ut ;
22
22
use ty:: { self , Ty , TyCtxt } ;
23
23
use ty:: { Region , RegionVid } ;
24
24
use ty:: ReStatic ;
@@ -48,7 +48,7 @@ pub struct RegionConstraintCollector<'tcx> {
48
48
glbs : CombineMap < ' tcx > ,
49
49
50
50
/// Number of skolemized variables currently active.
51
- skolemization_count : u32 ,
51
+ skolemization_count : ty :: UniverseIndex ,
52
52
53
53
/// Global counter used during the GLB algorithm to create unique
54
54
/// names for fresh bound regions
@@ -73,7 +73,7 @@ pub struct RegionConstraintCollector<'tcx> {
73
73
/// is iterating to a fixed point, because otherwise we sometimes
74
74
/// would wind up with a fresh stream of region variables that
75
75
/// have been equated but appear distinct.
76
- unification_table : UnificationTable < ty:: RegionVid > ,
76
+ unification_table : ut :: UnificationTable < ut :: InPlace < ty:: RegionVid > > ,
77
77
}
78
78
79
79
pub type VarOrigins = IndexVec < RegionVid , RegionVariableOrigin > ;
@@ -232,8 +232,8 @@ type CombineMap<'tcx> = FxHashMap<TwoRegions<'tcx>, RegionVid>;
232
232
233
233
pub struct RegionSnapshot {
234
234
length : usize ,
235
- region_snapshot : unify :: Snapshot < ty:: RegionVid > ,
236
- skolemization_count : u32 ,
235
+ region_snapshot : ut :: Snapshot < ut :: InPlace < ty:: RegionVid > > ,
236
+ skolemization_count : ty :: UniverseIndex ,
237
237
}
238
238
239
239
/// When working with skolemized regions, we often wish to find all of
@@ -277,10 +277,10 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
277
277
data : RegionConstraintData :: default ( ) ,
278
278
lubs : FxHashMap ( ) ,
279
279
glbs : FxHashMap ( ) ,
280
- skolemization_count : 0 ,
280
+ skolemization_count : ty :: UniverseIndex :: ROOT ,
281
281
bound_count : 0 ,
282
282
undo_log : Vec :: new ( ) ,
283
- unification_table : UnificationTable :: new ( ) ,
283
+ unification_table : ut :: UnificationTable :: new ( ) ,
284
284
}
285
285
}
286
286
@@ -329,7 +329,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
329
329
unification_table,
330
330
} = self ;
331
331
332
- assert_eq ! ( * skolemization_count, 0 ) ;
332
+ assert_eq ! ( skolemization_count. as_usize ( ) , 0 ) ;
333
333
334
334
// Clear the tables of (lubs, glbs), so that we will create
335
335
// fresh regions if we do a LUB operation. As it happens,
@@ -342,7 +342,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
342
342
// un-unified" state. Note that when we unify `a` and `b`, we
343
343
// also insert `a <= b` and a `b <= a` edges, so the
344
344
// `RegionConstraintData` contains the relationship here.
345
- * unification_table = UnificationTable :: new ( ) ;
345
+ * unification_table = ut :: UnificationTable :: new ( ) ;
346
346
for vid in var_origins. indices ( ) {
347
347
unification_table. new_key ( unify_key:: RegionVidKey { min_vid : vid } ) ;
348
348
}
@@ -371,7 +371,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
371
371
assert ! ( self . undo_log[ snapshot. length] == OpenSnapshot ) ;
372
372
assert ! (
373
373
self . skolemization_count == snapshot. skolemization_count,
374
- "failed to pop skolemized regions: {} now vs {} at start" ,
374
+ "failed to pop skolemized regions: {:? } now vs {:? } at start" ,
375
375
self . skolemization_count,
376
376
snapshot. skolemization_count
377
377
) ;
@@ -479,9 +479,9 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
479
479
assert ! ( self . in_snapshot( ) ) ;
480
480
assert ! ( self . undo_log[ snapshot. length] == OpenSnapshot ) ;
481
481
482
- let sc = self . skolemization_count ;
483
- self . skolemization_count = sc + 1 ;
484
- tcx. mk_region ( ReSkolemized ( ty :: SkolemizedRegionVid { index : sc } , br) )
482
+ let universe = self . skolemization_count . subuniverse ( ) ;
483
+ self . skolemization_count = universe ;
484
+ tcx. mk_region ( ReSkolemized ( universe , br) )
485
485
}
486
486
487
487
/// Removes all the edges to/from the skolemized regions that are
@@ -499,34 +499,34 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
499
499
assert ! ( self . in_snapshot( ) ) ;
500
500
assert ! ( self . undo_log[ snapshot. length] == OpenSnapshot ) ;
501
501
assert ! (
502
- self . skolemization_count as usize >= skols. len( ) ,
502
+ self . skolemization_count. as_usize ( ) >= skols. len( ) ,
503
503
"popping more skolemized variables than actually exist, \
504
504
sc now = {}, skols.len = {}",
505
- self . skolemization_count,
505
+ self . skolemization_count. as_usize ( ) ,
506
506
skols. len( )
507
507
) ;
508
508
509
- let last_to_pop = self . skolemization_count ;
510
- let first_to_pop = last_to_pop - ( skols. len ( ) as u32 ) ;
509
+ let last_to_pop = self . skolemization_count . subuniverse ( ) ;
510
+ let first_to_pop = ty :: UniverseIndex :: from ( last_to_pop. as_u32 ( ) - ( skols. len ( ) as u32 ) ) ;
511
511
512
512
assert ! (
513
513
first_to_pop >= snapshot. skolemization_count,
514
514
"popping more regions than snapshot contains, \
515
- sc now = {}, sc then = {}, skols.len = {}",
515
+ sc now = {:? }, sc then = {:? }, skols.len = {}",
516
516
self . skolemization_count,
517
517
snapshot. skolemization_count,
518
518
skols. len( )
519
519
) ;
520
520
debug_assert ! {
521
521
skols. iter( )
522
522
. all( |& k| match * k {
523
- ty:: ReSkolemized ( index , _) =>
524
- index . index >= first_to_pop &&
525
- index . index < last_to_pop,
523
+ ty:: ReSkolemized ( universe , _) =>
524
+ universe >= first_to_pop &&
525
+ universe < last_to_pop,
526
526
_ =>
527
527
false
528
528
} ) ,
529
- "invalid skolemization keys or keys out of range ({}..{}): {:?}" ,
529
+ "invalid skolemization keys or keys out of range ({:? }..{:? }): {:?}" ,
530
530
snapshot. skolemization_count,
531
531
self . skolemization_count,
532
532
skols
@@ -776,7 +776,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
776
776
tcx : TyCtxt < ' _ , ' _ , ' tcx > ,
777
777
rid : RegionVid ,
778
778
) -> ty:: Region < ' tcx > {
779
- let vid = self . unification_table . find_value ( rid) . min_vid ;
779
+ let vid = self . unification_table . probe_value ( rid) . min_vid ;
780
780
tcx. mk_region ( ty:: ReVar ( vid) )
781
781
}
782
782
@@ -861,7 +861,7 @@ impl fmt::Debug for RegionSnapshot {
861
861
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
862
862
write ! (
863
863
f,
864
- "RegionSnapshot(length={},skolemization={})" ,
864
+ "RegionSnapshot(length={},skolemization={:? })" ,
865
865
self . length,
866
866
self . skolemization_count
867
867
)
0 commit comments