1010
1111//! See README.md
1212
13- use self :: UndoLogEntry :: * ;
1413use self :: CombineMapType :: * ;
14+ use self :: UndoLogEntry :: * ;
1515
16- use super :: { MiscVariable , RegionVariableOrigin , SubregionOrigin } ;
1716use super :: unify_key;
17+ use super :: { MiscVariable , RegionVariableOrigin , SubregionOrigin } ;
1818
19- use rustc_data_structures:: indexed_vec:: IndexVec ;
2019use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
20+ use rustc_data_structures:: indexed_vec:: IndexVec ;
2121use rustc_data_structures:: unify as ut;
22- use ty:: { self , Ty , TyCtxt } ;
23- use ty:: { Region , RegionVid } ;
2422use ty:: ReStatic ;
23+ use ty:: { self , Ty , TyCtxt } ;
2524use ty:: { BrFresh , ReLateBound , ReVar } ;
25+ use ty:: { Region , RegionVid } ;
2626
2727use std:: collections:: BTreeMap ;
2828use std:: { cmp, fmt, mem, u32} ;
@@ -495,13 +495,12 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
495495 }
496496 }
497497
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 } ) ;
505504
506505 let u_vid = self . unification_table
507506 . new_key ( unify_key:: RegionVidKey { min_vid : vid } ) ;
@@ -511,8 +510,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
511510 }
512511 debug ! (
513512 "created new region variable {:?} with origin {:?}" ,
514- vid,
515- origin
513+ vid, origin
516514 ) ;
517515 return vid;
518516 }
@@ -533,45 +531,19 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
533531 /// created in that time.
534532 pub fn pop_placeholders (
535533 & mut self ,
536- skolemization_count : ty:: UniverseIndex ,
537- skols : & FxHashSet < ty:: Region < ' tcx > > ,
534+ placeholders : & FxHashSet < ty:: Region < ' tcx > > ,
538535 snapshot : & RegionSnapshot ,
539536 ) {
540- debug ! ( "pop_placeholders(skols ={:?})" , skols ) ;
537+ debug ! ( "pop_placeholders(placeholders ={:?})" , placeholders ) ;
541538
542539 assert ! ( self . in_snapshot( ) ) ;
543540 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- }
569541
570542 let constraints_to_kill: Vec < usize > = self . undo_log
571543 . iter ( )
572544 . enumerate ( )
573545 . rev ( )
574- . filter ( |& ( _, undo_entry) | kill_constraint ( skols , undo_entry) )
546+ . filter ( |& ( _, undo_entry) | kill_constraint ( placeholders , undo_entry) )
575547 . map ( |( index, _) | index)
576548 . collect ( ) ;
577549
@@ -583,20 +555,20 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
583555 return ;
584556
585557 fn kill_constraint < ' tcx > (
586- skols : & FxHashSet < ty:: Region < ' tcx > > ,
558+ placeholders : & FxHashSet < ty:: Region < ' tcx > > ,
587559 undo_entry : & UndoLogEntry < ' tcx > ,
588560 ) -> bool {
589561 match undo_entry {
590562 & 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) ,
593565 & AddConstraint ( Constraint :: RegSubReg ( a, b) ) => {
594- skols . contains ( & a) || skols . contains ( & b)
566+ placeholders . contains ( & a) || placeholders . contains ( & b)
595567 }
596568 & AddGiven ( ..) => false ,
597569 & AddVerify ( _) => false ,
598570 & 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 )
600572 }
601573 & AddVar ( ..) | & OpenSnapshot | & Purged | & CommitedSnapshot => false ,
602574 }
@@ -713,9 +685,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
713685 // cannot add constraints once regions are resolved
714686 debug ! (
715687 "RegionConstraintCollector: make_subregion({:?}, {:?}) due to {:?}" ,
716- sub,
717- sup,
718- origin
688+ sub, sup, origin
719689 ) ;
720690
721691 match ( sub, sup) {
@@ -854,19 +824,19 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
854824
855825 fn universe ( & self , region : Region < ' tcx > ) -> ty:: UniverseIndex {
856826 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 ,
863833 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+ ) ,
870840 }
871841 }
872842
@@ -897,9 +867,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
897867 ) -> FxHashSet < ty:: Region < ' tcx > > {
898868 debug ! (
899869 "tainted(mark={:?}, r0={:?}, directions={:?})" ,
900- mark,
901- r0,
902- directions
870+ mark, r0, directions
903871 ) ;
904872
905873 // `result_set` acts as a worklist: we explore all outgoing
0 commit comments