Skip to content

Commit 60e7462

Browse files
Auto merge of #142088 - compiler-errors:perf-universal-stall, r=<try>
Filter out universals and lifetimes from `stalled_vars` lol r? lcnr
2 parents c360e21 + 68fc0b9 commit 60e7462

File tree

2 files changed

+16
-3
lines changed
  • compiler

2 files changed

+16
-3
lines changed

compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,19 @@ where
544544
// to recompute this goal.
545545
HasChanged::Yes => None,
546546
HasChanged::No => {
547-
// Remove the unconstrained RHS arg, which is expected to have changed.
548547
let mut stalled_vars = orig_values;
548+
549+
// Remove the canonicalized universal vars, since we only care about stalled existentials.
550+
stalled_vars.retain(|arg| match arg.kind() {
551+
ty::GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Infer(_)),
552+
ty::GenericArgKind::Const(ct) => {
553+
matches!(ct.kind(), ty::ConstKind::Infer(_))
554+
}
555+
// Lifetimes can never stall goals.
556+
ty::GenericArgKind::Lifetime(_) => false,
557+
});
558+
559+
// Remove the unconstrained RHS arg, which is expected to have changed.
549560
if let Some(normalizes_to) = goal.predicate.as_normalizes_to() {
550561
let normalizes_to = normalizes_to.skip_binder();
551562
let rhs_arg: I::GenericArg = normalizes_to.term.into();

compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,15 @@ pub(super) fn fulfillment_error_for_stalled<'tcx>(
120120
false,
121121
),
122122
Ok(GoalEvaluation { certainty: Certainty::Yes, .. }) => {
123-
bug!(
123+
span_bug!(
124+
root_obligation.cause.span,
124125
"did not expect successful goal when collecting ambiguity errors for `{:?}`",
125126
infcx.resolve_vars_if_possible(root_obligation.predicate),
126127
)
127128
}
128129
Err(_) => {
129-
bug!(
130+
span_bug!(
131+
root_obligation.cause.span,
130132
"did not expect selection error when collecting ambiguity errors for `{:?}`",
131133
infcx.resolve_vars_if_possible(root_obligation.predicate),
132134
)

0 commit comments

Comments
 (0)