use rustc_type_ir::{self as ty, Interner};
use crate::infcx::SolverDelegate;
use crate::solve::{Certainty, EvalCtxt, Goal, GoalSource, QueryResult};
impl<Infcx, I> EvalCtxt<'_, Infcx>
where
Infcx: SolverDelegate<Interner = I>,
I: Interner,
{
pub(super) fn normalize_weak_type(
&mut self,
goal: Goal<I, ty::NormalizesTo<I>>,
) -> QueryResult<I> {
let tcx = self.interner();
let weak_ty = goal.predicate.alias;
self.add_goals(
GoalSource::Misc,
tcx.predicates_of(weak_ty.def_id)
.iter_instantiated(tcx, &weak_ty.args)
.map(|pred| goal.with(tcx, pred)),
);
let actual = tcx.type_of(weak_ty.def_id).instantiate(tcx, &weak_ty.args);
self.instantiate_normalizes_to_term(goal, actual.into());
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
}