@@ -6,7 +6,6 @@ use super::RegionVariableOrigin;
6
6
use super :: type_variable:: TypeVariableOrigin ;
7
7
8
8
use std:: ops:: Range ;
9
- use rustc_data_structures:: fx:: FxHashMap ;
10
9
11
10
impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
12
11
/// This rather funky routine is used while processing expected
@@ -102,10 +101,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
102
101
103
102
// Micro-optimization: if no variables have been created, then
104
103
// `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 ( ) &&
106
105
fudger. int_vars . is_empty ( ) &&
107
106
fudger. float_vars . is_empty ( ) &&
108
- fudger. region_vars . is_empty ( ) {
107
+ fudger. region_vars . 0 . is_empty ( ) {
109
108
Ok ( value)
110
109
} else {
111
110
Ok ( value. fold_with ( & mut fudger) )
@@ -115,10 +114,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
115
114
116
115
pub struct InferenceFudger < ' a , ' gcx : ' a +' tcx , ' tcx : ' a > {
117
116
infcx : & ' a InferCtxt < ' a , ' gcx , ' tcx > ,
118
- type_vars : FxHashMap < TyVid , TypeVariableOrigin > ,
117
+ type_vars : ( Range < TyVid > , Vec < TypeVariableOrigin > ) ,
119
118
int_vars : Range < IntVid > ,
120
119
float_vars : Range < FloatVid > ,
121
- region_vars : FxHashMap < RegionVid , RegionVariableOrigin > ,
120
+ region_vars : ( Range < RegionVid > , Vec < RegionVariableOrigin > ) ,
122
121
}
123
122
124
123
impl < ' 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>
129
128
fn fold_ty ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
130
129
match ty. sty {
131
130
ty:: Infer ( ty:: InferTy :: TyVar ( vid) ) => {
132
- if let Some ( & origin ) = self . type_vars . get ( & vid) {
131
+ if self . type_vars . 0 . contains ( & vid) {
133
132
// This variable was created during the fudging.
134
133
// 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] ;
135
136
self . infcx . next_ty_var ( origin)
136
137
} else {
137
138
// This variable was created before the
@@ -165,7 +166,9 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx>
165
166
166
167
fn fold_region ( & mut self , r : ty:: Region < ' tcx > ) -> ty:: Region < ' tcx > {
167
168
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] ;
169
172
return self . infcx . next_region_var ( origin) ;
170
173
}
171
174
}
0 commit comments