Skip to main content

rustc_next_trait_solver/solve/
project_goals.rs

1use rustc_type_ir::solve::QueryResultOrRerunNonErased;
2use rustc_type_ir::{self as ty, Interner, ProjectionPredicate};
3use tracing::instrument;
4
5use crate::delegate::SolverDelegate;
6use crate::solve::{Certainty, EvalCtxt, Goal, GoalSource};
7
8impl<D, I> EvalCtxt<'_, D>
9where
10    D: SolverDelegate<Interner = I>,
11    I: Interner,
12{
13    x;#[instrument(level = "trace", skip(self), ret)]
14    pub(super) fn compute_projection_goal(
15        &mut self,
16        goal: Goal<I, ProjectionPredicate<I>>,
17    ) -> QueryResultOrRerunNonErased<I> {
18        let cx = self.cx();
19        let projection_term = goal.predicate.projection_term.to_term(cx);
20        let goal = goal.with(
21            cx,
22            ty::PredicateKind::AliasRelate(
23                projection_term,
24                goal.predicate.term,
25                ty::AliasRelationDirection::Equate,
26            ),
27        );
28        // A projection goal holds if the alias is equal to the expected term.
29        self.add_goal(GoalSource::TypeRelating, goal);
30        self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
31    }
32}