Fast path for stalled obligations on self ty

This commit is contained in:
Michael Goulet
2025-05-28 11:14:43 +00:00
parent 2398bd60ef
commit 3418d5db3a
3 changed files with 13 additions and 6 deletions

View File

@@ -64,6 +64,16 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
span: Span,
) -> Option<Certainty> {
if let Some(trait_pred) = goal.predicate.as_trait_clause() {
if self.shallow_resolve(trait_pred.self_ty().skip_binder()).is_ty_var()
// We don't do this fast path when opaques are defined since we may
// eventually use opaques to incompletely guide inference via ty var
// self types.
// FIXME: Properly consider opaques here.
&& self.inner.borrow_mut().opaque_types().is_empty()
{
return Some(Certainty::AMBIGUOUS);
}
if trait_pred.polarity() == ty::PredicatePolarity::Positive {
match self.0.tcx.as_lang_item(trait_pred.def_id()) {
Some(LangItem::Sized)