Auto merge of #143500 - compiler-errors:characterize-less, r=lcnr

Skip walking into param-env component if it has no placeholder/re-var

Although it only provides a minor perf improvement, it seems like it could matter in more pathological cases.
This commit is contained in:
bors
2025-07-26 16:57:45 +00:00
@@ -10,8 +10,8 @@
use rustc_type_ir::lang_items::TraitSolverLangItem;
use rustc_type_ir::solve::SizedTraitKind;
use rustc_type_ir::{
self as ty, Interner, TypeFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt as _,
TypeVisitor, TypingMode, Upcast as _, elaborate,
self as ty, Interner, TypeFlags, TypeFoldable, TypeSuperVisitable, TypeVisitable,
TypeVisitableExt as _, TypeVisitor, TypingMode, Upcast as _, elaborate,
};
use tracing::{debug, instrument};
@@ -132,6 +132,7 @@ fn probe_and_consider_param_env_candidate(
})
.enter(|ecx| {
Self::match_assumption(ecx, goal, assumption, |ecx| {
ecx.try_evaluate_added_goals()?;
source.set(ecx.characterize_param_env_assumption(goal.param_env, assumption)?);
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})
@@ -1069,8 +1070,10 @@ fn visit_ty(&mut self, ty: I::Ty) -> Self::Result {
} else {
ControlFlow::Continue(())
}
} else {
} else if ty.has_type_flags(TypeFlags::HAS_PLACEHOLDER | TypeFlags::HAS_RE_INFER) {
ty.super_visit_with(self)
} else {
ControlFlow::Continue(())
}
}
@@ -1086,8 +1089,10 @@ fn visit_const(&mut self, ct: I::Const) -> Self::Result {
} else {
ControlFlow::Continue(())
}
} else {
} else if ct.has_type_flags(TypeFlags::HAS_PLACEHOLDER | TypeFlags::HAS_RE_INFER) {
ct.super_visit_with(self)
} else {
ControlFlow::Continue(())
}
}