Skip to content

Commit b44d94a

Browse files
committed
remove unneccessary uses of drain_fulfillment_cx
There were various places that we are invoking `drain_fulfillment_cx` with a "result" of `()`. This is kind of pointless, since it amounts to just a call to `select_all_or_error` along with some extra overhead.
1 parent 52c2d87 commit b44d94a

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

src/librustc/traits/specialize/mod.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -207,24 +207,27 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
207207
for oblig in obligations.into_iter() {
208208
fulfill_cx.register_predicate_obligation(&infcx, oblig);
209209
}
210+
match fulfill_cx.select_all_or_error(infcx) {
211+
Err(errors) => {
212+
// no dice!
213+
debug!("fulfill_implication: for impls on {:?} and {:?}, could not fulfill: {:?} given \
214+
{:?}",
215+
source_trait_ref,
216+
target_trait_ref,
217+
errors,
218+
infcx.parameter_environment.caller_bounds);
219+
Err(())
220+
}
210221

211-
if let Err(errors) = infcx.drain_fulfillment_cx(&mut fulfill_cx, &()) {
212-
// no dice!
213-
debug!("fulfill_implication: for impls on {:?} and {:?}, could not fulfill: {:?} given \
214-
{:?}",
215-
source_trait_ref,
216-
target_trait_ref,
217-
errors,
218-
infcx.parameter_environment.caller_bounds);
219-
Err(())
220-
} else {
221-
debug!("fulfill_implication: an impl for {:?} specializes {:?}",
222-
source_trait_ref,
223-
target_trait_ref);
222+
Ok(()) => {
223+
debug!("fulfill_implication: an impl for {:?} specializes {:?}",
224+
source_trait_ref,
225+
target_trait_ref);
224226

225-
// Now resolve the *substitution* we built for the target earlier, replacing
226-
// the inference variables inside with whatever we got from fulfillment.
227-
Ok(infcx.resolve_type_vars_if_possible(&target_substs))
227+
// Now resolve the *substitution* we built for the target earlier, replacing
228+
// the inference variables inside with whatever we got from fulfillment.
229+
Ok(infcx.resolve_type_vars_if_possible(&target_substs))
230+
}
228231
}
229232
}
230233

src/librustc_trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ pub fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10281028
fulfill_cx.register_predicate_obligation(&infcx, obligation);
10291029
}
10301030

1031-
infcx.drain_fulfillment_cx(&mut fulfill_cx, &()).is_ok()
1031+
fulfill_cx.select_all_or_error(infcx).is_ok()
10321032
})
10331033
}
10341034

0 commit comments

Comments
 (0)