Simplify API of solver a bit
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user