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 00fd3ba80465e..780feb9b827a6 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 @@ -147,13 +147,9 @@ pub trait SolverDelegateEvalExt: SolverDelegate { fn evaluate_root_goal( &self, goal: Goal::Predicate>, - generate_proof_tree: GenerateProofTree, span: ::Span, stalled_on: Option>, - ) -> ( - Result, NoSolution>, - Option>, - ); + ) -> Result, NoSolution>; /// Check whether evaluating `goal` with a depth of `root_depth` may /// succeed. This only returns `false` if the goal is guaranteed to @@ -170,17 +166,16 @@ pub trait SolverDelegateEvalExt: SolverDelegate { // FIXME: This is only exposed because we need to use it in `analyse.rs` // which is not yet uplifted. Once that's done, we should remove this. - fn evaluate_root_goal_raw( + fn evaluate_root_goal_for_proof_tree( &self, goal: Goal::Predicate>, - generate_proof_tree: GenerateProofTree, - stalled_on: Option>, + span: ::Span, ) -> ( Result< (NestedNormalizationGoals, GoalEvaluation), NoSolution, >, - Option>, + inspect::GoalEvaluation, ); } @@ -193,13 +188,17 @@ where fn evaluate_root_goal( &self, goal: Goal, - generate_proof_tree: GenerateProofTree, span: I::Span, stalled_on: Option>, - ) -> (Result, NoSolution>, Option>) { - EvalCtxt::enter_root(self, self.cx().recursion_limit(), generate_proof_tree, span, |ecx| { - ecx.evaluate_goal(GoalEvaluationKind::Root, GoalSource::Misc, goal, stalled_on) - }) + ) -> Result, NoSolution> { + EvalCtxt::enter_root( + self, + self.cx().recursion_limit(), + GenerateProofTree::No, + span, + |ecx| ecx.evaluate_goal(GoalEvaluationKind::Root, GoalSource::Misc, goal, stalled_on), + ) + .0 } fn root_goal_may_hold_with_depth( @@ -217,24 +216,22 @@ where } #[instrument(level = "debug", skip(self))] - fn evaluate_root_goal_raw( + fn evaluate_root_goal_for_proof_tree( &self, goal: Goal, - generate_proof_tree: GenerateProofTree, - stalled_on: Option>, + span: I::Span, ) -> ( Result<(NestedNormalizationGoals, GoalEvaluation), NoSolution>, - Option>, + inspect::GoalEvaluation, ) { - EvalCtxt::enter_root( + let (result, proof_tree) = EvalCtxt::enter_root( self, self.cx().recursion_limit(), - generate_proof_tree, - I::Span::dummy(), - |ecx| { - ecx.evaluate_goal_raw(GoalEvaluationKind::Root, GoalSource::Misc, goal, stalled_on) - }, - ) + GenerateProofTree::Yes, + span, + |ecx| ecx.evaluate_goal_raw(GoalEvaluationKind::Root, GoalSource::Misc, goal, None), + ); + (result, proof_tree.unwrap()) } } diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index ed99c678a4d2e..d56042a5ca2af 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -14,7 +14,7 @@ use rustc_middle::ty::{ }; use rustc_next_trait_solver::delegate::SolverDelegate as _; use rustc_next_trait_solver::solve::{ - GenerateProofTree, GoalEvaluation, GoalStalledOn, HasChanged, SolverDelegateEvalExt as _, + GoalEvaluation, GoalStalledOn, HasChanged, SolverDelegateEvalExt as _, }; use rustc_span::Span; use thin_vec::ThinVec; @@ -106,14 +106,11 @@ impl<'tcx> ObligationStorage<'tcx> { self.overflowed.extend( ExtractIf::new(&mut self.pending, |(o, stalled_on)| { let goal = o.as_goal(); - let result = <&SolverDelegate<'tcx>>::from(infcx) - .evaluate_root_goal( - goal, - GenerateProofTree::No, - o.cause.span, - stalled_on.take(), - ) - .0; + let result = <&SolverDelegate<'tcx>>::from(infcx).evaluate_root_goal( + goal, + o.cause.span, + stalled_on.take(), + ); matches!(result, Ok(GoalEvaluation { has_changed: HasChanged::Yes, .. })) }) .map(|(o, _)| o), @@ -207,14 +204,7 @@ where continue; } - let result = delegate - .evaluate_root_goal( - goal, - GenerateProofTree::No, - obligation.cause.span, - stalled_on, - ) - .0; + let result = delegate.evaluate_root_goal(goal, obligation.cause.span, stalled_on); self.inspect_evaluated_obligation(infcx, &obligation, &result); let GoalEvaluation { certainty, has_changed, stalled_on } = match result { Ok(result) => result, diff --git a/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs b/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs index 36a8ae675c0ea..fe248b033bb9f 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs @@ -11,9 +11,7 @@ use rustc_middle::traits::query::NoSolution; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::{bug, span_bug}; -use rustc_next_trait_solver::solve::{ - GenerateProofTree, GoalEvaluation, SolverDelegateEvalExt as _, -}; +use rustc_next_trait_solver::solve::{GoalEvaluation, SolverDelegateEvalExt as _}; use tracing::{instrument, trace}; use crate::solve::delegate::SolverDelegate; @@ -90,15 +88,11 @@ pub(super) fn fulfillment_error_for_stalled<'tcx>( root_obligation: PredicateObligation<'tcx>, ) -> FulfillmentError<'tcx> { let (code, refine_obligation) = infcx.probe(|_| { - match <&SolverDelegate<'tcx>>::from(infcx) - .evaluate_root_goal( - root_obligation.as_goal(), - GenerateProofTree::No, - root_obligation.cause.span, - None, - ) - .0 - { + match <&SolverDelegate<'tcx>>::from(infcx).evaluate_root_goal( + root_obligation.as_goal(), + root_obligation.cause.span, + None, + ) { Ok(GoalEvaluation { certainty: Certainty::Maybe(MaybeCause::Ambiguity), .. }) => { (FulfillmentErrorCode::Ambiguity { overflow: None }, true) } diff --git a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs index b0c8fa1f217d2..80df0fab2d83f 100644 --- a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs +++ b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs @@ -20,7 +20,7 @@ use rustc_middle::ty::{TyCtxt, VisitorResult, try_visit}; use rustc_middle::{bug, ty}; use rustc_next_trait_solver::resolve::eager_resolve_vars; use rustc_next_trait_solver::solve::inspect::{self, instantiate_canonical_state}; -use rustc_next_trait_solver::solve::{GenerateProofTree, MaybeCause, SolverDelegateEvalExt as _}; +use rustc_next_trait_solver::solve::{MaybeCause, SolverDelegateEvalExt as _}; use rustc_span::Span; use tracing::instrument; @@ -248,9 +248,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> { // considering the constrained RHS, and pass the resulting certainty to // `InspectGoal::new` so that the goal has the right result (and maintains // the impression that we don't do this normalizes-to infer hack at all). - let (nested, proof_tree) = - infcx.evaluate_root_goal_raw(goal, GenerateProofTree::Yes, None); - let proof_tree = proof_tree.unwrap(); + let (nested, proof_tree) = infcx.evaluate_root_goal_for_proof_tree(goal, span); let nested_goals_result = nested.and_then(|(nested, _)| { normalizes_to_term_hack.constrain_and( infcx, @@ -284,9 +282,8 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> { // into another candidate who ends up with different inference // constraints, we get an ICE if we already applied the constraints // from the chosen candidate. - let proof_tree = infcx - .probe(|_| infcx.evaluate_root_goal(goal, GenerateProofTree::Yes, span, None).1) - .unwrap(); + let proof_tree = + infcx.probe(|_| infcx.evaluate_root_goal_for_proof_tree(goal, span).1); InspectGoal::new(infcx, self.goal.depth + 1, proof_tree, None, source) } } @@ -488,13 +485,8 @@ impl<'tcx> InferCtxt<'tcx> { depth: usize, visitor: &mut V, ) -> V::Result { - let (_, proof_tree) = <&SolverDelegate<'tcx>>::from(self).evaluate_root_goal( - goal, - GenerateProofTree::Yes, - visitor.span(), - None, - ); - let proof_tree = proof_tree.unwrap(); + let (_, proof_tree) = <&SolverDelegate<'tcx>>::from(self) + .evaluate_root_goal_for_proof_tree(goal, visitor.span()); visitor.visit_goal(&InspectGoal::new(self, depth, proof_tree, None, GoalSource::Misc)) } }