@@ -13,7 +13,7 @@ use region_constraints::{
1313pub  use  relate:: combine:: { CombineFields ,  PredicateEmittingRelation } ; 
1414pub  use  relate:: StructurallyRelateAliases ; 
1515use  rustc_data_structures:: captures:: Captures ; 
16- use  rustc_data_structures:: fx:: { FxHashMap ,   FxHashSet ,  FxIndexMap } ; 
16+ use  rustc_data_structures:: fx:: { FxHashSet ,  FxIndexMap } ; 
1717use  rustc_data_structures:: sync:: Lrc ; 
1818use  rustc_data_structures:: undo_log:: Rollback ; 
1919use  rustc_data_structures:: unify as  ut; 
@@ -1318,38 +1318,34 @@ impl<'tcx> InferCtxt<'tcx> {
13181318            return  inner; 
13191319        } 
13201320
1321-         struct  ToFreshVars < ' a ,  ' tcx >  { 
1322-             infcx :  & ' a  InferCtxt < ' tcx > , 
1323-             span :  Span , 
1324-             lbrct :  BoundRegionConversionTime , 
1325-             map :  FxHashMap < ty:: BoundVar ,  ty:: GenericArg < ' tcx > > , 
1321+         let  bound_vars = value. bound_vars ( ) ; 
1322+         let  mut  args = Vec :: with_capacity ( bound_vars. len ( ) ) ; 
1323+ 
1324+         for  bound_var_kind in  bound_vars { 
1325+             let  arg:  ty:: GenericArg < ' _ >  = match  bound_var_kind { 
1326+                 ty:: BoundVariableKind :: Ty ( _)  => self . next_ty_var ( span) . into ( ) , 
1327+                 ty:: BoundVariableKind :: Region ( br)  => self . next_region_var ( BoundRegion ( span,  br,  lbrct) ) . into ( ) , 
1328+                 ty:: BoundVariableKind :: Const  => self . next_const_var ( span) . into ( ) 
1329+             } ; 
1330+             args. push ( arg) ; 
1331+         } 
1332+ 
1333+         struct  ToFreshVars < ' tcx >  { 
1334+             args :  Vec < ty:: GenericArg < ' tcx > > , 
13261335        } 
13271336
1328-         impl < ' tcx >  BoundVarReplacerDelegate < ' tcx >  for  ToFreshVars < ' _ ,   ' tcx >  { 
1337+         impl < ' tcx >  BoundVarReplacerDelegate < ' tcx >  for  ToFreshVars < ' tcx >  { 
13291338            fn  replace_region ( & mut  self ,  br :  ty:: BoundRegion )  -> ty:: Region < ' tcx >  { 
1330-                 self . map 
1331-                     . entry ( br. var ) 
1332-                     . or_insert_with ( || { 
1333-                         self . infcx 
1334-                             . next_region_var ( BoundRegion ( self . span ,  br. kind ,  self . lbrct ) ) 
1335-                             . into ( ) 
1336-                     } ) 
1337-                     . expect_region ( ) 
1339+                 self . args [ br. var . index ( ) ] . expect_region ( ) 
13381340            } 
13391341            fn  replace_ty ( & mut  self ,  bt :  ty:: BoundTy )  -> Ty < ' tcx >  { 
1340-                 self . map 
1341-                     . entry ( bt. var ) 
1342-                     . or_insert_with ( || self . infcx . next_ty_var ( self . span ) . into ( ) ) 
1343-                     . expect_ty ( ) 
1342+                 self . args [ bt. var . index ( ) ] . expect_ty ( ) 
13441343            } 
13451344            fn  replace_const ( & mut  self ,  bv :  ty:: BoundVar )  -> ty:: Const < ' tcx >  { 
1346-                 self . map 
1347-                     . entry ( bv) 
1348-                     . or_insert_with ( || self . infcx . next_const_var ( self . span ) . into ( ) ) 
1349-                     . expect_const ( ) 
1345+                 self . args [ bv. index ( ) ] . expect_const ( ) 
13501346            } 
13511347        } 
1352-         let  delegate = ToFreshVars  {  infcx :   self ,  span ,  lbrct ,   map :   Default :: default ( )  } ; 
1348+         let  delegate = ToFreshVars  {  args  } ; 
13531349        self . tcx . replace_bound_vars_uncached ( value,  delegate) 
13541350    } 
13551351
0 commit comments