Skip to content

Commit f9d8bb8

Browse files
committed
Simplify fudge_inference_if_ok
1 parent ac94858 commit f9d8bb8

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/librustc/infer/fudge.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
5656
{
5757
debug!("fudge_inference_if_ok(origin={:?})", origin);
5858

59-
let (type_vars, int_vars, float_vars, region_vars, value) = self.probe(|snapshot| {
59+
let (mut fudger, value) = self.probe(|snapshot| {
6060
match f() {
6161
Ok(value) => {
6262
let value = self.resolve_type_vars_if_possible(&value);
@@ -80,7 +80,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
8080
&snapshot.region_constraints_snapshot,
8181
);
8282

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))
8493
}
8594
Err(e) => Err(e),
8695
}
@@ -93,32 +102,23 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
93102

94103
// Micro-optimization: if no variables have been created, then
95104
// `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() {
100109
return Ok(value);
101110
}
102111

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-
112112
Ok(value.fold_with(&mut fudger))
113113
}
114114
}
115115

116116
pub struct InferenceFudger<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
117117
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>,
122122
origin: &'a RegionVariableOrigin,
123123
}
124124

0 commit comments

Comments
 (0)