1 use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
2 use crate::traits::query::Fallible;
3 use rustc_middle::ty::fold::TypeFoldable;
4 use rustc_middle::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt};
7 pub use rustc_middle::traits::query::type_op::Normalize;
9 impl<'tcx, T> super::QueryTypeOp<'tcx> for Normalize<T>
11 T: Normalizable<'tcx> + 'tcx,
13 type QueryResponse = T;
15 fn try_fast_path(_tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<T> {
16 if !key.value.value.has_projections() { Some(key.value.value) } else { None }
21 canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
22 ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self::QueryResponse>> {
23 T::type_op_method(tcx, canonicalized)
27 pub trait Normalizable<'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'tcx> + Copy {
30 canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
31 ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>>;
34 impl<'tcx> Normalizable<'tcx> for Ty<'tcx> {
37 canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
38 ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
39 tcx.type_op_normalize_ty(canonicalized)
43 impl<'tcx> Normalizable<'tcx> for ty::Predicate<'tcx> {
46 canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
47 ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
48 tcx.type_op_normalize_predicate(canonicalized)
52 impl<'tcx> Normalizable<'tcx> for ty::PolyFnSig<'tcx> {
55 canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
56 ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
57 tcx.type_op_normalize_poly_fn_sig(canonicalized)
61 impl<'tcx> Normalizable<'tcx> for ty::FnSig<'tcx> {
64 canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
65 ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
66 tcx.type_op_normalize_fn_sig(canonicalized)