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

@ -1784,7 +1784,7 @@ fn receiver_is_implemented<'tcx>(
receiver_ty: Ty<'tcx>, receiver_ty: Ty<'tcx>,
) -> bool { ) -> bool {
let tcx = wfcx.tcx(); let tcx = wfcx.tcx();
let trait_ref = ty::Binder::dummy(ty::TraitRef::new(tcx, receiver_trait_def_id, [receiver_ty])); let trait_ref = ty::TraitRef::new(tcx, receiver_trait_def_id, [receiver_ty]);
let obligation = traits::Obligation::new(tcx, cause, wfcx.param_env, trait_ref); let obligation = traits::Obligation::new(tcx, cause, wfcx.param_env, trait_ref);

View file

@ -340,11 +340,11 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
tcx, tcx,
cause.clone(), cause.clone(),
param_env, param_env,
ty::Binder::dummy(ty::TraitRef::new( ty::TraitRef::new(
tcx, tcx,
dispatch_from_dyn_trait, dispatch_from_dyn_trait,
[field.ty(tcx, substs_a), field.ty(tcx, substs_b)], [field.ty(tcx, substs_a), field.ty(tcx, substs_b)],
)), ),
)); ));
} }
let errors = ocx.select_all_or_error(); let errors = ocx.select_all_or_error();

View file

@ -1096,10 +1096,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx, self.tcx,
self.misc(expr.span), self.misc(expr.span),
self.param_env, self.param_env,
ty::Binder::dummy(ty::TraitRef::new(self.tcx, ty::TraitRef::new(self.tcx,
into_def_id, into_def_id,
[expr_ty, expected_ty] [expr_ty, expected_ty]
)), ),
)) ))
{ {
let sugg = if expr.precedence().order() >= PREC_POSTFIX { let sugg = if expr.precedence().order() >= PREC_POSTFIX {
@ -1438,7 +1438,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&& !results.expr_adjustments(callee_expr).iter().any(|adj| matches!(adj.kind, ty::adjustment::Adjust::Deref(..))) && !results.expr_adjustments(callee_expr).iter().any(|adj| matches!(adj.kind, ty::adjustment::Adjust::Deref(..)))
// Check that we're in fact trying to clone into the expected type // Check that we're in fact trying to clone into the expected type
&& self.can_coerce(*pointee_ty, expected_ty) && self.can_coerce(*pointee_ty, expected_ty)
&& let trait_ref = ty::Binder::dummy(ty::TraitRef::new(self.tcx, clone_trait_did, [expected_ty])) && let trait_ref = ty::TraitRef::new(self.tcx, clone_trait_did, [expected_ty])
// And the expected type doesn't implement `Clone` // And the expected type doesn't implement `Clone`
&& !self.predicate_must_hold_considering_regions(&traits::Obligation::new( && !self.predicate_must_hold_considering_regions(&traits::Obligation::new(
self.tcx, self.tcx,

View file

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