about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-26 16:57:45 +0000
committerbors <bors@rust-lang.org>2025-07-26 16:57:45 +0000
commitce5fdd7d42aba9a2925692e11af2bd39cf37798a (patch)
tree864df2c7aa41572b14d4a3b1fe6308bd622cdd5d
parent133798f9fb2887bcccf1098937540e280dd58465 (diff)
parente13757e17463e9f86b4eea492b8ee3ae22875675 (diff)
downloadrust-ce5fdd7d42aba9a2925692e11af2bd39cf37798a.tar.gz
rust-ce5fdd7d42aba9a2925692e11af2bd39cf37798a.zip
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.
-rw-r--r--compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs13
1 files 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 c281ef216c7..b2d40146348 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(())
         }
     }