From e13757e17463e9f86b4eea492b8ee3ae22875675 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 5 Jul 2025 18:40:00 +0000 Subject: [PATCH] [perf] Skip walking into param-env component if it has no placeholder/re-var --- .../src/solve/assembly/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs index c281ef216c788..b2d4014634855 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs @@ -10,8 +10,8 @@ use rustc_type_ir::inherent::*; 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 @@ where }) .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 @@ where } 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 @@ where } 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(()) } }