@@ -22,7 +22,7 @@ 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 ;
25
- use ty:: { BrFresh , ReLateBound , ReSkolemized , ReVar } ;
25
+ use ty:: { BrFresh , ReLateBound , ReVar } ;
26
26
27
27
use std:: collections:: BTreeMap ;
28
28
use std:: { cmp, fmt, mem, u32} ;
@@ -45,9 +45,6 @@ pub struct RegionConstraintCollector<'tcx> {
45
45
/// exist). This prevents us from making many such regions.
46
46
glbs : CombineMap < ' tcx > ,
47
47
48
- /// Number of skolemized variables currently active.
49
- skolemization_count : ty:: UniverseIndex ,
50
-
51
48
/// Global counter used during the GLB algorithm to create unique
52
49
/// names for fresh bound regions
53
50
bound_count : u32 ,
@@ -237,7 +234,6 @@ pub struct RegionVariableInfo {
237
234
pub struct RegionSnapshot {
238
235
length : usize ,
239
236
region_snapshot : ut:: Snapshot < ut:: InPlace < ty:: RegionVid > > ,
240
- skolemization_count : ty:: UniverseIndex ,
241
237
}
242
238
243
239
/// When working with skolemized regions, we often wish to find all of
@@ -281,7 +277,6 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
281
277
data : RegionConstraintData :: default ( ) ,
282
278
lubs : FxHashMap ( ) ,
283
279
glbs : FxHashMap ( ) ,
284
- skolemization_count : ty:: UniverseIndex :: ROOT ,
285
280
bound_count : 0 ,
286
281
undo_log : Vec :: new ( ) ,
287
282
unification_table : ut:: UnificationTable :: new ( ) ,
@@ -327,14 +322,11 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
327
322
data,
328
323
lubs,
329
324
glbs,
330
- skolemization_count,
331
325
bound_count : _,
332
326
undo_log : _,
333
327
unification_table,
334
328
} = self ;
335
329
336
- assert_eq ! ( * skolemization_count, ty:: UniverseIndex :: ROOT ) ;
337
-
338
330
// Clear the tables of (lubs, glbs), so that we will create
339
331
// fresh regions if we do a LUB operation. As it happens,
340
332
// LUB/GLB are not performed by the MIR type-checker, which is
@@ -369,20 +361,13 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
369
361
RegionSnapshot {
370
362
length,
371
363
region_snapshot : self . unification_table . snapshot ( ) ,
372
- skolemization_count : self . skolemization_count ,
373
364
}
374
365
}
375
366
376
367
pub fn commit ( & mut self , snapshot : RegionSnapshot ) {
377
368
debug ! ( "RegionConstraintCollector: commit({})" , snapshot. length) ;
378
369
assert ! ( self . undo_log. len( ) > snapshot. length) ;
379
370
assert ! ( self . undo_log[ snapshot. length] == OpenSnapshot ) ;
380
- assert ! (
381
- self . skolemization_count == snapshot. skolemization_count,
382
- "failed to pop skolemized regions: {:?} now vs {:?} at start" ,
383
- self . skolemization_count,
384
- snapshot. skolemization_count
385
- ) ;
386
371
387
372
if snapshot. length == 0 {
388
373
self . undo_log . truncate ( 0 ) ;
@@ -402,7 +387,6 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
402
387
}
403
388
let c = self . undo_log . pop ( ) . unwrap ( ) ;
404
389
assert ! ( c == OpenSnapshot ) ;
405
- self . skolemization_count = snapshot. skolemization_count ;
406
390
self . unification_table . rollback_to ( snapshot. region_snapshot ) ;
407
391
}
408
392
@@ -469,46 +453,13 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
469
453
self . var_infos [ vid] . origin
470
454
}
471
455
472
- /// Creates a new skolemized region. Skolemized regions are fresh
473
- /// regions used when performing higher-ranked computations. They
474
- /// must be used in a very particular way and are never supposed
475
- /// to "escape" out into error messages or the code at large.
476
- ///
477
- /// The idea is to always create a snapshot. Skolemized regions
478
- /// can be created in the context of this snapshot, but before the
479
- /// snapshot is committed or rolled back, they must be popped
480
- /// (using `pop_skolemized_regions`), so that their numbers can be
481
- /// recycled. Normally you don't have to think about this: you use
482
- /// the APIs in `higher_ranked/mod.rs`, such as
483
- /// `skolemize_late_bound_regions` and `plug_leaks`, which will
484
- /// guide you on this path (ensure that the `SkolemizationMap` is
485
- /// consumed and you are good). There are also somewhat extensive
486
- /// comments in `higher_ranked/README.md`.
487
- ///
488
- /// The `snapshot` argument to this function is not really used;
489
- /// it's just there to make it explicit which snapshot bounds the
490
- /// skolemized region that results. It should always be the top-most snapshot.
491
- pub fn push_skolemized (
492
- & mut self ,
493
- tcx : TyCtxt < ' _ , ' _ , ' tcx > ,
494
- br : ty:: BoundRegion ,
495
- snapshot : & RegionSnapshot ,
496
- ) -> Region < ' tcx > {
497
- assert ! ( self . in_snapshot( ) ) ;
498
- assert ! ( self . undo_log[ snapshot. length] == OpenSnapshot ) ;
499
-
500
- let universe = self . skolemization_count . subuniverse ( ) ;
501
- self . skolemization_count = universe;
502
- tcx. mk_region ( ReSkolemized ( universe, br) )
503
- }
504
-
505
456
/// Removes all the edges to/from the skolemized regions that are
506
457
/// in `skols`. This is used after a higher-ranked operation
507
458
/// completes to remove all trace of the skolemized regions
508
459
/// created in that time.
509
460
pub fn pop_skolemized (
510
461
& mut self ,
511
- _tcx : TyCtxt < ' _ , ' _ , ' tcx > ,
462
+ skolemization_count : ty :: UniverseIndex ,
512
463
skols : & FxHashSet < ty:: Region < ' tcx > > ,
513
464
snapshot : & RegionSnapshot ,
514
465
) {
@@ -517,24 +468,16 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
517
468
assert ! ( self . in_snapshot( ) ) ;
518
469
assert ! ( self . undo_log[ snapshot. length] == OpenSnapshot ) ;
519
470
assert ! (
520
- self . skolemization_count. as_usize( ) >= skols. len( ) ,
471
+ skolemization_count. as_usize( ) >= skols. len( ) ,
521
472
"popping more skolemized variables than actually exist, \
522
473
sc now = {:?}, skols.len = {:?}",
523
- self . skolemization_count,
474
+ skolemization_count,
524
475
skols. len( )
525
476
) ;
526
477
527
- let last_to_pop = self . skolemization_count . subuniverse ( ) ;
478
+ let last_to_pop = skolemization_count. subuniverse ( ) ;
528
479
let first_to_pop = ty:: UniverseIndex :: from ( last_to_pop. as_u32 ( ) - skols. len ( ) as u32 ) ;
529
480
530
- assert ! (
531
- first_to_pop >= snapshot. skolemization_count,
532
- "popping more regions than snapshot contains, \
533
- sc now = {:?}, sc then = {:?}, skols.len = {:?}",
534
- self . skolemization_count,
535
- snapshot. skolemization_count,
536
- skols. len( )
537
- ) ;
538
481
debug_assert ! {
539
482
skols. iter( )
540
483
. all( |& k| match * k {
@@ -545,8 +488,8 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
545
488
false
546
489
} ) ,
547
490
"invalid skolemization keys or keys out of range ({:?}..{:?}): {:?}" ,
548
- snapshot . skolemization_count ,
549
- self . skolemization_count ,
491
+ first_to_pop ,
492
+ last_to_pop ,
550
493
skols
551
494
}
552
495
@@ -563,7 +506,6 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
563
506
self . rollback_undo_entry ( undo_entry) ;
564
507
}
565
508
566
- self . skolemization_count = snapshot. skolemization_count ;
567
509
return ;
568
510
569
511
fn kill_constraint < ' tcx > (
@@ -896,12 +838,7 @@ pub fn region_universe(var_infos: &VarInfos, region: Region<'_>) -> ty::Universe
896
838
897
839
impl fmt:: Debug for RegionSnapshot {
898
840
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
899
- write ! (
900
- f,
901
- "RegionSnapshot(length={},skolemization={:?})" ,
902
- self . length,
903
- self . skolemization_count
904
- )
841
+ write ! ( f, "RegionSnapshot(length={})" , self . length)
905
842
}
906
843
}
907
844
0 commit comments