10
10
11
11
//! See README.md
12
12
13
- use self :: UndoLogEntry :: * ;
14
13
use self :: CombineMapType :: * ;
14
+ use self :: UndoLogEntry :: * ;
15
15
16
- use super :: { MiscVariable , RegionVariableOrigin , SubregionOrigin } ;
17
16
use super :: unify_key;
17
+ use super :: { MiscVariable , RegionVariableOrigin , SubregionOrigin } ;
18
18
19
- use rustc_data_structures:: indexed_vec:: IndexVec ;
20
19
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
20
+ use rustc_data_structures:: indexed_vec:: IndexVec ;
21
21
use rustc_data_structures:: unify as ut;
22
- use ty:: { self , Ty , TyCtxt } ;
23
- use ty:: { Region , RegionVid } ;
24
22
use ty:: ReStatic ;
23
+ use ty:: { self , Ty , TyCtxt } ;
25
24
use ty:: { BrFresh , ReLateBound , ReVar } ;
25
+ use ty:: { Region , RegionVid } ;
26
26
27
27
use std:: collections:: BTreeMap ;
28
28
use std:: { cmp, fmt, mem, u32} ;
@@ -495,13 +495,12 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
495
495
}
496
496
}
497
497
498
- pub fn new_region_var ( & mut self ,
499
- universe : ty:: UniverseIndex ,
500
- origin : RegionVariableOrigin ) -> RegionVid {
501
- let vid = self . var_infos . push ( RegionVariableInfo {
502
- origin,
503
- universe,
504
- } ) ;
498
+ pub fn new_region_var (
499
+ & mut self ,
500
+ universe : ty:: UniverseIndex ,
501
+ origin : RegionVariableOrigin ,
502
+ ) -> RegionVid {
503
+ let vid = self . var_infos . push ( RegionVariableInfo { origin, universe } ) ;
505
504
506
505
let u_vid = self . unification_table
507
506
. new_key ( unify_key:: RegionVidKey { min_vid : vid } ) ;
@@ -511,8 +510,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
511
510
}
512
511
debug ! (
513
512
"created new region variable {:?} with origin {:?}" ,
514
- vid,
515
- origin
513
+ vid, origin
516
514
) ;
517
515
return vid;
518
516
}
@@ -533,45 +531,19 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
533
531
/// created in that time.
534
532
pub fn pop_placeholders (
535
533
& mut self ,
536
- skolemization_count : ty:: UniverseIndex ,
537
- skols : & FxHashSet < ty:: Region < ' tcx > > ,
534
+ placeholders : & FxHashSet < ty:: Region < ' tcx > > ,
538
535
snapshot : & RegionSnapshot ,
539
536
) {
540
- debug ! ( "pop_placeholders(skols ={:?})" , skols ) ;
537
+ debug ! ( "pop_placeholders(placeholders ={:?})" , placeholders ) ;
541
538
542
539
assert ! ( self . in_snapshot( ) ) ;
543
540
assert ! ( self . undo_log[ snapshot. length] == OpenSnapshot ) ;
544
- assert ! (
545
- skolemization_count. as_usize( ) >= skols. len( ) ,
546
- "popping more placeholder variables than actually exist, \
547
- sc now = {:?}, skols.len = {:?}",
548
- skolemization_count,
549
- skols. len( )
550
- ) ;
551
-
552
- let last_to_pop = skolemization_count. subuniverse ( ) ;
553
- let first_to_pop = ty:: UniverseIndex :: from ( last_to_pop. as_u32 ( ) - skols. len ( ) as u32 ) ;
554
-
555
- debug_assert ! {
556
- skols. iter( )
557
- . all( |& k| match * k {
558
- ty:: RePlaceholder ( universe, _) =>
559
- universe >= first_to_pop &&
560
- universe < last_to_pop,
561
- _ =>
562
- false
563
- } ) ,
564
- "invalid skolemization keys or keys out of range ({:?}..{:?}): {:?}" ,
565
- first_to_pop,
566
- last_to_pop,
567
- skols
568
- }
569
541
570
542
let constraints_to_kill: Vec < usize > = self . undo_log
571
543
. iter ( )
572
544
. enumerate ( )
573
545
. rev ( )
574
- . filter ( |& ( _, undo_entry) | kill_constraint ( skols , undo_entry) )
546
+ . filter ( |& ( _, undo_entry) | kill_constraint ( placeholders , undo_entry) )
575
547
. map ( |( index, _) | index)
576
548
. collect ( ) ;
577
549
@@ -583,20 +555,20 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
583
555
return ;
584
556
585
557
fn kill_constraint < ' tcx > (
586
- skols : & FxHashSet < ty:: Region < ' tcx > > ,
558
+ placeholders : & FxHashSet < ty:: Region < ' tcx > > ,
587
559
undo_entry : & UndoLogEntry < ' tcx > ,
588
560
) -> bool {
589
561
match undo_entry {
590
562
& AddConstraint ( Constraint :: VarSubVar ( ..) ) => false ,
591
- & AddConstraint ( Constraint :: RegSubVar ( a, _) ) => skols . contains ( & a) ,
592
- & AddConstraint ( Constraint :: VarSubReg ( _, b) ) => skols . contains ( & b) ,
563
+ & AddConstraint ( Constraint :: RegSubVar ( a, _) ) => placeholders . contains ( & a) ,
564
+ & AddConstraint ( Constraint :: VarSubReg ( _, b) ) => placeholders . contains ( & b) ,
593
565
& AddConstraint ( Constraint :: RegSubReg ( a, b) ) => {
594
- skols . contains ( & a) || skols . contains ( & b)
566
+ placeholders . contains ( & a) || placeholders . contains ( & b)
595
567
}
596
568
& AddGiven ( ..) => false ,
597
569
& AddVerify ( _) => false ,
598
570
& AddCombination ( _, ref two_regions) => {
599
- skols . contains ( & two_regions. a ) || skols . contains ( & two_regions. b )
571
+ placeholders . contains ( & two_regions. a ) || placeholders . contains ( & two_regions. b )
600
572
}
601
573
& AddVar ( ..) | & OpenSnapshot | & Purged | & CommitedSnapshot => false ,
602
574
}
@@ -713,9 +685,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
713
685
// cannot add constraints once regions are resolved
714
686
debug ! (
715
687
"RegionConstraintCollector: make_subregion({:?}, {:?}) due to {:?}" ,
716
- sub,
717
- sup,
718
- origin
688
+ sub, sup, origin
719
689
) ;
720
690
721
691
match ( sub, sup) {
@@ -854,19 +824,19 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
854
824
855
825
fn universe ( & self , region : Region < ' tcx > ) -> ty:: UniverseIndex {
856
826
match * region {
857
- ty:: ReScope ( ..) |
858
- ty:: ReStatic |
859
- ty:: ReEmpty |
860
- ty:: ReErased |
861
- ty:: ReFree ( ..) |
862
- ty:: ReEarlyBound ( ..) => ty:: UniverseIndex :: ROOT ,
827
+ ty:: ReScope ( ..)
828
+ | ty:: ReStatic
829
+ | ty:: ReEmpty
830
+ | ty:: ReErased
831
+ | ty:: ReFree ( ..)
832
+ | ty:: ReEarlyBound ( ..) => ty:: UniverseIndex :: ROOT ,
863
833
ty:: RePlaceholder ( universe, _) => universe,
864
- ty:: ReClosureBound ( vid) |
865
- ty:: ReVar ( vid ) => self . var_universe ( vid ) ,
866
- ty:: ReLateBound ( ..) =>
867
- bug ! ( "universe (): encountered bound region {:?}", region ) ,
868
- ty :: ReCanonical ( .. ) =>
869
- bug ! ( "region_universe(): encountered canonical region {:?}" , region ) ,
834
+ ty:: ReClosureBound ( vid) | ty :: ReVar ( vid ) => self . var_universe ( vid ) ,
835
+ ty:: ReLateBound ( .. ) => bug ! ( "universe(): encountered bound region {:?}" , region ) ,
836
+ ty:: ReCanonical ( ..) => bug ! (
837
+ "region_universe (): encountered canonical region {:?}",
838
+ region
839
+ ) ,
870
840
}
871
841
}
872
842
@@ -897,9 +867,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
897
867
) -> FxHashSet < ty:: Region < ' tcx > > {
898
868
debug ! (
899
869
"tainted(mark={:?}, r0={:?}, directions={:?})" ,
900
- mark,
901
- r0,
902
- directions
870
+ mark, r0, directions
903
871
) ;
904
872
905
873
// `result_set` acts as a worklist: we explore all outgoing
0 commit comments