@@ -3,8 +3,10 @@ use crate::ty::fold::{TypeFoldable, TypeFolder};
33
44use super :: InferCtxt ;
55use super :: RegionVariableOrigin ;
6+ use super :: type_variable:: TypeVariableOrigin ;
67
78use std:: ops:: Range ;
9+ use rustc_data_structures:: fx:: FxHashMap ;
810
911impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
1012 /// This rather funky routine is used while processing expected
@@ -115,7 +117,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
115117
116118pub struct InferenceFudger < ' a , ' gcx : ' a +' tcx , ' tcx : ' a > {
117119 infcx : & ' a InferCtxt < ' a , ' gcx , ' tcx > ,
118- type_vars : Range < TyVid > ,
120+ type_vars : FxHashMap < TyVid , TypeVariableOrigin > ,
119121 int_vars : Range < IntVid > ,
120122 float_vars : Range < FloatVid > ,
121123 region_vars : Range < RegionVid > ,
@@ -130,10 +132,9 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx>
130132 fn fold_ty ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
131133 match ty. sty {
132134 ty:: Infer ( ty:: InferTy :: TyVar ( vid) ) => {
133- if self . type_vars . contains ( & vid) {
135+ if let Some ( & origin ) = self . type_vars . get ( & vid) {
134136 // This variable was created during the fudging.
135137 // Recreate it with a fresh variable here.
136- let origin = self . infcx . type_variables . borrow ( ) . var_origin ( vid) . clone ( ) ;
137138 self . infcx . next_ty_var ( origin)
138139 } else {
139140 // This variable was created before the
0 commit comments