1
Fork 0

Remove some useless ty::Binder::dummy calls

This commit is contained in:
Maybe Waffle 2023-04-25 16:45:08 +00:00
parent 91d495fdf4
commit c727edc0b7
5 changed files with 14 additions and 32 deletions

View file

@ -313,12 +313,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
Self::consider_implied_clause(
ecx,
goal,
ty::Binder::dummy(ty::TraitRef::new(
tcx,
goal.predicate.def_id(),
[self_ty, generator.resume_ty()],
))
.to_predicate(tcx),
ty::TraitRef::new(tcx, goal.predicate.def_id(), [self_ty, generator.resume_ty()])
.to_predicate(tcx),
// Technically, we need to check that the generator types are Sized,
// but that's already proven by the generator being WF.
[],
@ -363,10 +359,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
data.iter().map(|pred| goal.with(tcx, pred.with_self_ty(tcx, a_ty))),
);
// The type must be Sized to be unsized.
ecx.add_goal(goal.with(
tcx,
ty::Binder::dummy(ty::TraitRef::new(tcx, sized_def_id, [a_ty])),
));
ecx.add_goal(goal.with(tcx, ty::TraitRef::new(tcx, sized_def_id, [a_ty])));
// The type must outlive the lifetime of the `dyn` we're unsizing into.
ecx.add_goal(
goal.with(tcx, ty::Binder::dummy(ty::OutlivesPredicate(a_ty, region))),
@ -415,11 +408,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
ecx.eq(goal.param_env, unsized_a_ty, b_ty)?;
ecx.add_goal(goal.with(
tcx,
ty::Binder::dummy(ty::TraitRef::new(
tcx,
goal.predicate.def_id(),
[a_tail_ty, b_tail_ty],
)),
ty::TraitRef::new(tcx, goal.predicate.def_id(), [a_tail_ty, b_tail_ty]),
));
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
@ -438,11 +427,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
// Similar to ADTs, require that the rest of the fields are equal.
ecx.add_goal(goal.with(
tcx,
ty::Binder::dummy(ty::TraitRef::new(
tcx,
goal.predicate.def_id(),
[*a_last_ty, *b_last_ty],
)),
ty::TraitRef::new(tcx, goal.predicate.def_id(), [*a_last_ty, *b_last_ty]),
));
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}

View file

@ -784,7 +784,7 @@ fn receiver_is_dispatchable<'tcx>(
if param.index == 0 { unsized_self_ty.into() } else { tcx.mk_param_from_def(param) }
});
ty::Binder::dummy(ty::TraitRef::new(tcx, trait_def_id, substs)).to_predicate(tcx)
ty::TraitRef::new(tcx, trait_def_id, substs).to_predicate(tcx)
};
let caller_bounds =
@ -799,11 +799,8 @@ fn receiver_is_dispatchable<'tcx>(
// Receiver: DispatchFromDyn<Receiver[Self => U]>
let obligation = {
let predicate = ty::Binder::dummy(ty::TraitRef::new(
tcx,
dispatch_from_dyn_did,
[receiver_ty, unsized_receiver_ty],
));
let predicate =
ty::TraitRef::new(tcx, dispatch_from_dyn_did, [receiver_ty, unsized_receiver_ty]);
Obligation::new(tcx, ObligationCause::dummy(), param_env, predicate)
};