@@ -20,7 +20,6 @@ use rustc_middle::ty::{ReBound, ReVar};
2020use rustc_middle:: ty:: { Region , RegionVid } ;
2121use rustc_span:: Span ;
2222
23- use std:: collections:: BTreeMap ;
2423use std:: ops:: Range ;
2524use std:: { cmp, fmt, mem} ;
2625
@@ -90,7 +89,7 @@ pub type VarInfos = IndexVec<RegionVid, RegionVariableInfo>;
9089pub struct RegionConstraintData < ' tcx > {
9190 /// Constraints of the form `A <= B`, where either `A` or `B` can
9291 /// be a region variable (or neither, as it happens).
93- pub constraints : BTreeMap < Constraint < ' tcx > , SubregionOrigin < ' tcx > > ,
92+ pub constraints : Vec < ( Constraint < ' tcx > , SubregionOrigin < ' tcx > ) > ,
9493
9594 /// Constraints of the form `R0 member of [R1, ..., Rn]`, meaning that
9695 /// `R0` must be equal to one of the regions `R1..Rn`. These occur
@@ -273,7 +272,7 @@ pub(crate) enum UndoLog<'tcx> {
273272 AddVar ( RegionVid ) ,
274273
275274 /// We added the given `constraint`.
276- AddConstraint ( Constraint < ' tcx > ) ,
275+ AddConstraint ( usize ) ,
277276
278277 /// We added the given `verify`.
279278 AddVerify ( usize ) ,
@@ -319,8 +318,9 @@ impl<'tcx> RegionConstraintStorage<'tcx> {
319318 self . var_infos . pop ( ) . unwrap ( ) ;
320319 assert_eq ! ( self . var_infos. len( ) , vid. index( ) ) ;
321320 }
322- AddConstraint ( ref constraint) => {
323- self . data . constraints . remove ( constraint) ;
321+ AddConstraint ( index) => {
322+ self . data . constraints . pop ( ) . unwrap ( ) ;
323+ assert_eq ! ( self . data. constraints. len( ) , index) ;
324324 }
325325 AddVerify ( index) => {
326326 self . data . verifys . pop ( ) ;
@@ -443,14 +443,9 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
443443 // cannot add constraints once regions are resolved
444444 debug ! ( "RegionConstraintCollector: add_constraint({:?})" , constraint) ;
445445
446- // never overwrite an existing (constraint, origin) - only insert one if it isn't
447- // present in the map yet. This prevents origins from outside the snapshot being
448- // replaced with "less informative" origins e.g., during calls to `can_eq`
449- let undo_log = & mut self . undo_log ;
450- self . storage . data . constraints . entry ( constraint) . or_insert_with ( || {
451- undo_log. push ( AddConstraint ( constraint) ) ;
452- origin
453- } ) ;
446+ let index = self . storage . data . constraints . len ( ) ;
447+ self . storage . data . constraints . push ( ( constraint, origin) ) ;
448+ self . undo_log . push ( AddConstraint ( index) ) ;
454449 }
455450
456451 fn add_verify ( & mut self , verify : Verify < ' tcx > ) {
0 commit comments