Use map_bound(_ref) instead of Binder::bind when possible

This commit is contained in:
Jack Huey
2020-10-07 20:02:06 -04:00
parent a78a62fc99
commit dd5c9bf139
24 changed files with 173 additions and 143 deletions

View File

@@ -126,14 +126,15 @@ impl Elaborator<'tcx> {
fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) {
let tcx = self.visited.tcx;
match obligation.predicate.skip_binders() {
let bound_predicate = obligation.predicate.bound_atom(tcx);
match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(data, _) => {
// Get predicates declared on the trait.
let predicates = tcx.super_predicates_of(data.def_id());
let obligations = predicates.predicates.iter().map(|&(pred, _)| {
predicate_obligation(
pred.subst_supertrait(tcx, &ty::Binder::bind(data.trait_ref)),
pred.subst_supertrait(tcx, &bound_predicate.map_bound(|_| data.trait_ref)),
obligation.param_env,
obligation.cause.clone(),
)