Skip to content

Commit 90b7f30

Browse files
Auto merge of #144698 - compiler-errors:perf-stall-norm, r=<try>
Stall `ProjectionPredicate` and `NormalizesTo` on infer self ty too
2 parents e5e79f8 + bc3cb42 commit 90b7f30

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

compiler/rustc_trait_selection/src/solve/delegate.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,27 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
6363
goal: Goal<'tcx, ty::Predicate<'tcx>>,
6464
span: Span,
6565
) -> Option<Certainty> {
66-
if let Some(trait_pred) = goal.predicate.as_trait_clause() {
67-
if self.shallow_resolve(trait_pred.self_ty().skip_binder()).is_ty_var()
66+
let self_ty = match goal.predicate.kind().skip_binder() {
67+
ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)) => {
68+
Some(trait_pred.self_ty())
69+
}
70+
ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj_pred)) => {
71+
Some(proj_pred.self_ty())
72+
}
73+
ty::PredicateKind::NormalizesTo(normalizes_to) => Some(normalizes_to.self_ty()),
74+
_ => None,
75+
};
76+
if let Some(self_ty) = self_ty && self.shallow_resolve(self_ty).is_ty_var()
6877
// We don't do this fast path when opaques are defined since we may
6978
// eventually use opaques to incompletely guide inference via ty var
7079
// self types.
7180
// FIXME: Properly consider opaques here.
7281
&& self.inner.borrow_mut().opaque_types().is_empty()
73-
{
74-
return Some(Certainty::AMBIGUOUS);
75-
}
82+
{
83+
return Some(Certainty::AMBIGUOUS);
84+
}
7685

86+
if let Some(trait_pred) = goal.predicate.as_trait_clause() {
7787
if trait_pred.polarity() == ty::PredicatePolarity::Positive {
7888
match self.0.tcx.as_lang_item(trait_pred.def_id()) {
7989
Some(LangItem::Sized) | Some(LangItem::MetaSized) => {

0 commit comments

Comments
 (0)