Skip to content

Filter out universals and lifetimes from stalled_vars #142088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,19 @@ where
// to recompute this goal.
HasChanged::Yes => None,
HasChanged::No => {
// Remove the unconstrained RHS arg, which is expected to have changed.
let mut stalled_vars = orig_values;

// Remove the canonicalized universal vars, since we only care about stalled existentials.
stalled_vars.retain(|arg| match arg.kind() {
ty::GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Infer(_)),
ty::GenericArgKind::Const(ct) => {
matches!(ct.kind(), ty::ConstKind::Infer(_))
}
// Lifetimes can never stall goals.
ty::GenericArgKind::Lifetime(_) => false,
});

// Remove the unconstrained RHS arg, which is expected to have changed.
if let Some(normalizes_to) = goal.predicate.as_normalizes_to() {
let normalizes_to = normalizes_to.skip_binder();
let rhs_arg: I::GenericArg = normalizes_to.term.into();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ pub(super) fn fulfillment_error_for_stalled<'tcx>(
false,
),
Ok(GoalEvaluation { certainty: Certainty::Yes, .. }) => {
bug!(
span_bug!(
root_obligation.cause.span,
"did not expect successful goal when collecting ambiguity errors for `{:?}`",
infcx.resolve_vars_if_possible(root_obligation.predicate),
)
}
Err(_) => {
bug!(
span_bug!(
root_obligation.cause.span,
"did not expect selection error when collecting ambiguity errors for `{:?}`",
infcx.resolve_vars_if_possible(root_obligation.predicate),
)
Expand Down
Loading