@@ -6,7 +6,6 @@ use super::RegionVariableOrigin;
66use super :: type_variable:: TypeVariableOrigin ;
77
88use std:: ops:: Range ;
9- use rustc_data_structures:: fx:: FxHashMap ;
109
1110impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
1211 /// This rather funky routine is used while processing expected
@@ -102,10 +101,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
102101
103102 // Micro-optimization: if no variables have been created, then
104103 // `value` can't refer to any of them. =) So we can just return it.
105- if fudger. type_vars . is_empty ( ) &&
104+ if fudger. type_vars . 0 . is_empty ( ) &&
106105 fudger. int_vars . is_empty ( ) &&
107106 fudger. float_vars . is_empty ( ) &&
108- fudger. region_vars . is_empty ( ) {
107+ fudger. region_vars . 0 . is_empty ( ) {
109108 Ok ( value)
110109 } else {
111110 Ok ( value. fold_with ( & mut fudger) )
@@ -115,10 +114,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
115114
116115pub struct InferenceFudger < ' a , ' gcx : ' a +' tcx , ' tcx : ' a > {
117116 infcx : & ' a InferCtxt < ' a , ' gcx , ' tcx > ,
118- type_vars : FxHashMap < TyVid , TypeVariableOrigin > ,
117+ type_vars : ( Range < TyVid > , Vec < TypeVariableOrigin > ) ,
119118 int_vars : Range < IntVid > ,
120119 float_vars : Range < FloatVid > ,
121- region_vars : FxHashMap < RegionVid , RegionVariableOrigin > ,
120+ region_vars : ( Range < RegionVid > , Vec < RegionVariableOrigin > ) ,
122121}
123122
124123impl < ' a , ' gcx , ' tcx > TypeFolder < ' gcx , ' tcx > for InferenceFudger < ' a , ' gcx , ' tcx > {
@@ -129,9 +128,11 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx>
129128 fn fold_ty ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
130129 match ty. sty {
131130 ty:: Infer ( ty:: InferTy :: TyVar ( vid) ) => {
132- if let Some ( & origin ) = self . type_vars . get ( & vid) {
131+ if self . type_vars . 0 . contains ( & vid) {
133132 // This variable was created during the fudging.
134133 // Recreate it with a fresh variable here.
134+ let idx = ( vid. index - self . type_vars . 0 . start . index ) as usize ;
135+ let origin = self . type_vars . 1 [ idx] ;
135136 self . infcx . next_ty_var ( origin)
136137 } else {
137138 // This variable was created before the
@@ -165,7 +166,9 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx>
165166
166167 fn fold_region ( & mut self , r : ty:: Region < ' tcx > ) -> ty:: Region < ' tcx > {
167168 if let ty:: ReVar ( vid) = r {
168- if let Some ( & origin) = self . region_vars . get ( & vid) {
169+ if self . region_vars . 0 . contains ( & vid) {
170+ let idx = ( vid. index ( ) - self . region_vars . 0 . start . index ( ) ) as usize ;
171+ let origin = self . region_vars . 1 [ idx] ;
169172 return self . infcx . next_region_var ( origin) ;
170173 }
171174 }
0 commit comments