rustc_next_trait_solver/solve/normalizes_to/
weak_types.rs

1//! Computes a normalizes-to (projection) goal for inherent associated types,
2//! `#![feature(lazy_type_alias)]` and `#![feature(type_alias_impl_trait)]`.
3//!
4//! Since a weak alias is never ambiguous, this just computes the `type_of` of
5//! the alias and registers the where-clauses of the type alias.
6
7use rustc_type_ir::{self as ty, Interner};
8
9use crate::delegate::SolverDelegate;
10use crate::solve::{Certainty, EvalCtxt, Goal, GoalSource, QueryResult};
11
12impl<D, I> EvalCtxt<'_, D>
13where
14    D: SolverDelegate<Interner = I>,
15    I: Interner,
16{
17    pub(super) fn normalize_weak_type(
18        &mut self,
19        goal: Goal<I, ty::NormalizesTo<I>>,
20    ) -> QueryResult<I> {
21        let cx = self.cx();
22        let weak_ty = goal.predicate.alias;
23
24        // Check where clauses
25        self.add_goals(
26            GoalSource::Misc,
27            cx.predicates_of(weak_ty.def_id)
28                .iter_instantiated(cx, weak_ty.args)
29                .map(|pred| goal.with(cx, pred)),
30        );
31
32        let actual = cx.type_of(weak_ty.def_id).instantiate(cx, weak_ty.args);
33        self.instantiate_normalizes_to_term(goal, actual.into());
34
35        self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
36    }
37}