Skip to content

Commit 6726382

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 + 4252464 commit 6726382

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

compiler/rustc_infer/src/infer/context.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
9696
false
9797
}
9898
ty::GenericArgKind::Type(ty) => {
99-
if let ty::Infer(infer_ty) = *ty.kind() {
100-
match infer_ty {
99+
match *ty.kind() {
100+
ty::Infer(infer_ty) => match infer_ty {
101101
ty::InferTy::TyVar(vid) => {
102102
!self.probe_ty_var(vid).is_err_and(|_| self.root_var(vid) == vid)
103103
}
@@ -119,22 +119,24 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
119119
}
120120
ty::InferTy::FreshTy(_)
121121
| ty::InferTy::FreshIntTy(_)
122-
| ty::InferTy::FreshFloatTy(_) => true,
123-
}
124-
} else {
125-
true
122+
| ty::InferTy::FreshFloatTy(_) => unreachable!(),
123+
},
124+
// This was a canonicalized universal var, so it doesn't change.
125+
ty::Param(_) | ty::Placeholder(_) => false,
126+
_ => unreachable!("unexpected orig value: {arg}"),
126127
}
127128
}
128129
ty::GenericArgKind::Const(ct) => {
129-
if let ty::ConstKind::Infer(infer_ct) = ct.kind() {
130-
match infer_ct {
130+
match ct.kind() {
131+
ty::ConstKind::Infer(infer_ct) => match infer_ct {
131132
ty::InferConst::Var(vid) => !self
132133
.probe_const_var(vid)
133134
.is_err_and(|_| self.root_const_var(vid) == vid),
134135
ty::InferConst::Fresh(_) => true,
135-
}
136-
} else {
137-
true
136+
},
137+
// This was a canonicalized universal var, so it doesn't change.
138+
ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(_) => false,
139+
_ => unreachable!("unexpected orig value: {arg}"),
138140
}
139141
}
140142
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ 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+
// Remove the unconstrained RHS arg, which is expected to have changed.
549549
if let Some(normalizes_to) = goal.predicate.as_normalizes_to() {
550550
let normalizes_to = normalizes_to.skip_binder();
551551
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)