@@ -41,16 +41,16 @@ use std::collections::hash_map::Entry;
41
41
use super :: unify_key:: ToType ;
42
42
use super :: InferCtxt ;
43
43
44
- pub struct TypeFreshener < ' a , ' tcx > {
45
- infcx : & ' a InferCtxt < ' a , ' tcx > ,
44
+ pub struct TypeFreshener < ' a , ' cx , ' tcx > {
45
+ infcx : & ' a mut InferCtxt < ' cx , ' tcx > ,
46
46
ty_freshen_count : u32 ,
47
47
const_freshen_count : u32 ,
48
48
ty_freshen_map : FxHashMap < ty:: InferTy , Ty < ' tcx > > ,
49
49
const_freshen_map : FxHashMap < ty:: InferConst < ' tcx > , & ' tcx ty:: Const < ' tcx > > ,
50
50
}
51
51
52
- impl < ' a , ' tcx > TypeFreshener < ' a , ' tcx > {
53
- pub fn new ( infcx : & ' a InferCtxt < ' a , ' tcx > ) -> TypeFreshener < ' a , ' tcx > {
52
+ impl < ' a , ' cx , ' tcx > TypeFreshener < ' a , ' cx , ' tcx > {
53
+ pub fn new ( infcx : & ' a mut InferCtxt < ' cx , ' tcx > ) -> Self {
54
54
TypeFreshener {
55
55
infcx,
56
56
ty_freshen_count : 0 ,
@@ -112,7 +112,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
112
112
}
113
113
}
114
114
115
- impl < ' a , ' tcx > TypeFolder < ' tcx > for TypeFreshener < ' a , ' tcx > {
115
+ impl < ' a , ' tcx > TypeFolder < ' tcx > for TypeFreshener < ' a , ' _ , ' tcx > {
116
116
fn tcx < ' b > ( & ' b self ) -> TyCtxt < ' tcx > {
117
117
self . infcx . tcx
118
118
}
@@ -150,25 +150,31 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
150
150
self . freshen_ty ( opt_ty, ty:: TyVar ( v) , ty:: FreshTy )
151
151
}
152
152
153
- ty:: Infer ( ty:: IntVar ( v) ) => self . freshen_ty (
154
- self . infcx
153
+ ty:: Infer ( ty:: IntVar ( v) ) => {
154
+ let opt_ty = self . infcx
155
155
. inner
156
156
. int_unification_table ( )
157
157
. probe_value ( v)
158
- . map ( |v| v. to_type ( tcx) ) ,
159
- ty:: IntVar ( v) ,
160
- ty:: FreshIntTy ,
161
- ) ,
158
+ . map ( |v| v. to_type ( tcx) ) ;
159
+ self . freshen_ty (
160
+ opt_ty,
161
+ ty:: IntVar ( v) ,
162
+ ty:: FreshIntTy ,
163
+ )
164
+ }
162
165
163
- ty:: Infer ( ty:: FloatVar ( v) ) => self . freshen_ty (
164
- self . infcx
166
+ ty:: Infer ( ty:: FloatVar ( v) ) => {
167
+ let opt_ty = self . infcx
165
168
. inner
166
169
. float_unification_table ( )
167
170
. probe_value ( v)
168
- . map ( |v| v. to_type ( tcx) ) ,
171
+ . map ( |v| v. to_type ( tcx) ) ;
172
+ self . freshen_ty (
173
+ opt_ty,
169
174
ty:: FloatVar ( v) ,
170
175
ty:: FreshFloatTy ,
171
- ) ,
176
+ )
177
+ }
172
178
173
179
ty:: Infer ( ty:: FreshTy ( ct) | ty:: FreshIntTy ( ct) | ty:: FreshFloatTy ( ct) ) => {
174
180
if ct >= self . ty_freshen_count {
0 commit comments