rustc_next_trait_solver/solve/normalizes_to/
inherent.rs
1use rustc_type_ir::{self as ty, Interner};
9
10use crate::delegate::SolverDelegate;
11use crate::solve::{Certainty, EvalCtxt, Goal, GoalSource, QueryResult};
12
13impl<D, I> EvalCtxt<'_, D>
14where
15 D: SolverDelegate<Interner = I>,
16 I: Interner,
17{
18 pub(super) fn normalize_inherent_associated_type(
19 &mut self,
20 goal: Goal<I, ty::NormalizesTo<I>>,
21 ) -> QueryResult<I> {
22 let cx = self.cx();
23 let inherent = goal.predicate.alias.expect_ty(cx);
24
25 let impl_def_id = cx.parent(inherent.def_id);
26 let impl_args = self.fresh_args_for_item(impl_def_id);
27
28 self.eq(
30 goal.param_env,
31 inherent.self_ty(),
32 cx.type_of(impl_def_id).instantiate(cx, impl_args),
33 )?;
34
35 let inherent_args = inherent.rebase_inherent_args_onto_impl(impl_args, cx);
37
38 self.add_goals(
45 GoalSource::Misc,
46 cx.predicates_of(inherent.def_id)
47 .iter_instantiated(cx, inherent_args)
48 .map(|pred| goal.with(cx, pred)),
49 );
50
51 let normalized = cx.type_of(inherent.def_id).instantiate(cx, inherent_args);
52 self.instantiate_normalizes_to_term(goal, normalized.into());
53 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
54 }
55}