Skip to content

Commit 7c1b684

Browse files
committed
use map_bound instead of skip_binder
1 parent 3b4a062 commit 7c1b684

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/librustc_typeck/check/wfcheck.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
277277

278278
fn check_trait(&mut self, item: &hir::Item) {
279279
let trait_def_id = self.tcx.hir.local_def_id(item.id);
280-
281280
self.for_item(item).with_fcx(|fcx, _| {
282281
self.check_trait_where_clauses(fcx, item.span, trait_def_id);
283282
vec![]
@@ -421,14 +420,13 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
421420
if skip { continue; }
422421
substituted_predicates.push(match pred {
423422
// In trait predicates, substitute defaults only for the LHS.
424-
ty::Predicate::Trait(trait_pred) => {
425-
let t_pred = trait_pred.skip_binder();
426-
let self_ty = t_pred.self_ty().subst(fcx.tcx, substs);
427-
let mut trait_substs = t_pred.trait_ref.substs.to_vec();
428-
trait_substs[0] = self_ty.into();
429-
let trait_ref = ty::TraitRef::new(t_pred.def_id(),
430-
fcx.tcx.intern_substs(&trait_substs));
431-
ty::Predicate::Trait(ty::Binder(trait_ref).to_poly_trait_predicate())
423+
ty::Predicate::Trait(t_pred) => {
424+
let trait_ref = t_pred.map_bound(|t_pred| {
425+
let mut trait_subs = t_pred.trait_ref.substs.to_vec();
426+
trait_subs[0] = t_pred.self_ty().subst(fcx.tcx, substs).into();
427+
ty::TraitRef::new(t_pred.def_id(), fcx.tcx.intern_substs(&trait_subs))
428+
});
429+
ty::Predicate::Trait(trait_ref.to_poly_trait_predicate())
432430
}
433431
_ => pred.subst(fcx.tcx, substs)
434432
});

0 commit comments

Comments
 (0)