From 0b323eacd4c4cf99d18bd75ad02b2139dd990297 Mon Sep 17 00:00:00 2001 From: lcnr Date: Thu, 24 Jul 2025 14:53:13 +0000 Subject: uniquify root goals during HIR typeck --- compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs | 2 ++ compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs | 5 ++++- compiler/rustc_next_trait_solver/src/solve/mod.rs | 2 -- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_next_trait_solver/src/solve') diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs index 5ed316aa6b1..de1330ca82a 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs @@ -55,6 +55,7 @@ where /// for each bound variable. pub(super) fn canonicalize_goal( &self, + is_hir_typeck_root_goal: bool, goal: Goal, ) -> (Vec, CanonicalInput) { // We only care about one entry per `OpaqueTypeKey` here, @@ -67,6 +68,7 @@ where let canonical = Canonicalizer::canonicalize_input( self.delegate, &mut orig_values, + is_hir_typeck_root_goal, QueryInput { goal, predefined_opaques_in_body: self diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs index ce9b794d40d..053ccf285cf 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs @@ -447,7 +447,10 @@ where )); } - let (orig_values, canonical_goal) = self.canonicalize_goal(goal); + let is_hir_typeck_root_goal = matches!(goal_evaluation_kind, GoalEvaluationKind::Root) + && self.delegate.in_hir_typeck(); + + let (orig_values, canonical_goal) = self.canonicalize_goal(is_hir_typeck_root_goal, goal); let mut goal_evaluation = self.inspect.new_goal_evaluation(goal, &orig_values, goal_evaluation_kind); let canonical_result = self.search_graph.evaluate_goal( diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs index 5ea3f0d1061..f39426c7689 100644 --- a/compiler/rustc_next_trait_solver/src/solve/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs @@ -252,8 +252,6 @@ where return None; } - // FIXME(-Znext-solver): Add support to merge region constraints in - // responses to deal with trait-system-refactor-initiative#27. let one = responses[0]; if responses[1..].iter().all(|&resp| resp == one) { return Some(one); -- cgit 1.4.1-3-g733a5