use rustc_type_ir::solve::QueryResultOrRerunNonErased;
use rustc_type_ir::{self as ty, Interner};
use tracing::instrument;

use crate::delegate::SolverDelegate;
use crate::solve::{EvalCtxt, Goal};

impl<D, I> EvalCtxt<'_, D>
where
    D: SolverDelegate<Interner = I>,
    I: Interner,
{
    #[instrument(level = "trace", skip(self), ret)]
    pub(super) fn normalize_anon_const(
        &mut self,
        goal: Goal<I, ty::ProjectionPredicate<I>>,
    ) -> QueryResultOrRerunNonErased<I> {
        let alias_const = goal.predicate.projection_term.expect_ct();
        self.evaluate_const_and_instantiate_projection_term(
            goal.param_env,
            goal.predicate.projection_term,
            goal.predicate.term,
            alias_const,
        )
    }
}
