@@ -20,7 +20,6 @@ use rustc_middle::ty::{ReBound, ReVar};
20
20
use rustc_middle:: ty:: { Region , RegionVid } ;
21
21
use rustc_span:: Span ;
22
22
23
- use std:: collections:: BTreeMap ;
24
23
use std:: ops:: Range ;
25
24
use std:: { cmp, fmt, mem} ;
26
25
@@ -90,7 +89,7 @@ pub type VarInfos = IndexVec<RegionVid, RegionVariableInfo>;
90
89
pub struct RegionConstraintData < ' tcx > {
91
90
/// Constraints of the form `A <= B`, where either `A` or `B` can
92
91
/// 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 > ) > ,
94
93
95
94
/// Constraints of the form `R0 member of [R1, ..., Rn]`, meaning that
96
95
/// `R0` must be equal to one of the regions `R1..Rn`. These occur
@@ -273,7 +272,7 @@ pub(crate) enum UndoLog<'tcx> {
273
272
AddVar ( RegionVid ) ,
274
273
275
274
/// We added the given `constraint`.
276
- AddConstraint ( Constraint < ' tcx > ) ,
275
+ AddConstraint ( usize ) ,
277
276
278
277
/// We added the given `verify`.
279
278
AddVerify ( usize ) ,
@@ -319,8 +318,9 @@ impl<'tcx> RegionConstraintStorage<'tcx> {
319
318
self . var_infos . pop ( ) . unwrap ( ) ;
320
319
assert_eq ! ( self . var_infos. len( ) , vid. index( ) ) ;
321
320
}
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) ;
324
324
}
325
325
AddVerify ( index) => {
326
326
self . data . verifys . pop ( ) ;
@@ -443,14 +443,9 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
443
443
// cannot add constraints once regions are resolved
444
444
debug ! ( "RegionConstraintCollector: add_constraint({:?})" , constraint) ;
445
445
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) ) ;
454
449
}
455
450
456
451
fn add_verify ( & mut self , verify : Verify < ' tcx > ) {
0 commit comments