@@ -3,8 +3,10 @@ use crate::ty::fold::{TypeFoldable, TypeFolder};
3
3
4
4
use super :: InferCtxt ;
5
5
use super :: RegionVariableOrigin ;
6
+ use super :: type_variable:: TypeVariableOrigin ;
6
7
7
8
use std:: ops:: Range ;
9
+ use rustc_data_structures:: fx:: FxHashMap ;
8
10
9
11
impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
10
12
/// This rather funky routine is used while processing expected
@@ -115,7 +117,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
115
117
116
118
pub struct InferenceFudger < ' a , ' gcx : ' a +' tcx , ' tcx : ' a > {
117
119
infcx : & ' a InferCtxt < ' a , ' gcx , ' tcx > ,
118
- type_vars : Range < TyVid > ,
120
+ type_vars : FxHashMap < TyVid , TypeVariableOrigin > ,
119
121
int_vars : Range < IntVid > ,
120
122
float_vars : Range < FloatVid > ,
121
123
region_vars : Range < RegionVid > ,
@@ -130,10 +132,9 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx>
130
132
fn fold_ty ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
131
133
match ty. sty {
132
134
ty:: Infer ( ty:: InferTy :: TyVar ( vid) ) => {
133
- if self . type_vars . contains ( & vid) {
135
+ if let Some ( & origin ) = self . type_vars . get ( & vid) {
134
136
// This variable was created during the fudging.
135
137
// Recreate it with a fresh variable here.
136
- let origin = self . infcx . type_variables . borrow ( ) . var_origin ( vid) . clone ( ) ;
137
138
self . infcx . next_ty_var ( origin)
138
139
} else {
139
140
// This variable was created before the
0 commit comments