@@ -50,13 +50,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
5050 /// unified.
5151 pub fn fudge_inference_if_ok < T , E , F > (
5252 & self ,
53- origin : & RegionVariableOrigin ,
5453 f : F ,
5554 ) -> Result < T , E > where
5655 F : FnOnce ( ) -> Result < T , E > ,
5756 T : TypeFoldable < ' tcx > ,
5857 {
59- debug ! ( "fudge_inference_if_ok(origin={:?})" , origin ) ;
58+ debug ! ( "fudge_inference_if_ok()" ) ;
6059
6160 let ( mut fudger, value) = self . probe ( |snapshot| {
6261 match f ( ) {
@@ -88,7 +87,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
8887 int_vars,
8988 float_vars,
9089 region_vars,
91- origin,
9290 } ;
9391
9492 Ok ( ( fudger, value) )
@@ -120,8 +118,7 @@ pub struct InferenceFudger<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
120118 type_vars : FxHashMap < TyVid , TypeVariableOrigin > ,
121119 int_vars : Range < IntVid > ,
122120 float_vars : Range < FloatVid > ,
123- region_vars : Range < RegionVid > ,
124- origin : & ' a RegionVariableOrigin ,
121+ region_vars : FxHashMap < RegionVid , RegionVariableOrigin > ,
125122}
126123
127124impl < ' a , ' gcx , ' tcx > TypeFolder < ' gcx , ' tcx > for InferenceFudger < ' a , ' gcx , ' tcx > {
@@ -167,11 +164,11 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx>
167164 }
168165
169166 fn fold_region ( & mut self , r : ty:: Region < ' tcx > ) -> ty:: Region < ' tcx > {
170- match * r {
171- ty :: ReVar ( vid ) if self . region_vars . contains ( & vid) => {
172- self . infcx . next_region_var ( self . origin . clone ( ) )
167+ if let ty :: ReVar ( vid ) = r {
168+ if let Some ( & origin ) = self . region_vars . get ( & vid) {
169+ return self . infcx . next_region_var ( origin) ;
173170 }
174- _ => r,
175171 }
172+ r
176173 }
177174}
0 commit comments