@@ -19,7 +19,7 @@ use opaque_types::OpaqueTypeStorage;
19
19
use region_constraints:: { GenericKind , VarInfos , VerifyBound } ;
20
20
use region_constraints:: { RegionConstraintCollector , RegionConstraintStorage } ;
21
21
use rustc_data_structures:: captures:: Captures ;
22
- use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap } ;
22
+ use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap } ;
23
23
use rustc_data_structures:: sync:: Lrc ;
24
24
use rustc_data_structures:: undo_log:: Rollback ;
25
25
use rustc_data_structures:: unify as ut;
@@ -1317,38 +1317,34 @@ impl<'tcx> InferCtxt<'tcx> {
1317
1317
return inner;
1318
1318
}
1319
1319
1320
- struct ToFreshVars < ' a , ' tcx > {
1321
- infcx : & ' a InferCtxt < ' tcx > ,
1322
- span : Span ,
1323
- lbrct : BoundRegionConversionTime ,
1324
- map : FxHashMap < ty:: BoundVar , ty:: GenericArg < ' tcx > > ,
1320
+ let bound_vars = value. bound_vars ( ) ;
1321
+ let mut args = Vec :: with_capacity ( bound_vars. len ( ) ) ;
1322
+
1323
+ for bound_var_kind in bound_vars {
1324
+ let arg: ty:: GenericArg < ' _ > = match bound_var_kind {
1325
+ ty:: BoundVariableKind :: Ty ( _) => self . next_ty_var ( span) . into ( ) ,
1326
+ ty:: BoundVariableKind :: Region ( br) => self . next_region_var ( BoundRegion ( span, br, lbrct) ) . into ( ) ,
1327
+ ty:: BoundVariableKind :: Const => self . next_const_var ( span) . into ( )
1328
+ } ;
1329
+ args. push ( arg) ;
1330
+ }
1331
+
1332
+ struct ToFreshVars < ' tcx > {
1333
+ args : Vec < ty:: GenericArg < ' tcx > > ,
1325
1334
}
1326
1335
1327
- impl < ' tcx > BoundVarReplacerDelegate < ' tcx > for ToFreshVars < ' _ , ' tcx > {
1336
+ impl < ' tcx > BoundVarReplacerDelegate < ' tcx > for ToFreshVars < ' tcx > {
1328
1337
fn replace_region ( & mut self , br : ty:: BoundRegion ) -> ty:: Region < ' tcx > {
1329
- self . map
1330
- . entry ( br. var )
1331
- . or_insert_with ( || {
1332
- self . infcx
1333
- . next_region_var ( BoundRegion ( self . span , br. kind , self . lbrct ) )
1334
- . into ( )
1335
- } )
1336
- . expect_region ( )
1338
+ self . args [ br. var . index ( ) ] . expect_region ( )
1337
1339
}
1338
1340
fn replace_ty ( & mut self , bt : ty:: BoundTy ) -> Ty < ' tcx > {
1339
- self . map
1340
- . entry ( bt. var )
1341
- . or_insert_with ( || self . infcx . next_ty_var ( self . span ) . into ( ) )
1342
- . expect_ty ( )
1341
+ self . args [ bt. var . index ( ) ] . expect_ty ( )
1343
1342
}
1344
1343
fn replace_const ( & mut self , bv : ty:: BoundVar ) -> ty:: Const < ' tcx > {
1345
- self . map
1346
- . entry ( bv)
1347
- . or_insert_with ( || self . infcx . next_const_var ( self . span ) . into ( ) )
1348
- . expect_const ( )
1344
+ self . args [ bv. index ( ) ] . expect_const ( )
1349
1345
}
1350
1346
}
1351
- let delegate = ToFreshVars { infcx : self , span , lbrct , map : Default :: default ( ) } ;
1347
+ let delegate = ToFreshVars { args } ;
1352
1348
self . tcx . replace_bound_vars_uncached ( value, delegate)
1353
1349
}
1354
1350
0 commit comments