about summary refs log tree commit diff
path: root/compiler/rustc_next_trait_solver/src
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-04-25 00:55:28 +0000
committerMichael Goulet <michael@errs.io>2025-04-28 17:15:11 +0000
commit105d1dcefd9baa520e63830f557d9c472f50d4fd (patch)
treee3fe976a3b1f4f0efd533d462d9f8166b92d2924 /compiler/rustc_next_trait_solver/src
parenta932eb36f8adf6c8cdfc450f063943da3112d621 (diff)
downloadrust-105d1dcefd9baa520e63830f557d9c472f50d4fd.tar.gz
rust-105d1dcefd9baa520e63830f557d9c472f50d4fd.zip
Do not compute type_of for impl item if impl where clauses are unsatisfied
Diffstat (limited to 'compiler/rustc_next_trait_solver/src')
-rw-r--r--compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs
index 119d197de13..fa8cfbba7fc 100644
--- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs
@@ -194,6 +194,12 @@ where
                 .map(|pred| goal.with(cx, pred));
             ecx.add_goals(GoalSource::ImplWhereBound, where_clause_bounds);
 
+            // Bail if the nested goals don't hold here. This is to avoid unnecessarily
+            // computing the `type_of` query for associated types that never apply, as
+            // this may result in query cycles in the case of RPITITs.
+            // See <https://github.com/rust-lang/trait-system-refactor-initiative/issues/185>.
+            ecx.try_evaluate_added_goals()?;
+
             // Add GAT where clauses from the trait's definition.
             // FIXME: We don't need these, since these are the type's own WF obligations.
             ecx.add_goals(