@@ -56,7 +56,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
56
56
{
57
57
debug ! ( "fudge_inference_if_ok(origin={:?})" , origin) ;
58
58
59
- let ( type_vars , int_vars , float_vars , region_vars , value) = self . probe ( |snapshot| {
59
+ let ( mut fudger , value) = self . probe ( |snapshot| {
60
60
match f ( ) {
61
61
Ok ( value) => {
62
62
let value = self . resolve_type_vars_if_possible ( & value) ;
@@ -80,7 +80,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
80
80
& snapshot. region_constraints_snapshot ,
81
81
) ;
82
82
83
- Ok ( ( type_vars, int_vars, float_vars, region_vars, value) )
83
+ let fudger = InferenceFudger {
84
+ infcx : self ,
85
+ type_vars,
86
+ int_vars,
87
+ float_vars,
88
+ region_vars,
89
+ origin,
90
+ } ;
91
+
92
+ Ok ( ( fudger, value) )
84
93
}
85
94
Err ( e) => Err ( e) ,
86
95
}
@@ -93,32 +102,23 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
93
102
94
103
// Micro-optimization: if no variables have been created, then
95
104
// `value` can't refer to any of them. =) So we can just return it.
96
- if type_vars. is_empty ( ) &&
97
- int_vars. is_empty ( ) &&
98
- float_vars. is_empty ( ) &&
99
- region_vars. is_empty ( ) {
105
+ if fudger . type_vars . is_empty ( ) &&
106
+ fudger . int_vars . is_empty ( ) &&
107
+ fudger . float_vars . is_empty ( ) &&
108
+ fudger . region_vars . is_empty ( ) {
100
109
return Ok ( value) ;
101
110
}
102
111
103
- let mut fudger = InferenceFudger {
104
- infcx : self ,
105
- type_vars : & type_vars,
106
- int_vars : & int_vars,
107
- float_vars : & float_vars,
108
- region_vars : & region_vars,
109
- origin,
110
- } ;
111
-
112
112
Ok ( value. fold_with ( & mut fudger) )
113
113
}
114
114
}
115
115
116
116
pub struct InferenceFudger < ' a , ' gcx : ' a +' tcx , ' tcx : ' a > {
117
117
infcx : & ' a InferCtxt < ' a , ' gcx , ' tcx > ,
118
- type_vars : & ' a Range < TyVid > ,
119
- int_vars : & ' a Range < IntVid > ,
120
- float_vars : & ' a Range < FloatVid > ,
121
- region_vars : & ' a Range < RegionVid > ,
118
+ type_vars : Range < TyVid > ,
119
+ int_vars : Range < IntVid > ,
120
+ float_vars : Range < FloatVid > ,
121
+ region_vars : Range < RegionVid > ,
122
122
origin : & ' a RegionVariableOrigin ,
123
123
}
124
124
0 commit comments