Skip to main content

rustc_type_ir/
predicate.rs

1use std::hash::Hash;
2use std::{fmt, iter};
3
4use derive_where::derive_where;
5#[cfg(feature = "nightly")]
6use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash, StableHash_NoContext};
7use rustc_type_ir_macros::{
8    GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic,
9};
10
11use crate::inherent::*;
12use crate::lang_items::SolverTraitLangItem;
13use crate::upcast::{Upcast, UpcastFrom};
14use crate::visit::TypeVisitableExt as _;
15use crate::{self as ty, Alias, Binder, ClauseKind, Interner, Region};
16
17/// `A: 'region`
18#[automatically_derived]
impl<I: Interner, A> ::core::clone::Clone for OutlivesClause<I, A> where
    I: Interner, A: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            OutlivesClause(ref __field_0, ref __field_1) =>
                OutlivesClause {
                    0: ::core::clone::Clone::clone(__field_0),
                    1: ::core::clone::Clone::clone(__field_1),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner, A> ::core::hash::Hash for OutlivesClause<I, A> where
    I: Interner, A: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            OutlivesClause(ref __field_0, ref __field_1) => {
                ::core::hash::Hash::hash(__field_0, __state);
                ::core::hash::Hash::hash(__field_1, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, A> ::core::cmp::PartialEq for OutlivesClause<I, A> where
    I: Interner, A: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (OutlivesClause(ref __field_0, ref __field_1),
                OutlivesClause(ref __other_field_0, ref __other_field_1)) =>
                true && ::core::cmp::PartialEq::eq(__field_0, __other_field_0)
                    && ::core::cmp::PartialEq::eq(__field_1, __other_field_1),
        }
    }
}
#[automatically_derived]
impl<I: Interner, A> ::core::fmt::Debug for OutlivesClause<I, A> where
    I: Interner, A: ::core::fmt::Debug {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            OutlivesClause(ref __field_0, ref __field_1) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "OutlivesClause");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::field(&mut __builder, __field_1);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, A> ::core::marker::Copy for OutlivesClause<I, A> where
    I: Interner, A: Copy {
}#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, A)]
19#[derive_where(Copy; I: Interner, A: Copy)]
20#[derive(const _: () =
    {
        impl<I: Interner, A> ::rustc_type_ir::TypeVisitable<I> for
            OutlivesClause<I, A> where I: Interner,
            A: ::rustc_type_ir::TypeVisitable<I>,
            Region<I>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    OutlivesClause(ref __binding_0, ref __binding_1) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, A, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            OutlivesClause<I, A> where
            A: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    OutlivesClause(ref __binding_0, ref __binding_1) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner, A> ::rustc_type_ir::TypeFoldable<I> for
            OutlivesClause<I, A> where I: Interner,
            A: ::rustc_type_ir::TypeFoldable<I>,
            A: ::rustc_type_ir::TypeFoldable<I>,
            Region<I>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        OutlivesClause(__binding_0, __binding_1) => {
                            OutlivesClause(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    OutlivesClause(__binding_0, __binding_1) => {
                        OutlivesClause(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, A, J> ::rustc_type_ir::lift::Lift<J> for
            OutlivesClause<I, A> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J>, A: ::rustc_type_ir::lift::Lift<J>
            {
            type Lifted =
                OutlivesClause<J,
                <A as ::rustc_type_ir::lift::Lift<J>>::Lifted>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    OutlivesClause(__binding_0, __binding_1) => {
                        OutlivesClause(__binding_0.lift_to_interner(interner),
                            __binding_1.lift_to_interner(interner))
                    }
                }
            }
        }
    };Lift_Generic)]
21#[cfg_attr(
22    feature = "nightly",
23    derive(const _: () =
    {
        impl<I: Interner, A, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for OutlivesClause<I, A> where
            A: ::rustc_serialize::Decodable<__D>,
            Region<I>: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                OutlivesClause(::rustc_serialize::Decodable::decode(__decoder),
                    ::rustc_serialize::Decodable::decode(__decoder))
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, A, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for OutlivesClause<I, A> where
            A: ::rustc_serialize::Encodable<__E>,
            Region<I>: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let OutlivesClause(ref __binding_0, ref __binding_1) = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner, A> ::rustc_data_structures::stable_hash::StableHash
            for OutlivesClause<I, A> where
            A: ::rustc_data_structures::stable_hash::StableHash,
            Region<I>: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    OutlivesClause(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
24)]
25pub struct OutlivesClause<I: Interner, A>(pub A, pub Region<I>);
26
27impl<I: Interner, A: Eq> Eq for OutlivesClause<I, A> {}
28
29/// `'a == 'b`.
30/// For the rationale behind having this instead of a pair of bidirectional
31/// `'a: 'b` and `'b: 'a`, see
32/// [this discusstion on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/A.20question.20on.20.23251/near/584167074).
33#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for RegionEqPredicate<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for RegionEqPredicate<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for RegionEqPredicate<I> where
    I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            RegionEqPredicate(ref __field_0, ref __field_1) => {
                ::core::hash::Hash::hash(__field_0, __state);
                ::core::hash::Hash::hash(__field_1, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for RegionEqPredicate<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (RegionEqPredicate(ref __field_0, ref __field_1),
                RegionEqPredicate(ref __other_field_0, ref __other_field_1))
                =>
                true && ::core::cmp::PartialEq::eq(__field_0, __other_field_0)
                    && ::core::cmp::PartialEq::eq(__field_1, __other_field_1),
        }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner> DeriveWhereAssertEq for RegionEqPredicate<I> where
            I: Interner {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<Region<I>>;
                let _: __AssertEq<Region<I>>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner> ::core::cmp::Eq for RegionEqPredicate<I> where I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for RegionEqPredicate<I> where
    I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            RegionEqPredicate(ref __field_0, ref __field_1) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f,
                        "RegionEqPredicate");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::field(&mut __builder, __field_1);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
34#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            RegionEqPredicate<I> where I: Interner,
            Region<I>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    RegionEqPredicate(ref __binding_0, ref __binding_1) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            RegionEqPredicate<I> where
            Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    RegionEqPredicate(ref __binding_0, ref __binding_1) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            RegionEqPredicate<I> where I: Interner,
            Region<I>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        RegionEqPredicate(__binding_0, __binding_1) => {
                            RegionEqPredicate(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    RegionEqPredicate(__binding_0, __binding_1) => {
                        RegionEqPredicate(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
            RegionEqPredicate<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = RegionEqPredicate<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    RegionEqPredicate(__binding_0, __binding_1) => {
                        RegionEqPredicate(__binding_0.lift_to_interner(interner),
                            __binding_1.lift_to_interner(interner))
                    }
                }
            }
        }
    };Lift_Generic)]
35#[cfg_attr(
36    feature = "nightly",
37    derive(const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for RegionEqPredicate<I> where
            Region<I>: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                RegionEqPredicate(::rustc_serialize::Decodable::decode(__decoder),
                    ::rustc_serialize::Decodable::decode(__decoder))
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for RegionEqPredicate<I> where
            Region<I>: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let RegionEqPredicate(ref __binding_0, ref __binding_1) =
                    *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            RegionEqPredicate<I> where
            Region<I>: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    RegionEqPredicate(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
38)]
39pub struct RegionEqPredicate<I: Interner>(pub Region<I>, pub Region<I>);
40
41impl<I: Interner> RegionEqPredicate<I> {
42    /// Decompose `'a == 'b` into `['a: 'b, 'b: 'a]`
43    pub fn into_bidirectional_outlives(self) -> [OutlivesClause<I, I::GenericArg>; 2] {
44        [OutlivesClause(self.0.into(), self.1), OutlivesClause(self.1.into(), self.0)]
45    }
46}
47
48#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for RegionConstraint<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for RegionConstraint<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for RegionConstraint<I> where I: Interner
    {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            RegionConstraint::Outlives(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            RegionConstraint::Eq(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for RegionConstraint<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        if ::core::mem::discriminant(self) ==
                ::core::mem::discriminant(__other) {
            match (self, __other) {
                (RegionConstraint::Outlives(ref __field_0),
                    RegionConstraint::Outlives(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (RegionConstraint::Eq(ref __field_0),
                    RegionConstraint::Eq(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                _ => unsafe { ::core::hint::unreachable_unchecked() },
            }
        } else { false }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner> DeriveWhereAssertEq for RegionConstraint<I> where
            I: Interner {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<OutlivesClause<I, I::GenericArg>>;
                let _: __AssertEq<RegionEqPredicate<I>>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner> ::core::cmp::Eq for RegionConstraint<I> where I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for RegionConstraint<I> where I: Interner
    {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            RegionConstraint::Outlives(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Outlives");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            RegionConstraint::Eq(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Eq");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
49#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            RegionConstraint<I> where I: Interner,
            OutlivesClause<I,
            I::GenericArg>: ::rustc_type_ir::TypeVisitable<I>,
            RegionEqPredicate<I>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    RegionConstraint::Outlives(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    RegionConstraint::Eq(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for RegionConstraint<I>
            where
            OutlivesClause<I,
            I::GenericArg>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            RegionEqPredicate<I>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    RegionConstraint::Outlives(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    RegionConstraint::Eq(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            RegionConstraint<I> where I: Interner,
            OutlivesClause<I,
            I::GenericArg>: ::rustc_type_ir::TypeFoldable<I>,
            RegionEqPredicate<I>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        RegionConstraint::Outlives(__binding_0) => {
                            RegionConstraint::Outlives(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                        RegionConstraint::Eq(__binding_0) => {
                            RegionConstraint::Eq(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    RegionConstraint::Outlives(__binding_0) => {
                        RegionConstraint::Outlives(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                    RegionConstraint::Eq(__binding_0) => {
                        RegionConstraint::Eq(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
            RegionConstraint<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = RegionConstraint<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    RegionConstraint::Outlives(__binding_0) => {
                        RegionConstraint::Outlives(__binding_0.lift_to_interner(interner))
                    }
                    RegionConstraint::Eq(__binding_0) => {
                        RegionConstraint::Eq(__binding_0.lift_to_interner(interner))
                    }
                }
            }
        }
    };Lift_Generic)]
50#[cfg_attr(
51    feature = "nightly",
52    derive(const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for RegionConstraint<I> where
            OutlivesClause<I,
            I::GenericArg>: ::rustc_serialize::Decodable<__D>,
            RegionEqPredicate<I>: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        RegionConstraint::Outlives(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        RegionConstraint::Eq(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `RegionConstraint`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for RegionConstraint<I> where
            OutlivesClause<I,
            I::GenericArg>: ::rustc_serialize::Encodable<__E>,
            RegionEqPredicate<I>: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        RegionConstraint::Outlives(ref __binding_0) => { 0usize }
                        RegionConstraint::Eq(ref __binding_0) => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    RegionConstraint::Outlives(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    RegionConstraint::Eq(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            RegionConstraint<I> where
            OutlivesClause<I,
            I::GenericArg>: ::rustc_data_structures::stable_hash::StableHash,
            RegionEqPredicate<I>: ::rustc_data_structures::stable_hash::StableHash
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    RegionConstraint::Outlives(ref __binding_0) =>
                        0u8.stable_hash(__hcx, __hasher),
                    RegionConstraint::Eq(ref __binding_0) =>
                        1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    RegionConstraint::Outlives(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    RegionConstraint::Eq(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
53)]
54pub enum RegionConstraint<I: Interner> {
55    Outlives(OutlivesClause<I, I::GenericArg>),
56    Eq(RegionEqPredicate<I>),
57}
58
59impl<I: Interner> From<OutlivesClause<I, I::GenericArg>> for RegionConstraint<I> {
60    fn from(value: OutlivesClause<I, I::GenericArg>) -> Self {
61        RegionConstraint::Outlives(value)
62    }
63}
64
65impl<I: Interner> From<RegionEqPredicate<I>> for RegionConstraint<I> {
66    fn from(value: RegionEqPredicate<I>) -> Self {
67        RegionConstraint::Eq(value)
68    }
69}
70
71impl<I: Interner> RegionConstraint<I> {
72    /// Whether the given constraint is either `'a: 'a` or `'a == 'a`.
73    pub fn is_trivial(self) -> bool {
74        match self {
75            RegionConstraint::Outlives(outlives) => {
76                outlives.0.as_region().is_some_and(|re| re == outlives.1)
77            }
78            RegionConstraint::Eq(eq) => eq.0 == eq.1,
79        }
80    }
81
82    /// If `self` is an eq constraint, iterate through its decomposed bidirectional outlives
83    /// bounds and if not, just iterate once for the outlives bound itself.
84    pub fn iter_outlives(self) -> impl Iterator<Item = OutlivesClause<I, I::GenericArg>> {
85        match self {
86            RegionConstraint::Outlives(outlives) => iter::once(outlives).chain(None),
87            RegionConstraint::Eq(eq) => {
88                let [outlives1, outlives2] = eq.into_bidirectional_outlives();
89                iter::once(outlives1).chain(Some(outlives2))
90            }
91        }
92    }
93}
94
95/// A complete reference to a trait.
96///
97/// These take numerous guises in syntax,
98/// but perhaps the most recognizable form is in a where-clause:
99/// ```ignore (illustrative)
100/// T: Foo<U>
101/// ```
102/// This would be represented by a trait-reference where the `DefId` is the
103/// `DefId` for the trait `Foo` and the args define `T` as parameter 0,
104/// and `U` as parameter 1.
105///
106/// Trait references also appear in object types like `Foo<U>`, but in
107/// that case the `Self` parameter is absent from the generic parameters.
108#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for TraitRef<I> where I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for TraitRef<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for TraitRef<I> where I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            TraitRef {
                def_id: ref __field_def_id,
                args: ref __field_args,
                _use_trait_ref_new_instead: ref __field__use_trait_ref_new_instead
                } => {
                ::core::hash::Hash::hash(__field_def_id, __state);
                ::core::hash::Hash::hash(__field_args, __state);
                ::core::hash::Hash::hash(__field__use_trait_ref_new_instead,
                    __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for TraitRef<I> where I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (TraitRef {
                def_id: ref __field_def_id,
                args: ref __field_args,
                _use_trait_ref_new_instead: ref __field__use_trait_ref_new_instead
                }, TraitRef {
                def_id: ref __other_field_def_id,
                args: ref __other_field_args,
                _use_trait_ref_new_instead: ref __other_field__use_trait_ref_new_instead
                }) =>
                true &&
                            ::core::cmp::PartialEq::eq(__field_def_id,
                                __other_field_def_id) &&
                        ::core::cmp::PartialEq::eq(__field_args, __other_field_args)
                    &&
                    ::core::cmp::PartialEq::eq(__field__use_trait_ref_new_instead,
                        __other_field__use_trait_ref_new_instead),
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
109#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for TraitRef<I>
            where I: Interner, I::TraitId: ::rustc_type_ir::TypeVisitable<I>,
            I::GenericArgs: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    TraitRef {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        _use_trait_ref_new_instead: ref __binding_2 } => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_2,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for TraitRef<I> where
            I::TraitId: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
            (): ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    TraitRef {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        _use_trait_ref_new_instead: ref __binding_2 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for TraitRef<I>
            where I: Interner, I::TraitId: ::rustc_type_ir::TypeFoldable<I>,
            I::GenericArgs: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        TraitRef {
                            def_id: __binding_0,
                            args: __binding_1,
                            _use_trait_ref_new_instead: __binding_2 } => {
                            TraitRef {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                args: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                                _use_trait_ref_new_instead: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    TraitRef {
                        def_id: __binding_0,
                        args: __binding_1,
                        _use_trait_ref_new_instead: __binding_2 } => {
                        TraitRef {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            args: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                            _use_trait_ref_new_instead: ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for TraitRef<I>
            where J: Interner, I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = TraitRef<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    TraitRef {
                        def_id: __binding_0,
                        args: __binding_1,
                        _use_trait_ref_new_instead: __binding_2 } => {
                        TraitRef {
                            def_id: __binding_0.lift_to_interner(interner),
                            args: __binding_1.lift_to_interner(interner),
                            _use_trait_ref_new_instead: __binding_2.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
110#[cfg_attr(
111    feature = "nightly",
112    derive(const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for TraitRef<I> where
            I::TraitId: ::rustc_serialize::Decodable<__D>,
            I::GenericArgs: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                TraitRef {
                    def_id: ::rustc_serialize::Decodable::decode(__decoder),
                    args: ::rustc_serialize::Decodable::decode(__decoder),
                    _use_trait_ref_new_instead: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for TraitRef<I> where
            I::TraitId: ::rustc_serialize::Encodable<__E>,
            I::GenericArgs: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let TraitRef {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        _use_trait_ref_new_instead: ref __binding_2 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            TraitRef<I> where
            I::TraitId: ::rustc_data_structures::stable_hash::StableHash,
            I::GenericArgs: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    TraitRef {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        _use_trait_ref_new_instead: ref __binding_2 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
113)]
114pub struct TraitRef<I: Interner> {
115    pub def_id: I::TraitId,
116    pub args: I::GenericArgs,
117    /// This field exists to prevent the creation of `TraitRef` without
118    /// calling [`TraitRef::new_from_args`].
119    _use_trait_ref_new_instead: (),
120}
121
122impl<I: Interner> Eq for TraitRef<I> {}
123
124impl<I: Interner> TraitRef<I> {
125    pub fn new_from_args(interner: I, trait_def_id: I::TraitId, args: I::GenericArgs) -> Self {
126        interner.debug_assert_args_compatible(trait_def_id.into(), args);
127        Self { def_id: trait_def_id, args, _use_trait_ref_new_instead: () }
128    }
129
130    pub fn new(
131        interner: I,
132        trait_def_id: I::TraitId,
133        args: impl IntoIterator<Item: Into<I::GenericArg>>,
134    ) -> Self {
135        let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
136        Self::new_from_args(interner, trait_def_id, args)
137    }
138
139    pub fn from_assoc(interner: I, trait_id: I::TraitId, args: I::GenericArgs) -> TraitRef<I> {
140        let generics = interner.generics_of(trait_id.into());
141        if generics.count() == args.len() {
142            // Can reuse `args` in its entirety.
143            TraitRef::new_from_args(interner, trait_id, args)
144        } else {
145            // Need only some of `args`.
146            TraitRef::new(interner, trait_id, args.iter().take(generics.count()))
147        }
148    }
149
150    /// Returns a `TraitRef` of the form `P0: Foo<P1..Pn>` where `Pi`
151    /// are the parameters defined on trait.
152    pub fn identity(interner: I, def_id: I::TraitId) -> TraitRef<I> {
153        TraitRef::new_from_args(
154            interner,
155            def_id,
156            I::GenericArgs::identity_for_item(interner, def_id.into()),
157        )
158    }
159
160    pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
161        TraitRef::new(
162            interner,
163            self.def_id,
164            [self_ty.into()].into_iter().chain(self.args.iter().skip(1)),
165        )
166    }
167
168    #[inline]
169    pub fn self_ty(&self) -> I::Ty {
170        self.args.type_at(0)
171    }
172}
173
174impl<I: Interner> ty::Binder<I, TraitRef<I>> {
175    pub fn self_ty(&self) -> ty::Binder<I, I::Ty> {
176        self.map_bound_ref(|tr| tr.self_ty())
177    }
178
179    pub fn def_id(&self) -> I::TraitId {
180        self.skip_binder().def_id
181    }
182
183    pub fn to_host_effect_clause(self, cx: I, constness: BoundConstness) -> I::Clause {
184        self.map_bound(|trait_ref| {
185            ty::ClauseKind::HostEffect(HostEffectClause { trait_ref, constness })
186        })
187        .upcast(cx)
188    }
189}
190
191#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for TraitClause<I> where I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for TraitClause<I> where I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for TraitClause<I> where I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            TraitClause {
                trait_ref: ref __field_trait_ref,
                polarity: ref __field_polarity } => {
                ::core::hash::Hash::hash(__field_trait_ref, __state);
                ::core::hash::Hash::hash(__field_polarity, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for TraitClause<I> where I: Interner
    {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (TraitClause {
                trait_ref: ref __field_trait_ref,
                polarity: ref __field_polarity }, TraitClause {
                trait_ref: ref __other_field_trait_ref,
                polarity: ref __other_field_polarity }) =>
                true &&
                        ::core::cmp::PartialEq::eq(__field_trait_ref,
                            __other_field_trait_ref) &&
                    ::core::cmp::PartialEq::eq(__field_polarity,
                        __other_field_polarity),
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
192#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for TraitClause<I>
            where I: Interner, TraitRef<I>: ::rustc_type_ir::TypeVisitable<I>
            {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    TraitClause {
                        trait_ref: ref __binding_0, polarity: ref __binding_1 } => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for TraitClause<I>
            where TraitRef<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            ClausePolarity: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    TraitClause {
                        trait_ref: ref __binding_0, polarity: ref __binding_1 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for TraitClause<I>
            where I: Interner, TraitRef<I>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        TraitClause { trait_ref: __binding_0, polarity: __binding_1
                            } => {
                            TraitClause {
                                trait_ref: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                polarity: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    TraitClause { trait_ref: __binding_0, polarity: __binding_1
                        } => {
                        TraitClause {
                            trait_ref: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            polarity: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for TraitClause<I>
            where J: Interner, I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = TraitClause<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    TraitClause { trait_ref: __binding_0, polarity: __binding_1
                        } => {
                        TraitClause {
                            trait_ref: __binding_0.lift_to_interner(interner),
                            polarity: __binding_1,
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
193#[cfg_attr(
194    feature = "nightly",
195    derive(const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for TraitClause<I> where
            TraitRef<I>: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                TraitClause {
                    trait_ref: ::rustc_serialize::Decodable::decode(__decoder),
                    polarity: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for TraitClause<I> where
            TraitRef<I>: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let TraitClause {
                        trait_ref: ref __binding_0, polarity: ref __binding_1 } =
                    *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            TraitClause<I> where
            TraitRef<I>: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    TraitClause {
                        trait_ref: ref __binding_0, polarity: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
196)]
197pub struct TraitClause<I: Interner> {
198    pub trait_ref: TraitRef<I>,
199
200    /// If polarity is Positive: we are proving that the trait is implemented.
201    ///
202    /// If polarity is Negative: we are proving that a negative impl of this trait
203    /// exists. (Note that coherence also checks whether negative impls of supertraits
204    /// exist via a series of clauses.)
205    #[lift(identity)]
206    pub polarity: ClausePolarity,
207}
208
209impl<I: Interner> Eq for TraitClause<I> {}
210
211impl<I: Interner> TraitClause<I> {
212    pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
213        Self {
214            trait_ref: self.trait_ref.with_replaced_self_ty(interner, self_ty),
215            polarity: self.polarity,
216        }
217    }
218
219    pub fn def_id(self) -> I::TraitId {
220        self.trait_ref.def_id
221    }
222
223    pub fn self_ty(self) -> I::Ty {
224        self.trait_ref.self_ty()
225    }
226}
227
228impl<I: Interner> ty::Binder<I, TraitClause<I>> {
229    pub fn def_id(self) -> I::TraitId {
230        // Ok to skip binder since trait `DefId` does not care about regions.
231        self.skip_binder().def_id()
232    }
233
234    pub fn self_ty(self) -> ty::Binder<I, I::Ty> {
235        self.map_bound_no_validate_bound_vars(|trait_ref| trait_ref.self_ty())
236    }
237
238    #[inline]
239    pub fn polarity(self) -> ClausePolarity {
240        self.skip_binder().polarity
241    }
242}
243
244impl<I: Interner> UpcastFrom<I, TraitRef<I>> for TraitClause<I> {
245    fn upcast_from(from: TraitRef<I>, _tcx: I) -> Self {
246        TraitClause { trait_ref: from, polarity: ClausePolarity::Positive }
247    }
248}
249
250impl<I: Interner> UpcastFrom<I, ty::Binder<I, TraitRef<I>>> for ty::Binder<I, TraitClause<I>> {
251    fn upcast_from(from: ty::Binder<I, TraitRef<I>>, _tcx: I) -> Self {
252        from.map_bound_no_validate_bound_vars(|trait_ref| TraitClause {
253            trait_ref,
254            polarity: ClausePolarity::Positive,
255        })
256    }
257}
258
259impl<I: Interner> fmt::Debug for TraitClause<I> {
260    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
261        f.write_fmt(format_args!("TraitClause({0:?}, polarity:{1:?})", self.trait_ref,
        self.polarity))write!(f, "TraitClause({:?}, polarity:{:?})", self.trait_ref, self.polarity)
262    }
263}
264
265#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for ImplPolarity {
}
#[automatically_derived]impl ::core::clone::Clone for ImplPolarity {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for ImplPolarity { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    ImplPolarity {
}
#[automatically_derived]impl ::core::cmp::PartialEq for ImplPolarity {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for ImplPolarity { }Eq, #[automatically_derived]impl ::core::cmp::PartialOrd for ImplPolarity {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]impl ::core::cmp::Ord for ImplPolarity {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
            &::core::intrinsics::discriminant_value(other))
    }
}Ord, #[automatically_derived]impl ::core::hash::Hash for ImplPolarity {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]impl ::core::fmt::Debug for ImplPolarity {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                ImplPolarity::Positive => "Positive",
                ImplPolarity::Negative => "Negative",
            })
    }
}Debug)]
266#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<__D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for ImplPolarity {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { ImplPolarity::Positive }
                    1usize => { ImplPolarity::Negative }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ImplPolarity`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<__E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for ImplPolarity {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        ImplPolarity::Positive => { 0usize }
                        ImplPolarity::Negative => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for ImplPolarity
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ImplPolarity::Positive => 0u8.stable_hash(__hcx, __hasher),
                    ImplPolarity::Negative => 1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    ImplPolarity::Positive => {}
                    ImplPolarity::Negative => {}
                }
            }
        }
    };StableHash))]
267pub enum ImplPolarity {
268    /// `impl Trait for Type`
269    Positive,
270    /// `impl !Trait for Type`
271    Negative,
272}
273
274impl fmt::Display for ImplPolarity {
275    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
276        match self {
277            Self::Positive => f.write_str("positive"),
278            Self::Negative => f.write_str("negative"),
279        }
280    }
281}
282
283impl ImplPolarity {
284    /// The polarity marker in front of the impl trait ref if applicable.
285    pub fn as_str(self) -> &'static str {
286        match self {
287            Self::Positive => "",
288            Self::Negative => "!",
289        }
290    }
291}
292
293/// Polarity for a trait clause.
294///
295/// May either be negative or positive.
296/// Distinguished from [`ImplPolarity`] since we never compute goals with
297/// "reservation" level.
298#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for ClausePolarity {
}
#[automatically_derived]impl ::core::clone::Clone for ClausePolarity {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for ClausePolarity { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    ClausePolarity {
}
#[automatically_derived]impl ::core::cmp::PartialEq for ClausePolarity {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for ClausePolarity { }Eq, #[automatically_derived]impl ::core::cmp::PartialOrd for ClausePolarity {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]impl ::core::cmp::Ord for ClausePolarity {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
            &::core::intrinsics::discriminant_value(other))
    }
}Ord, #[automatically_derived]impl ::core::hash::Hash for ClausePolarity {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]impl ::core::fmt::Debug for ClausePolarity {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                ClausePolarity::Positive => "Positive",
                ClausePolarity::Negative => "Negative",
            })
    }
}Debug)]
299#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<__D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for ClausePolarity {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { ClausePolarity::Positive }
                    1usize => { ClausePolarity::Negative }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ClausePolarity`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<__E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for ClausePolarity {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        ClausePolarity::Positive => { 0usize }
                        ClausePolarity::Negative => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            ClausePolarity {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ClausePolarity::Positive =>
                        0u8.stable_hash(__hcx, __hasher),
                    ClausePolarity::Negative =>
                        1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    ClausePolarity::Positive => {}
                    ClausePolarity::Negative => {}
                }
            }
        }
    };StableHash))]
300pub enum ClausePolarity {
301    /// `Type: Trait`
302    Positive,
303    /// `Type: !Trait`
304    Negative,
305}
306
307impl ClausePolarity {
308    /// Flips polarity by turning `Positive` into `Negative` and `Negative` into `Positive`.
309    pub fn flip(&self) -> ClausePolarity {
310        match self {
311            ClausePolarity::Positive => ClausePolarity::Negative,
312            ClausePolarity::Negative => ClausePolarity::Positive,
313        }
314    }
315}
316
317impl fmt::Display for ClausePolarity {
318    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
319        match self {
320            Self::Positive => f.write_str("positive"),
321            Self::Negative => f.write_str("negative"),
322        }
323    }
324}
325
326#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ExistentialPredicate<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for ExistentialPredicate<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ExistentialPredicate<I> where
    I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            ExistentialPredicate::Trait(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            ExistentialPredicate::Projection(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            ExistentialPredicate::AutoTrait(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ExistentialPredicate<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        if ::core::mem::discriminant(self) ==
                ::core::mem::discriminant(__other) {
            match (self, __other) {
                (ExistentialPredicate::Trait(ref __field_0),
                    ExistentialPredicate::Trait(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (ExistentialPredicate::Projection(ref __field_0),
                    ExistentialPredicate::Projection(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (ExistentialPredicate::AutoTrait(ref __field_0),
                    ExistentialPredicate::AutoTrait(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                _ => unsafe { ::core::hint::unreachable_unchecked() },
            }
        } else { false }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for ExistentialPredicate<I> where
    I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            ExistentialPredicate::Trait(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Trait");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            ExistentialPredicate::Projection(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Projection");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            ExistentialPredicate::AutoTrait(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "AutoTrait");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
327#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            ExistentialPredicate<I> where I: Interner,
            ExistentialTraitRef<I>: ::rustc_type_ir::TypeVisitable<I>,
            ExistentialProjection<I>: ::rustc_type_ir::TypeVisitable<I>,
            I::TraitId: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    ExistentialPredicate::Trait(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    ExistentialPredicate::Projection(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    ExistentialPredicate::AutoTrait(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            ExistentialPredicate<I> where
            ExistentialTraitRef<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            ExistentialProjection<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::TraitId: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    ExistentialPredicate::Trait(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    ExistentialPredicate::Projection(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    ExistentialPredicate::AutoTrait(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            ExistentialPredicate<I> where I: Interner,
            ExistentialTraitRef<I>: ::rustc_type_ir::TypeFoldable<I>,
            ExistentialProjection<I>: ::rustc_type_ir::TypeFoldable<I>,
            I::TraitId: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        ExistentialPredicate::Trait(__binding_0) => {
                            ExistentialPredicate::Trait(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                        ExistentialPredicate::Projection(__binding_0) => {
                            ExistentialPredicate::Projection(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                        ExistentialPredicate::AutoTrait(__binding_0) => {
                            ExistentialPredicate::AutoTrait(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    ExistentialPredicate::Trait(__binding_0) => {
                        ExistentialPredicate::Trait(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                    ExistentialPredicate::Projection(__binding_0) => {
                        ExistentialPredicate::Projection(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                    ExistentialPredicate::AutoTrait(__binding_0) => {
                        ExistentialPredicate::AutoTrait(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
            ExistentialPredicate<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = ExistentialPredicate<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    ExistentialPredicate::Trait(__binding_0) => {
                        ExistentialPredicate::Trait(__binding_0.lift_to_interner(interner))
                    }
                    ExistentialPredicate::Projection(__binding_0) => {
                        ExistentialPredicate::Projection(__binding_0.lift_to_interner(interner))
                    }
                    ExistentialPredicate::AutoTrait(__binding_0) => {
                        ExistentialPredicate::AutoTrait(__binding_0.lift_to_interner(interner))
                    }
                }
            }
        }
    };Lift_Generic)]
328#[cfg_attr(
329    feature = "nightly",
330    derive(const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for ExistentialPredicate<I>
            where ExistentialTraitRef<I>: ::rustc_serialize::Decodable<__D>,
            ExistentialProjection<I>: ::rustc_serialize::Decodable<__D>,
            I::TraitId: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        ExistentialPredicate::Trait(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        ExistentialPredicate::Projection(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    2usize => {
                        ExistentialPredicate::AutoTrait(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ExistentialPredicate`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for ExistentialPredicate<I>
            where ExistentialTraitRef<I>: ::rustc_serialize::Encodable<__E>,
            ExistentialProjection<I>: ::rustc_serialize::Encodable<__E>,
            I::TraitId: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        ExistentialPredicate::Trait(ref __binding_0) => { 0usize }
                        ExistentialPredicate::Projection(ref __binding_0) => {
                            1usize
                        }
                        ExistentialPredicate::AutoTrait(ref __binding_0) => {
                            2usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    ExistentialPredicate::Trait(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    ExistentialPredicate::Projection(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    ExistentialPredicate::AutoTrait(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            ExistentialPredicate<I> where
            ExistentialTraitRef<I>: ::rustc_data_structures::stable_hash::StableHash,
            ExistentialProjection<I>: ::rustc_data_structures::stable_hash::StableHash,
            I::TraitId: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ExistentialPredicate::Trait(ref __binding_0) =>
                        0u8.stable_hash(__hcx, __hasher),
                    ExistentialPredicate::Projection(ref __binding_0) =>
                        1u8.stable_hash(__hcx, __hasher),
                    ExistentialPredicate::AutoTrait(ref __binding_0) =>
                        2u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    ExistentialPredicate::Trait(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    ExistentialPredicate::Projection(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    ExistentialPredicate::AutoTrait(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
331)]
332pub enum ExistentialPredicate<I: Interner> {
333    /// E.g., `Iterator`.
334    Trait(ExistentialTraitRef<I>),
335    /// E.g., `Iterator::Item = T`.
336    Projection(ExistentialProjection<I>),
337    /// E.g., `Send`.
338    AutoTrait(I::TraitId),
339}
340
341impl<I: Interner> Eq for ExistentialPredicate<I> {}
342
343impl<I: Interner> ty::Binder<I, ExistentialPredicate<I>> {
344    pub fn def_id(&self) -> I::DefId {
345        match self.skip_binder() {
346            ExistentialPredicate::Trait(tr) => tr.def_id.into(),
347            ExistentialPredicate::Projection(p) => p.def_id.into(),
348            ExistentialPredicate::AutoTrait(did) => did.into(),
349        }
350    }
351    /// Given an existential predicate like `?Self: PartialEq<u32>` (e.g., derived from `dyn PartialEq<u32>`),
352    /// and a concrete type `self_ty`, returns a full predicate where the existentially quantified variable `?Self`
353    /// has been replaced with `self_ty` (e.g., `self_ty: PartialEq<u32>`, in our example).
354    pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> I::Clause {
355        match self.skip_binder() {
356            ExistentialPredicate::Trait(tr) => self.rebind(tr).with_self_ty(cx, self_ty).upcast(cx),
357            ExistentialPredicate::Projection(p) => {
358                self.rebind(p.with_self_ty(cx, self_ty)).upcast(cx)
359            }
360            ExistentialPredicate::AutoTrait(did) => {
361                let generics = cx.generics_of(did.into());
362                let trait_ref = if generics.count() == 1 {
363                    ty::TraitRef::new(cx, did, [self_ty])
364                } else {
365                    // If this is an ill-formed auto trait, then synthesize
366                    // new error args for the missing generics.
367                    let err_args =
368                        GenericArgs::extend_with_error(cx, did.into(), &[self_ty.into()]);
369                    ty::TraitRef::new_from_args(cx, did, err_args)
370                };
371                self.rebind(trait_ref).upcast(cx)
372            }
373        }
374    }
375}
376
377/// An existential reference to a trait where the self type `Self` is erased.
378///
379/// For example, the trait object type `Trait<'a, T, N>` can be understood as:
380/// ```ignore (illustrative)
381/// exists<X> X: Trait<'a, T, N>
382/// ```
383/// The generic arguments don't include the erased self type (so it's only `['a, T, N]`).
384#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ExistentialTraitRef<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for ExistentialTraitRef<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ExistentialTraitRef<I> where
    I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            ExistentialTraitRef {
                def_id: ref __field_def_id,
                args: ref __field_args,
                _use_existential_trait_ref_new_instead: ref __field__use_existential_trait_ref_new_instead
                } => {
                ::core::hash::Hash::hash(__field_def_id, __state);
                ::core::hash::Hash::hash(__field_args, __state);
                ::core::hash::Hash::hash(__field__use_existential_trait_ref_new_instead,
                    __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ExistentialTraitRef<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (ExistentialTraitRef {
                def_id: ref __field_def_id,
                args: ref __field_args,
                _use_existential_trait_ref_new_instead: ref __field__use_existential_trait_ref_new_instead
                }, ExistentialTraitRef {
                def_id: ref __other_field_def_id,
                args: ref __other_field_args,
                _use_existential_trait_ref_new_instead: ref __other_field__use_existential_trait_ref_new_instead
                }) =>
                true &&
                            ::core::cmp::PartialEq::eq(__field_def_id,
                                __other_field_def_id) &&
                        ::core::cmp::PartialEq::eq(__field_args, __other_field_args)
                    &&
                    ::core::cmp::PartialEq::eq(__field__use_existential_trait_ref_new_instead,
                        __other_field__use_existential_trait_ref_new_instead),
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
385#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            ExistentialTraitRef<I> where I: Interner,
            I::TraitId: ::rustc_type_ir::TypeVisitable<I>,
            I::GenericArgs: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    ExistentialTraitRef {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        _use_existential_trait_ref_new_instead: ref __binding_2 } =>
                        {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_2,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            ExistentialTraitRef<I> where
            I::TraitId: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
            (): ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    ExistentialTraitRef {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        _use_existential_trait_ref_new_instead: ref __binding_2 } =>
                        {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            ExistentialTraitRef<I> where I: Interner,
            I::TraitId: ::rustc_type_ir::TypeFoldable<I>,
            I::GenericArgs: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        ExistentialTraitRef {
                            def_id: __binding_0,
                            args: __binding_1,
                            _use_existential_trait_ref_new_instead: __binding_2 } => {
                            ExistentialTraitRef {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                args: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                                _use_existential_trait_ref_new_instead: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    ExistentialTraitRef {
                        def_id: __binding_0,
                        args: __binding_1,
                        _use_existential_trait_ref_new_instead: __binding_2 } => {
                        ExistentialTraitRef {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            args: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                            _use_existential_trait_ref_new_instead: ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
            ExistentialTraitRef<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = ExistentialTraitRef<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    ExistentialTraitRef {
                        def_id: __binding_0,
                        args: __binding_1,
                        _use_existential_trait_ref_new_instead: __binding_2 } => {
                        ExistentialTraitRef {
                            def_id: __binding_0.lift_to_interner(interner),
                            args: __binding_1.lift_to_interner(interner),
                            _use_existential_trait_ref_new_instead: __binding_2.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
386#[cfg_attr(
387    feature = "nightly",
388    derive(const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for ExistentialTraitRef<I> where
            I::TraitId: ::rustc_serialize::Decodable<__D>,
            I::GenericArgs: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                ExistentialTraitRef {
                    def_id: ::rustc_serialize::Decodable::decode(__decoder),
                    args: ::rustc_serialize::Decodable::decode(__decoder),
                    _use_existential_trait_ref_new_instead: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for ExistentialTraitRef<I> where
            I::TraitId: ::rustc_serialize::Encodable<__E>,
            I::GenericArgs: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let ExistentialTraitRef {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        _use_existential_trait_ref_new_instead: ref __binding_2 } =
                    *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            ExistentialTraitRef<I> where
            I::TraitId: ::rustc_data_structures::stable_hash::StableHash,
            I::GenericArgs: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ExistentialTraitRef {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        _use_existential_trait_ref_new_instead: ref __binding_2 } =>
                        {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
389)]
390pub struct ExistentialTraitRef<I: Interner> {
391    pub def_id: I::TraitId,
392    pub args: I::GenericArgs,
393    /// This field exists to prevent the creation of `ExistentialTraitRef` without
394    /// calling [`ExistentialTraitRef::new_from_args`].
395    _use_existential_trait_ref_new_instead: (),
396}
397
398impl<I: Interner> Eq for ExistentialTraitRef<I> {}
399
400impl<I: Interner> ExistentialTraitRef<I> {
401    pub fn new_from_args(interner: I, trait_def_id: I::TraitId, args: I::GenericArgs) -> Self {
402        interner.debug_assert_existential_args_compatible(trait_def_id.into(), args);
403        Self { def_id: trait_def_id, args, _use_existential_trait_ref_new_instead: () }
404    }
405
406    pub fn new(
407        interner: I,
408        trait_def_id: I::TraitId,
409        args: impl IntoIterator<Item: Into<I::GenericArg>>,
410    ) -> Self {
411        let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
412        Self::new_from_args(interner, trait_def_id, args)
413    }
414
415    pub fn erase_self_ty(interner: I, trait_ref: TraitRef<I>) -> ExistentialTraitRef<I> {
416        // Assert there is a Self.
417        trait_ref.args.type_at(0);
418
419        ExistentialTraitRef {
420            def_id: trait_ref.def_id,
421            args: interner.mk_args(&trait_ref.args.as_slice()[1..]),
422            _use_existential_trait_ref_new_instead: (),
423        }
424    }
425
426    /// Convert the *existential* trait ref into a normal one by providing a self type.
427    ///
428    /// Existential trait refs don't contain a self type, it's erased.
429    /// Therefore, you must specify *some* self type to perform the conversion.
430    /// A common choice is the trait object type itself or some kind of dummy type.
431    pub fn with_self_ty(self, interner: I, self_ty: I::Ty) -> TraitRef<I> {
432        TraitRef::new(interner, self.def_id, [self_ty.into()].into_iter().chain(self.args.iter()))
433    }
434}
435
436impl<I: Interner> ty::Binder<I, ExistentialTraitRef<I>> {
437    pub fn def_id(&self) -> I::TraitId {
438        self.skip_binder().def_id
439    }
440
441    /// Convert the *existential* polymorphic trait ref into a normal one by providing a self type.
442    ///
443    /// See also [`ExistentialTraitRef::with_self_ty`].
444    pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, TraitRef<I>> {
445        self.map_bound(|trait_ref| trait_ref.with_self_ty(cx, self_ty))
446    }
447}
448
449/// A `ProjectionClause` for an `ExistentialTraitRef`.
450#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ExistentialProjection<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for ExistentialProjection<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ExistentialProjection<I> where
    I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            ExistentialProjection {
                def_id: ref __field_def_id,
                args: ref __field_args,
                term: ref __field_term,
                use_existential_projection_new_instead: ref __field_use_existential_projection_new_instead
                } => {
                ::core::hash::Hash::hash(__field_def_id, __state);
                ::core::hash::Hash::hash(__field_args, __state);
                ::core::hash::Hash::hash(__field_term, __state);
                ::core::hash::Hash::hash(__field_use_existential_projection_new_instead,
                    __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ExistentialProjection<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (ExistentialProjection {
                def_id: ref __field_def_id,
                args: ref __field_args,
                term: ref __field_term,
                use_existential_projection_new_instead: ref __field_use_existential_projection_new_instead
                }, ExistentialProjection {
                def_id: ref __other_field_def_id,
                args: ref __other_field_args,
                term: ref __other_field_term,
                use_existential_projection_new_instead: ref __other_field_use_existential_projection_new_instead
                }) =>
                true &&
                                ::core::cmp::PartialEq::eq(__field_def_id,
                                    __other_field_def_id) &&
                            ::core::cmp::PartialEq::eq(__field_args, __other_field_args)
                        &&
                        ::core::cmp::PartialEq::eq(__field_term, __other_field_term)
                    &&
                    ::core::cmp::PartialEq::eq(__field_use_existential_projection_new_instead,
                        __other_field_use_existential_projection_new_instead),
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for ExistentialProjection<I> where
    I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            ExistentialProjection {
                def_id: ref __field_def_id,
                args: ref __field_args,
                term: ref __field_term,
                use_existential_projection_new_instead: ref __field_use_existential_projection_new_instead
                } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f,
                        "ExistentialProjection");
                ::core::fmt::DebugStruct::field(&mut __builder, "def_id",
                    __field_def_id);
                ::core::fmt::DebugStruct::field(&mut __builder, "args",
                    __field_args);
                ::core::fmt::DebugStruct::field(&mut __builder, "term",
                    __field_term);
                ::core::fmt::DebugStruct::finish_non_exhaustive(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
451#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            ExistentialProjection<I> where I: Interner,
            I::TraitAssocTermId: ::rustc_type_ir::TypeVisitable<I>,
            I::GenericArgs: ::rustc_type_ir::TypeVisitable<I>,
            I::Term: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    ExistentialProjection {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        term: ref __binding_2,
                        use_existential_projection_new_instead: ref __binding_3 } =>
                        {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_2,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_3,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            ExistentialProjection<I> where
            I::TraitAssocTermId: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::Term: ::rustc_type_ir::GenericTypeVisitable<__V>,
            (): ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    ExistentialProjection {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        term: ref __binding_2,
                        use_existential_projection_new_instead: ref __binding_3 } =>
                        {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_3,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            ExistentialProjection<I> where I: Interner,
            I::TraitAssocTermId: ::rustc_type_ir::TypeFoldable<I>,
            I::GenericArgs: ::rustc_type_ir::TypeFoldable<I>,
            I::Term: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        ExistentialProjection {
                            def_id: __binding_0,
                            args: __binding_1,
                            term: __binding_2,
                            use_existential_projection_new_instead: __binding_3 } => {
                            ExistentialProjection {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                args: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                                term: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
                                        __folder)?,
                                use_existential_projection_new_instead: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_3,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    ExistentialProjection {
                        def_id: __binding_0,
                        args: __binding_1,
                        term: __binding_2,
                        use_existential_projection_new_instead: __binding_3 } => {
                        ExistentialProjection {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            args: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                            term: ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
                                __folder),
                            use_existential_projection_new_instead: ::rustc_type_ir::TypeFoldable::fold_with(__binding_3,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
            ExistentialProjection<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = ExistentialProjection<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    ExistentialProjection {
                        def_id: __binding_0,
                        args: __binding_1,
                        term: __binding_2,
                        use_existential_projection_new_instead: __binding_3 } => {
                        ExistentialProjection {
                            def_id: __binding_0.lift_to_interner(interner),
                            args: __binding_1.lift_to_interner(interner),
                            term: __binding_2.lift_to_interner(interner),
                            use_existential_projection_new_instead: __binding_3.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
452#[cfg_attr(
453    feature = "nightly",
454    derive(const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for ExistentialProjection<I>
            where I::TraitAssocTermId: ::rustc_serialize::Decodable<__D>,
            I::GenericArgs: ::rustc_serialize::Decodable<__D>,
            I::Term: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                ExistentialProjection {
                    def_id: ::rustc_serialize::Decodable::decode(__decoder),
                    args: ::rustc_serialize::Decodable::decode(__decoder),
                    term: ::rustc_serialize::Decodable::decode(__decoder),
                    use_existential_projection_new_instead: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for ExistentialProjection<I>
            where I::TraitAssocTermId: ::rustc_serialize::Encodable<__E>,
            I::GenericArgs: ::rustc_serialize::Encodable<__E>,
            I::Term: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let ExistentialProjection {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        term: ref __binding_2,
                        use_existential_projection_new_instead: ref __binding_3 } =
                    *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_3,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            ExistentialProjection<I> where
            I::TraitAssocTermId: ::rustc_data_structures::stable_hash::StableHash,
            I::GenericArgs: ::rustc_data_structures::stable_hash::StableHash,
            I::Term: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ExistentialProjection {
                        def_id: ref __binding_0,
                        args: ref __binding_1,
                        term: ref __binding_2,
                        use_existential_projection_new_instead: ref __binding_3 } =>
                        {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                        { __binding_3.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
455)]
456pub struct ExistentialProjection<I: Interner> {
457    pub def_id: I::TraitAssocTermId,
458    pub args: I::GenericArgs,
459    pub term: I::Term,
460
461    /// This field exists to prevent the creation of `ExistentialProjection`
462    /// without using [`ExistentialProjection::new_from_args`].
463    #[derive_where(skip(Debug))]
464    use_existential_projection_new_instead: (),
465}
466
467impl<I: Interner> Eq for ExistentialProjection<I> {}
468
469impl<I: Interner> ExistentialProjection<I> {
470    pub fn new_from_args(
471        interner: I,
472        def_id: I::TraitAssocTermId,
473        args: I::GenericArgs,
474        term: I::Term,
475    ) -> ExistentialProjection<I> {
476        interner.debug_assert_existential_args_compatible(def_id.into(), args);
477        Self { def_id, args, term, use_existential_projection_new_instead: () }
478    }
479
480    pub fn new(
481        interner: I,
482        def_id: I::TraitAssocTermId,
483        args: impl IntoIterator<Item: Into<I::GenericArg>>,
484        term: I::Term,
485    ) -> ExistentialProjection<I> {
486        let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
487        Self::new_from_args(interner, def_id, args, term)
488    }
489
490    /// Extracts the underlying existential trait reference from this projection.
491    ///
492    /// For example, if this is a projection of `exists T. <T as Iterator>::Item == X`,
493    /// then this function would return an `exists T. T: Iterator` existential trait
494    /// reference.
495    pub fn trait_ref(&self, interner: I) -> ExistentialTraitRef<I> {
496        let def_id = interner.projection_parent(self.def_id);
497        let args_count = interner.generics_of(def_id.into()).count() - 1;
498        let args = interner.mk_args(&self.args.as_slice()[..args_count]);
499        ExistentialTraitRef::new_from_args(interner, def_id, args)
500    }
501
502    pub fn alias_kind(&self) -> ty::AliasTermKind<I> {
503        match self.term.kind() {
504            ty::TermKind::Ty(_) => {
505                ty::AliasTermKind::ProjectionTy { def_id: self.def_id.try_into().unwrap() }
506            }
507            ty::TermKind::Const(_) => {
508                ty::AliasTermKind::ProjectionConst { def_id: self.def_id.try_into().unwrap() }
509            }
510        }
511    }
512
513    pub fn with_self_ty(&self, interner: I, self_ty: I::Ty) -> ProjectionClause<I> {
514        // otherwise the escaping regions would be captured by the binders
515        if true {
    if !!self_ty.has_escaping_bound_vars() {
        ::core::panicking::panic("assertion failed: !self_ty.has_escaping_bound_vars()")
    };
};debug_assert!(!self_ty.has_escaping_bound_vars());
516
517        ProjectionClause {
518            projection_term: ty::AliasTerm::new(
519                interner,
520                self.alias_kind(),
521                [self_ty.into()].iter().chain(self.args.iter()),
522            ),
523            term: self.term,
524        }
525    }
526
527    pub fn erase_self_ty(interner: I, projection_predicate: ProjectionClause<I>) -> Self {
528        // Assert there is a Self.
529        projection_predicate.projection_term.args.type_at(0);
530
531        Self {
532            def_id: projection_predicate.def_id(),
533            args: interner.mk_args(&projection_predicate.projection_term.args.as_slice()[1..]),
534            term: projection_predicate.term,
535            use_existential_projection_new_instead: (),
536        }
537    }
538}
539
540impl<I: Interner> ty::Binder<I, ExistentialProjection<I>> {
541    pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, ProjectionClause<I>> {
542        self.map_bound(|p| p.with_self_ty(cx, self_ty))
543    }
544
545    pub fn item_def_id(&self) -> I::TraitAssocTermId {
546        self.skip_binder().def_id
547    }
548}
549
550/// This kind of predicate has no *direct* correspondent in the
551/// syntax, but it roughly corresponds to the syntactic forms:
552///
553/// 1. `T: TraitRef<..., Item = Type>`
554/// 2. `<T as TraitRef<...>>::Item == Type` (NYI)
555///
556/// In particular, form #1 is "desugared" to the combination of a
557/// normal trait predicate (`T: TraitRef<...>`) and one of these
558/// predicates. Form #2 is a broader form in that it also permits
559/// equality between arbitrary types. Processing an instance of
560/// Form #2 eventually yields one of these `ProjectionClause`
561/// instances to normalize the LHS.
562#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ProjectionClause<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for ProjectionClause<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ProjectionClause<I> where I: Interner
    {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            ProjectionClause {
                projection_term: ref __field_projection_term,
                term: ref __field_term } => {
                ::core::hash::Hash::hash(__field_projection_term, __state);
                ::core::hash::Hash::hash(__field_term, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ProjectionClause<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (ProjectionClause {
                projection_term: ref __field_projection_term,
                term: ref __field_term }, ProjectionClause {
                projection_term: ref __other_field_projection_term,
                term: ref __other_field_term }) =>
                true &&
                        ::core::cmp::PartialEq::eq(__field_projection_term,
                            __other_field_projection_term) &&
                    ::core::cmp::PartialEq::eq(__field_term,
                        __other_field_term),
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
563#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            ProjectionClause<I> where I: Interner,
            ty::AliasTerm<I>: ::rustc_type_ir::TypeVisitable<I>,
            I::Term: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    ProjectionClause {
                        projection_term: ref __binding_0, term: ref __binding_1 } =>
                        {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for ProjectionClause<I>
            where
            ty::AliasTerm<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::Term: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    ProjectionClause {
                        projection_term: ref __binding_0, term: ref __binding_1 } =>
                        {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            ProjectionClause<I> where I: Interner,
            ty::AliasTerm<I>: ::rustc_type_ir::TypeFoldable<I>,
            I::Term: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        ProjectionClause {
                            projection_term: __binding_0, term: __binding_1 } => {
                            ProjectionClause {
                                projection_term: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                term: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    ProjectionClause {
                        projection_term: __binding_0, term: __binding_1 } => {
                        ProjectionClause {
                            projection_term: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            term: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
            ProjectionClause<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = ProjectionClause<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    ProjectionClause {
                        projection_term: __binding_0, term: __binding_1 } => {
                        ProjectionClause {
                            projection_term: __binding_0.lift_to_interner(interner),
                            term: __binding_1.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
564#[cfg_attr(
565    feature = "nightly",
566    derive(const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for ProjectionClause<I> where
            ty::AliasTerm<I>: ::rustc_serialize::Decodable<__D>,
            I::Term: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                ProjectionClause {
                    projection_term: ::rustc_serialize::Decodable::decode(__decoder),
                    term: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for ProjectionClause<I> where
            ty::AliasTerm<I>: ::rustc_serialize::Encodable<__E>,
            I::Term: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let ProjectionClause {
                        projection_term: ref __binding_0, term: ref __binding_1 } =
                    *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            ProjectionClause<I> where
            ty::AliasTerm<I>: ::rustc_data_structures::stable_hash::StableHash,
            I::Term: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ProjectionClause {
                        projection_term: ref __binding_0, term: ref __binding_1 } =>
                        {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
567)]
568pub struct ProjectionClause<I: Interner> {
569    pub projection_term: ty::AliasTerm<I>,
570    pub term: I::Term,
571}
572
573impl<I: Interner> Eq for ProjectionClause<I> {}
574
575impl<I: Interner> ProjectionClause<I> {
576    pub fn self_ty(self) -> I::Ty {
577        self.projection_term.self_ty()
578    }
579
580    pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> ProjectionClause<I> {
581        Self {
582            projection_term: self.projection_term.with_replaced_self_ty(interner, self_ty),
583            ..self
584        }
585    }
586
587    pub fn trait_def_id(self, interner: I) -> I::TraitId {
588        self.projection_term.trait_def_id(interner)
589    }
590
591    pub fn def_id(self) -> I::TraitAssocTermId {
592        self.projection_term.expect_projection_def_id()
593    }
594}
595
596impl<I: Interner> ty::Binder<I, ProjectionClause<I>> {
597    /// Returns the `DefId` of the trait of the associated item being projected.
598    #[inline]
599    pub fn trait_def_id(&self, cx: I) -> I::TraitId {
600        self.skip_binder().projection_term.trait_def_id(cx)
601    }
602
603    pub fn term(&self) -> ty::Binder<I, I::Term> {
604        self.map_bound(|predicate| predicate.term)
605    }
606
607    /// The `DefId` of the `TraitItem` for the associated type.
608    ///
609    /// Note that this is not the `DefId` of the `TraitRef` containing this
610    /// associated type, which is in `tcx.associated_item(projection_def_id()).container`.
611    pub fn item_def_id(&self) -> I::TraitAssocTermId {
612        // Ok to skip binder since trait `DefId` does not care about regions.
613        self.skip_binder().def_id()
614    }
615}
616
617impl<I: Interner> fmt::Debug for ProjectionClause<I> {
618    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
619        f.write_fmt(format_args!("ProjectionClause({0:?}, {1:?})",
        self.projection_term, self.term))write!(f, "ProjectionClause({:?}, {:?})", self.projection_term, self.term)
620    }
621}
622
623/// Used by the new solver to normalize an alias. This always expects the `term` to
624/// be an unconstrained inference variable which is used as the output.
625#[automatically_derived]
impl<I: Interner, K> ::core::clone::Clone for NormalizesTo<I, K> where
    I: Interner, K: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            NormalizesTo { alias: ref __field_alias, term: ref __field_term }
                =>
                NormalizesTo {
                    alias: ::core::clone::Clone::clone(__field_alias),
                    term: ::core::clone::Clone::clone(__field_term),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner, K> ::core::marker::Copy for NormalizesTo<I, K> where
    I: Interner, K: ::core::marker::Copy {
}
#[automatically_derived]
impl<I: Interner, K> ::core::hash::Hash for NormalizesTo<I, K> where
    I: Interner, K: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            NormalizesTo { alias: ref __field_alias, term: ref __field_term }
                => {
                ::core::hash::Hash::hash(__field_alias, __state);
                ::core::hash::Hash::hash(__field_term, __state);
            }
        }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner, K> DeriveWhereAssertEq for NormalizesTo<I, K> where
            I: Interner, K: ::core::cmp::Eq {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<Alias<I, K>>;
                let _: __AssertEq<I::Term>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner, K> ::core::cmp::Eq for NormalizesTo<I, K> where I: Interner,
    K: ::core::cmp::Eq {
}
#[automatically_derived]
impl<I: Interner, K> ::core::cmp::PartialEq for NormalizesTo<I, K> where
    I: Interner, K: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (NormalizesTo { alias: ref __field_alias, term: ref __field_term
                }, NormalizesTo {
                alias: ref __other_field_alias, term: ref __other_field_term
                }) =>
                true &&
                        ::core::cmp::PartialEq::eq(__field_alias,
                            __other_field_alias) &&
                    ::core::cmp::PartialEq::eq(__field_term,
                        __other_field_term),
        }
    }
}#[derive_where(Clone, Copy, Hash, Eq, PartialEq; I: Interner, K)]
626#[derive(const _: () =
    {
        impl<I: Interner, K> ::rustc_type_ir::TypeVisitable<I> for
            NormalizesTo<I, K> where I: Interner,
            Alias<I, K>: ::rustc_type_ir::TypeVisitable<I>,
            I::Term: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    NormalizesTo { alias: ref __binding_0, term: ref __binding_1
                        } => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, K, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for NormalizesTo<I, K>
            where Alias<I, K>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::Term: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    NormalizesTo { alias: ref __binding_0, term: ref __binding_1
                        } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner, K> ::rustc_type_ir::TypeFoldable<I> for
            NormalizesTo<I, K> where I: Interner,
            K: ::rustc_type_ir::TypeFoldable<I>,
            Alias<I, K>: ::rustc_type_ir::TypeFoldable<I>,
            I::Term: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        NormalizesTo { alias: __binding_0, term: __binding_1 } => {
                            NormalizesTo {
                                alias: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                term: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    NormalizesTo { alias: __binding_0, term: __binding_1 } => {
                        NormalizesTo {
                            alias: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            term: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, K, J> ::rustc_type_ir::lift::Lift<J> for
            NormalizesTo<I, K> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J>, K: ::rustc_type_ir::lift::Lift<J>
            {
            type Lifted =
                NormalizesTo<J,
                <K as ::rustc_type_ir::lift::Lift<J>>::Lifted>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    NormalizesTo { alias: __binding_0, term: __binding_1 } => {
                        NormalizesTo {
                            alias: __binding_0.lift_to_interner(interner),
                            term: __binding_1.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
627#[cfg_attr(
628    feature = "nightly",
629    derive(const _: () =
    {
        impl<I: Interner, K, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for NormalizesTo<I, K> where
            Alias<I, K>: ::rustc_serialize::Decodable<__D>,
            I::Term: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                NormalizesTo {
                    alias: ::rustc_serialize::Decodable::decode(__decoder),
                    term: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, K, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for NormalizesTo<I, K> where
            Alias<I, K>: ::rustc_serialize::Encodable<__E>,
            I::Term: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let NormalizesTo {
                        alias: ref __binding_0, term: ref __binding_1 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner, K> ::rustc_data_structures::stable_hash::StableHash
            for NormalizesTo<I, K> where
            Alias<I, K>: ::rustc_data_structures::stable_hash::StableHash,
            I::Term: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    NormalizesTo { alias: ref __binding_0, term: ref __binding_1
                        } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
630)]
631pub struct NormalizesTo<I: Interner, K = ty::AliasTermKind<I>> {
632    pub alias: Alias<I, K>,
633    pub term: I::Term,
634}
635
636impl<I: Interner> NormalizesTo<I> {
637    pub fn self_ty(self) -> I::Ty {
638        self.alias.self_ty()
639    }
640
641    pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> NormalizesTo<I> {
642        Self { alias: self.alias.with_replaced_self_ty(interner, self_ty), ..self }
643    }
644
645    pub fn trait_def_id(self, interner: I) -> I::TraitId {
646        self.alias.trait_def_id(interner)
647    }
648}
649
650impl<I: Interner, K> fmt::Debug for NormalizesTo<I, K>
651where
652    // `TypeVisitable_Generic` derived on `NormalizesTo` creates a field-level
653    // `Alias<I, K>: TypeVisitable<I>` bound. Since `TypeVisitable<I>: fmt::Debug`,
654    // that proves `Alias<I, K>: fmt::Debug`, but not `K: fmt::Debug`.
655    Alias<I, K>: fmt::Debug,
656{
657    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
658        f.write_fmt(format_args!("NormalizesTo({0:?}, {1:?})", self.alias, self.term))write!(f, "NormalizesTo({:?}, {:?})", self.alias, self.term)
659    }
660}
661
662#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for HostEffectClause<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for HostEffectClause<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for HostEffectClause<I> where I: Interner
    {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            HostEffectClause {
                trait_ref: ref __field_trait_ref,
                constness: ref __field_constness } => {
                ::core::hash::Hash::hash(__field_trait_ref, __state);
                ::core::hash::Hash::hash(__field_constness, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for HostEffectClause<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (HostEffectClause {
                trait_ref: ref __field_trait_ref,
                constness: ref __field_constness }, HostEffectClause {
                trait_ref: ref __other_field_trait_ref,
                constness: ref __other_field_constness }) =>
                true &&
                        ::core::cmp::PartialEq::eq(__field_trait_ref,
                            __other_field_trait_ref) &&
                    ::core::cmp::PartialEq::eq(__field_constness,
                        __other_field_constness),
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for HostEffectClause<I> where I: Interner
    {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            HostEffectClause {
                trait_ref: ref __field_trait_ref,
                constness: ref __field_constness } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f,
                        "HostEffectClause");
                ::core::fmt::DebugStruct::field(&mut __builder, "trait_ref",
                    __field_trait_ref);
                ::core::fmt::DebugStruct::field(&mut __builder, "constness",
                    __field_constness);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
663#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            HostEffectClause<I> where I: Interner,
            ty::TraitRef<I>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    HostEffectClause {
                        trait_ref: ref __binding_0, constness: ref __binding_1 } =>
                        {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for HostEffectClause<I>
            where ty::TraitRef<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            BoundConstness: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    HostEffectClause {
                        trait_ref: ref __binding_0, constness: ref __binding_1 } =>
                        {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            HostEffectClause<I> where I: Interner,
            ty::TraitRef<I>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        HostEffectClause {
                            trait_ref: __binding_0, constness: __binding_1 } => {
                            HostEffectClause {
                                trait_ref: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                constness: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    HostEffectClause {
                        trait_ref: __binding_0, constness: __binding_1 } => {
                        HostEffectClause {
                            trait_ref: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            constness: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
            HostEffectClause<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = HostEffectClause<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    HostEffectClause {
                        trait_ref: __binding_0, constness: __binding_1 } => {
                        HostEffectClause {
                            trait_ref: __binding_0.lift_to_interner(interner),
                            constness: __binding_1,
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
664#[cfg_attr(
665    feature = "nightly",
666    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for HostEffectClause<I> where
            ty::TraitRef<I>: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let HostEffectClause {
                        trait_ref: ref __binding_0, constness: ref __binding_1 } =
                    *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for HostEffectClause<I> where
            ty::TraitRef<I>: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                HostEffectClause {
                    trait_ref: ::rustc_serialize::Decodable::decode(__decoder),
                    constness: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            HostEffectClause<I> where
            ty::TraitRef<I>: ::rustc_data_structures::stable_hash::StableHash
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    HostEffectClause {
                        trait_ref: ref __binding_0, constness: ref __binding_1 } =>
                        {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
667)]
668pub struct HostEffectClause<I: Interner> {
669    pub trait_ref: ty::TraitRef<I>,
670    #[lift(identity)]
671    pub constness: BoundConstness,
672}
673
674impl<I: Interner> Eq for HostEffectClause<I> {}
675
676impl<I: Interner> HostEffectClause<I> {
677    pub fn self_ty(self) -> I::Ty {
678        self.trait_ref.self_ty()
679    }
680
681    pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
682        Self { trait_ref: self.trait_ref.with_replaced_self_ty(interner, self_ty), ..self }
683    }
684
685    pub fn def_id(self) -> I::TraitId {
686        self.trait_ref.def_id
687    }
688}
689
690impl<I: Interner> ty::Binder<I, HostEffectClause<I>> {
691    pub fn def_id(self) -> I::TraitId {
692        // Ok to skip binder since trait `DefId` does not care about regions.
693        self.skip_binder().def_id()
694    }
695
696    pub fn self_ty(self) -> ty::Binder<I, I::Ty> {
697        self.map_bound(|trait_ref| trait_ref.self_ty())
698    }
699
700    #[inline]
701    pub fn constness(self) -> BoundConstness {
702        self.skip_binder().constness
703    }
704}
705
706/// Encodes that `a` must be a subtype of `b`. The `a_is_expected` flag indicates
707/// whether the `a` type is the type that we should label as "expected" when
708/// presenting user diagnostics.
709#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for SubtypePredicate<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for SubtypePredicate<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for SubtypePredicate<I> where I: Interner
    {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            SubtypePredicate {
                a_is_expected: ref __field_a_is_expected,
                a: ref __field_a,
                b: ref __field_b } => {
                ::core::hash::Hash::hash(__field_a_is_expected, __state);
                ::core::hash::Hash::hash(__field_a, __state);
                ::core::hash::Hash::hash(__field_b, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for SubtypePredicate<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (SubtypePredicate {
                a_is_expected: ref __field_a_is_expected,
                a: ref __field_a,
                b: ref __field_b }, SubtypePredicate {
                a_is_expected: ref __other_field_a_is_expected,
                a: ref __other_field_a,
                b: ref __other_field_b }) =>
                true &&
                            ::core::cmp::PartialEq::eq(__field_a_is_expected,
                                __other_field_a_is_expected) &&
                        ::core::cmp::PartialEq::eq(__field_a, __other_field_a) &&
                    ::core::cmp::PartialEq::eq(__field_b, __other_field_b),
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for SubtypePredicate<I> where I: Interner
    {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            SubtypePredicate {
                a_is_expected: ref __field_a_is_expected,
                a: ref __field_a,
                b: ref __field_b } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f,
                        "SubtypePredicate");
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "a_is_expected", __field_a_is_expected);
                ::core::fmt::DebugStruct::field(&mut __builder, "a",
                    __field_a);
                ::core::fmt::DebugStruct::field(&mut __builder, "b",
                    __field_b);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
710#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            SubtypePredicate<I> where I: Interner,
            I::Ty: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    SubtypePredicate {
                        a_is_expected: ref __binding_0,
                        a: ref __binding_1,
                        b: ref __binding_2 } => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_2,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for SubtypePredicate<I>
            where bool: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    SubtypePredicate {
                        a_is_expected: ref __binding_0,
                        a: ref __binding_1,
                        b: ref __binding_2 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            SubtypePredicate<I> where I: Interner,
            I::Ty: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        SubtypePredicate {
                            a_is_expected: __binding_0, a: __binding_1, b: __binding_2 }
                            => {
                            SubtypePredicate {
                                a_is_expected: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                a: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                                b: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    SubtypePredicate {
                        a_is_expected: __binding_0, a: __binding_1, b: __binding_2 }
                        => {
                        SubtypePredicate {
                            a_is_expected: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            a: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                            b: ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
            SubtypePredicate<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = SubtypePredicate<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    SubtypePredicate {
                        a_is_expected: __binding_0, a: __binding_1, b: __binding_2 }
                        => {
                        SubtypePredicate {
                            a_is_expected: __binding_0,
                            a: __binding_1.lift_to_interner(interner),
                            b: __binding_2.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
711#[cfg_attr(
712    feature = "nightly",
713    derive(const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for SubtypePredicate<I> where
            I::Ty: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                SubtypePredicate {
                    a_is_expected: ::rustc_serialize::Decodable::decode(__decoder),
                    a: ::rustc_serialize::Decodable::decode(__decoder),
                    b: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for SubtypePredicate<I> where
            I::Ty: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let SubtypePredicate {
                        a_is_expected: ref __binding_0,
                        a: ref __binding_1,
                        b: ref __binding_2 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            SubtypePredicate<I> where
            I::Ty: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    SubtypePredicate {
                        a_is_expected: ref __binding_0,
                        a: ref __binding_1,
                        b: ref __binding_2 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
714)]
715pub struct SubtypePredicate<I: Interner> {
716    #[lift(identity)]
717    pub a_is_expected: bool,
718    pub a: I::Ty,
719    pub b: I::Ty,
720}
721
722impl<I: Interner> Eq for SubtypePredicate<I> {}
723
724/// Encodes that we have to coerce *from* the `a` type to the `b` type.
725#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for CoercePredicate<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for CoercePredicate<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for CoercePredicate<I> where I: Interner
    {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            CoercePredicate { a: ref __field_a, b: ref __field_b } => {
                ::core::hash::Hash::hash(__field_a, __state);
                ::core::hash::Hash::hash(__field_b, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for CoercePredicate<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (CoercePredicate { a: ref __field_a, b: ref __field_b },
                CoercePredicate {
                a: ref __other_field_a, b: ref __other_field_b }) =>
                true && ::core::cmp::PartialEq::eq(__field_a, __other_field_a)
                    && ::core::cmp::PartialEq::eq(__field_b, __other_field_b),
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for CoercePredicate<I> where I: Interner
    {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            CoercePredicate { a: ref __field_a, b: ref __field_b } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f,
                        "CoercePredicate");
                ::core::fmt::DebugStruct::field(&mut __builder, "a",
                    __field_a);
                ::core::fmt::DebugStruct::field(&mut __builder, "b",
                    __field_b);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
726#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            CoercePredicate<I> where I: Interner,
            I::Ty: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    CoercePredicate { a: ref __binding_0, b: ref __binding_1 }
                        => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for CoercePredicate<I>
            where I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    CoercePredicate { a: ref __binding_0, b: ref __binding_1 }
                        => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            CoercePredicate<I> where I: Interner,
            I::Ty: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        CoercePredicate { a: __binding_0, b: __binding_1 } => {
                            CoercePredicate {
                                a: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                b: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    CoercePredicate { a: __binding_0, b: __binding_1 } => {
                        CoercePredicate {
                            a: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            b: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
            CoercePredicate<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = CoercePredicate<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    CoercePredicate { a: __binding_0, b: __binding_1 } => {
                        CoercePredicate {
                            a: __binding_0.lift_to_interner(interner),
                            b: __binding_1.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
727#[cfg_attr(
728    feature = "nightly",
729    derive(const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for CoercePredicate<I> where
            I::Ty: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                CoercePredicate {
                    a: ::rustc_serialize::Decodable::decode(__decoder),
                    b: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for CoercePredicate<I> where
            I::Ty: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let CoercePredicate { a: ref __binding_0, b: ref __binding_1
                        } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            CoercePredicate<I> where
            I::Ty: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    CoercePredicate { a: ref __binding_0, b: ref __binding_1 }
                        => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
730)]
731pub struct CoercePredicate<I: Interner> {
732    pub a: I::Ty,
733    pub b: I::Ty,
734}
735
736impl<I: Interner> Eq for CoercePredicate<I> {}
737
738#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for BoundConstness {
}
#[automatically_derived]impl ::core::clone::Clone for BoundConstness {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for BoundConstness { }Copy, #[automatically_derived]impl ::core::hash::Hash for BoundConstness {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    BoundConstness {
}
#[automatically_derived]impl ::core::cmp::PartialEq for BoundConstness {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for BoundConstness { }Eq, #[automatically_derived]impl ::core::fmt::Debug for BoundConstness {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                BoundConstness::Const => "Const",
                BoundConstness::Maybe => "Maybe",
            })
    }
}Debug)]
739#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<__E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for BoundConstness {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        BoundConstness::Const => { 0usize }
                        BoundConstness::Maybe => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<__D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for BoundConstness {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { BoundConstness::Const }
                    1usize => { BoundConstness::Maybe }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `BoundConstness`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            BoundConstness {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    BoundConstness::Const => 0u8.stable_hash(__hcx, __hasher),
                    BoundConstness::Maybe => 1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    BoundConstness::Const => {}
                    BoundConstness::Maybe => {}
                }
            }
        }
    };StableHash))]
740pub enum BoundConstness {
741    /// `Type: const Trait`
742    ///
743    /// A bound is required to be unconditionally const, even in a runtime function.
744    Const,
745    /// `Type: [const] Trait`
746    ///
747    /// Requires resolving to const only when we are in a const context.
748    Maybe,
749}
750
751impl BoundConstness {
752    pub fn satisfies(self, goal: BoundConstness) -> bool {
753        match (self, goal) {
754            (BoundConstness::Const, BoundConstness::Const | BoundConstness::Maybe) => true,
755            (BoundConstness::Maybe, BoundConstness::Maybe) => true,
756            (BoundConstness::Maybe, BoundConstness::Const) => false,
757        }
758    }
759
760    pub fn as_str(self) -> &'static str {
761        match self {
762            Self::Const => "const",
763            Self::Maybe => "[const]",
764        }
765    }
766}
767
768impl fmt::Display for BoundConstness {
769    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
770        match self {
771            Self::Const => f.write_str("const"),
772            Self::Maybe => f.write_str("[const]"),
773        }
774    }
775}
776
777#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for CompressedTraitRefs {
}
#[automatically_derived]impl ::core::clone::Clone for CompressedTraitRefs {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<u32>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for CompressedTraitRefs { }Copy, #[automatically_derived]impl ::core::hash::Hash for CompressedTraitRefs {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}Hash, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    CompressedTraitRefs {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CompressedTraitRefs {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]impl ::core::fmt::Debug for CompressedTraitRefs {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "CompressedTraitRefs", &&self.0)
    }
}Debug)]
778#[derive(const _: () =
    {
        unsafe impl<__V> ::rustc_type_ir::GenericTypeVisitable<__V> for
            CompressedTraitRefs where
            u32: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    CompressedTraitRefs(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable)]
779#[cfg_attr(
780    feature = "nightly",
781    derive(const _: () =
    {
        impl<__E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for CompressedTraitRefs {
            fn encode(&self, __encoder: &mut __E) {
                let CompressedTraitRefs(ref __binding_0) = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<__D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for CompressedTraitRefs {
            fn decode(__decoder: &mut __D) -> Self {
                CompressedTraitRefs(::rustc_serialize::Decodable::decode(__decoder))
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            CompressedTraitRefs {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    CompressedTraitRefs(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
782)]
783pub struct CompressedTraitRefs(u32);
784impl CompressedTraitRefs {
    #[allow(deprecated, non_upper_case_globals,)]
    pub const SIZED: Self = Self::from_bits_retain(1);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const META_SIZED: Self = Self::from_bits_retain(1 << 1);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const POINTEE_SIZED: Self = Self::from_bits_retain(1 << 2);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const CLONE: Self = Self::from_bits_retain(1 << 3);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const COPY: Self = Self::from_bits_retain(1 << 4);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const DEBUG: Self = Self::from_bits_retain(1 << 5);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const DROP: Self = Self::from_bits_retain(1 << 6);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const UNPIN: Self = Self::from_bits_retain(1 << 7);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const EQ: Self = Self::from_bits_retain(1 << 8);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const SEND: Self = Self::from_bits_retain(1 << 9);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const SYNC: Self = Self::from_bits_retain(1 << 10);
}
impl ::bitflags::Flags for CompressedTraitRefs {
    const FLAGS: &'static [::bitflags::Flag<CompressedTraitRefs>] =
        &[{

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("SIZED", CompressedTraitRefs::SIZED)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("META_SIZED",
                            CompressedTraitRefs::META_SIZED)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("POINTEE_SIZED",
                            CompressedTraitRefs::POINTEE_SIZED)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("CLONE", CompressedTraitRefs::CLONE)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("COPY", CompressedTraitRefs::COPY)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("DEBUG", CompressedTraitRefs::DEBUG)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("DROP", CompressedTraitRefs::DROP)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("UNPIN", CompressedTraitRefs::UNPIN)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("EQ", CompressedTraitRefs::EQ)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("SEND", CompressedTraitRefs::SEND)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("SYNC", CompressedTraitRefs::SYNC)
                    }];
    type Bits = u32;
    fn bits(&self) -> u32 { CompressedTraitRefs::bits(self) }
    fn from_bits_retain(bits: u32) -> CompressedTraitRefs {
        CompressedTraitRefs::from_bits_retain(bits)
    }
}
#[allow(dead_code, deprecated, unused_doc_comments, unused_attributes,
unused_mut, unused_imports, non_upper_case_globals, clippy ::
assign_op_pattern, clippy :: iter_without_into_iter,)]
const _: () =
    {
        #[allow(dead_code, deprecated, unused_attributes)]
        impl CompressedTraitRefs {
            /// Get a flags value with all bits unset.
            #[inline]
            pub const fn empty() -> Self {
                Self(<u32 as ::bitflags::Bits>::EMPTY)
            }
            /// Get a flags value with all known bits set.
            #[inline]
            pub const fn all() -> Self {
                let mut truncated = <u32 as ::bitflags::Bits>::EMPTY;
                let mut i = 0;
                {
                    {
                        let flag =
                            <CompressedTraitRefs as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CompressedTraitRefs as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CompressedTraitRefs as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CompressedTraitRefs as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CompressedTraitRefs as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CompressedTraitRefs as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CompressedTraitRefs as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CompressedTraitRefs as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CompressedTraitRefs as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CompressedTraitRefs as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CompressedTraitRefs as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                let _ = i;
                Self(truncated)
            }
            /// Get the underlying bits value.
            ///
            /// The returned value is exactly the bits set in this flags value.
            #[inline]
            pub const fn bits(&self) -> u32 { self.0 }
            /// Convert from a bits value.
            ///
            /// This method will return `None` if any unknown bits are set.
            #[inline]
            pub const fn from_bits(bits: u32)
                -> ::bitflags::__private::core::option::Option<Self> {
                let truncated = Self::from_bits_truncate(bits).0;
                if truncated == bits {
                    ::bitflags::__private::core::option::Option::Some(Self(bits))
                } else { ::bitflags::__private::core::option::Option::None }
            }
            /// Convert from a bits value, unsetting any unknown bits.
            #[inline]
            pub const fn from_bits_truncate(bits: u32) -> Self {
                Self(bits & Self::all().0)
            }
            /// Convert from a bits value exactly.
            #[inline]
            pub const fn from_bits_retain(bits: u32) -> Self { Self(bits) }
            /// Get a flags value with the bits of a flag with the given name set.
            ///
            /// This method will return `None` if `name` is empty or doesn't
            /// correspond to any named flag.
            #[inline]
            pub fn from_name(name: &str)
                -> ::bitflags::__private::core::option::Option<Self> {
                {
                    if name == "SIZED" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CompressedTraitRefs::SIZED.bits()));
                    }
                };
                ;
                {
                    if name == "META_SIZED" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CompressedTraitRefs::META_SIZED.bits()));
                    }
                };
                ;
                {
                    if name == "POINTEE_SIZED" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CompressedTraitRefs::POINTEE_SIZED.bits()));
                    }
                };
                ;
                {
                    if name == "CLONE" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CompressedTraitRefs::CLONE.bits()));
                    }
                };
                ;
                {
                    if name == "COPY" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CompressedTraitRefs::COPY.bits()));
                    }
                };
                ;
                {
                    if name == "DEBUG" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CompressedTraitRefs::DEBUG.bits()));
                    }
                };
                ;
                {
                    if name == "DROP" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CompressedTraitRefs::DROP.bits()));
                    }
                };
                ;
                {
                    if name == "UNPIN" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CompressedTraitRefs::UNPIN.bits()));
                    }
                };
                ;
                {
                    if name == "EQ" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CompressedTraitRefs::EQ.bits()));
                    }
                };
                ;
                {
                    if name == "SEND" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CompressedTraitRefs::SEND.bits()));
                    }
                };
                ;
                {
                    if name == "SYNC" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CompressedTraitRefs::SYNC.bits()));
                    }
                };
                ;
                let _ = name;
                ::bitflags::__private::core::option::Option::None
            }
            /// Whether all bits in this flags value are unset.
            #[inline]
            pub const fn is_empty(&self) -> bool {
                self.0 == <u32 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all known bits in this flags value are set.
            #[inline]
            pub const fn is_all(&self) -> bool {
                Self::all().0 | self.0 == self.0
            }
            /// Whether any set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn intersects(&self, other: Self) -> bool {
                self.0 & other.0 != <u32 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn contains(&self, other: Self) -> bool {
                self.0 & other.0 == other.0
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            pub fn insert(&mut self, other: Self) {
                *self = Self(self.0).union(other);
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `remove` won't truncate `other`, but the `!` operator will.
            #[inline]
            pub fn remove(&mut self, other: Self) {
                *self = Self(self.0).difference(other);
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            pub fn toggle(&mut self, other: Self) {
                *self = Self(self.0).symmetric_difference(other);
            }
            /// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
            #[inline]
            pub fn set(&mut self, other: Self, value: bool) {
                if value { self.insert(other); } else { self.remove(other); }
            }
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn intersection(self, other: Self) -> Self {
                Self(self.0 & other.0)
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn union(self, other: Self) -> Self {
                Self(self.0 | other.0)
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            #[must_use]
            pub const fn difference(self, other: Self) -> Self {
                Self(self.0 & !other.0)
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn symmetric_difference(self, other: Self) -> Self {
                Self(self.0 ^ other.0)
            }
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            #[must_use]
            pub const fn complement(self) -> Self {
                Self::from_bits_truncate(!self.0)
            }
        }
        impl ::bitflags::__private::core::fmt::Binary for CompressedTraitRefs
            {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::Octal for CompressedTraitRefs {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::LowerHex for
            CompressedTraitRefs {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::UpperHex for
            CompressedTraitRefs {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::ops::BitOr for CompressedTraitRefs {
            type Output = Self;
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor(self, other: CompressedTraitRefs) -> Self {
                self.union(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitOrAssign for
            CompressedTraitRefs {
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor_assign(&mut self, other: Self) { self.insert(other); }
        }
        impl ::bitflags::__private::core::ops::BitXor for CompressedTraitRefs
            {
            type Output = Self;
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor(self, other: Self) -> Self {
                self.symmetric_difference(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitXorAssign for
            CompressedTraitRefs {
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
        }
        impl ::bitflags::__private::core::ops::BitAnd for CompressedTraitRefs
            {
            type Output = Self;
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand(self, other: Self) -> Self { self.intersection(other) }
        }
        impl ::bitflags::__private::core::ops::BitAndAssign for
            CompressedTraitRefs {
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand_assign(&mut self, other: Self) {
                *self =
                    Self::from_bits_retain(self.bits()).intersection(other);
            }
        }
        impl ::bitflags::__private::core::ops::Sub for CompressedTraitRefs {
            type Output = Self;
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub(self, other: Self) -> Self { self.difference(other) }
        }
        impl ::bitflags::__private::core::ops::SubAssign for
            CompressedTraitRefs {
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub_assign(&mut self, other: Self) { self.remove(other); }
        }
        impl ::bitflags::__private::core::ops::Not for CompressedTraitRefs {
            type Output = Self;
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            fn not(self) -> Self { self.complement() }
        }
        impl ::bitflags::__private::core::iter::Extend<CompressedTraitRefs>
            for CompressedTraitRefs {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(&mut self, iterator: T) {
                for item in iterator { self.insert(item) }
            }
        }
        impl ::bitflags::__private::core::iter::FromIterator<CompressedTraitRefs>
            for CompressedTraitRefs {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(iterator: T) -> Self {
                use ::bitflags::__private::core::iter::Extend;
                let mut result = Self::empty();
                result.extend(iterator);
                result
            }
        }
        impl CompressedTraitRefs {
            /// Yield a set of contained flags values.
            ///
            /// Each yielded flags value will correspond to a defined named flag. Any unknown bits
            /// will be yielded together as a final flags value.
            #[inline]
            pub const fn iter(&self)
                -> ::bitflags::iter::Iter<CompressedTraitRefs> {
                ::bitflags::iter::Iter::__private_const_new(<CompressedTraitRefs
                        as ::bitflags::Flags>::FLAGS,
                    CompressedTraitRefs::from_bits_retain(self.bits()),
                    CompressedTraitRefs::from_bits_retain(self.bits()))
            }
            /// Yield a set of contained named flags values.
            ///
            /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
            /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
            #[inline]
            pub const fn iter_names(&self)
                -> ::bitflags::iter::IterNames<CompressedTraitRefs> {
                ::bitflags::iter::IterNames::__private_const_new(<CompressedTraitRefs
                        as ::bitflags::Flags>::FLAGS,
                    CompressedTraitRefs::from_bits_retain(self.bits()),
                    CompressedTraitRefs::from_bits_retain(self.bits()))
            }
        }
        impl ::bitflags::__private::core::iter::IntoIterator for
            CompressedTraitRefs {
            type Item = CompressedTraitRefs;
            type IntoIter = ::bitflags::iter::Iter<CompressedTraitRefs>;
            fn into_iter(self) -> Self::IntoIter { self.iter() }
        }
    };bitflags::bitflags! {
785    impl CompressedTraitRefs: u32 {
786        const SIZED = 1;
787        const META_SIZED = 1 << 1;
788        const POINTEE_SIZED = 1 << 2;
789        const CLONE = 1 << 3;
790        const COPY = 1 << 4;
791        const DEBUG = 1 << 5;
792        const DROP = 1 << 6;
793        const UNPIN = 1 << 7;
794        const EQ = 1 << 8;
795        const SEND = 1 << 9;
796        const SYNC = 1 << 10;
797    }
798}
799
800impl CompressedTraitRefs {
801    pub fn get_and_mask_least_significant_bit(&mut self) -> Option<Self> {
802        let bs = self.bits();
803        if bs == 0 {
804            return None;
805        }
806
807        // `bs & -bs` (but for unsigned numbers), to get only the LSB set
808        // This blog helped me: https://lemire.me/blog/2018/02/21/iterating-over-set-bits-quickly/.
809        // This is the result we're looking for, but we want to still mask it out of self.
810        let only_lsb_set = bs & (!bs + 1);
811
812        // To mask it, we xor it out of bs, and put it into self.
813        // NOTE: this can never fail by the arithmetic we did above.
814        *self = CompressedTraitRefs::from_bits(bs ^ only_lsb_set).unwrap();
815
816        // Construct the one with only a single bit set.
817        Some(CompressedTraitRefs::from_bits(only_lsb_set).unwrap())
818    }
819
820    #[inline]
821    pub fn from_lang_item(lang_item: SolverTraitLangItem) -> Option<Self> {
822        Some(match lang_item {
823            SolverTraitLangItem::Sized => CompressedTraitRefs::SIZED,
824            SolverTraitLangItem::MetaSized => CompressedTraitRefs::META_SIZED,
825            SolverTraitLangItem::PointeeSized => CompressedTraitRefs::POINTEE_SIZED,
826            SolverTraitLangItem::Clone => CompressedTraitRefs::CLONE,
827            SolverTraitLangItem::Copy => CompressedTraitRefs::COPY,
828            SolverTraitLangItem::Debug => CompressedTraitRefs::DEBUG,
829            SolverTraitLangItem::Drop => CompressedTraitRefs::DROP,
830            SolverTraitLangItem::Unpin => CompressedTraitRefs::UNPIN,
831            SolverTraitLangItem::Eq => CompressedTraitRefs::EQ,
832            SolverTraitLangItem::Send => CompressedTraitRefs::SEND,
833            SolverTraitLangItem::Sync => CompressedTraitRefs::SYNC,
834            _ => return None,
835        })
836    }
837
838    #[inline]
839    pub fn lang_item_from_single_bit(self) -> SolverTraitLangItem {
840        match self {
841            Self::SIZED => SolverTraitLangItem::Sized,
842            Self::META_SIZED => SolverTraitLangItem::MetaSized,
843            Self::POINTEE_SIZED => SolverTraitLangItem::PointeeSized,
844            Self::CLONE => SolverTraitLangItem::Clone,
845            Self::COPY => SolverTraitLangItem::Copy,
846            Self::DEBUG => SolverTraitLangItem::Debug,
847            Self::DROP => SolverTraitLangItem::Drop,
848            Self::UNPIN => SolverTraitLangItem::Unpin,
849            Self::EQ => SolverTraitLangItem::Eq,
850            Self::SEND => SolverTraitLangItem::Send,
851            Self::SYNC => SolverTraitLangItem::Sync,
852            _ => ::core::panicking::unreachable_default_msg()unreachable!(),
853        }
854    }
855
856    #[inline]
857    pub fn trait_clause_from_def_id<I: Interner>(
858        cx: I,
859        self_ty: I::GenericArgs,
860        def_id: I::TraitId,
861    ) -> Binder<I, TraitClause<I>> {
862        // Note that `self_ty` is a GenericArgs, but only contains a single
863        // argument which is the trait's self_ty. This is done for perf.
864        Binder::dummy(TraitClause {
865            trait_ref: TraitRef::new_from_args(cx, def_id, self_ty),
866            polarity: ClausePolarity::Positive,
867        })
868    }
869
870    #[inline]
871    pub fn trait_clause_from_single_bit<I: Interner>(
872        self,
873        cx: I,
874        self_ty: I::GenericArgs,
875    ) -> Binder<I, TraitClause<I>> {
876        Self::trait_clause_from_def_id(
877            cx,
878            self_ty,
879            cx.require_trait_lang_item(self.lang_item_from_single_bit()),
880        )
881    }
882}
883
884/// A clause kind that represents a small set of frequently occurring clauses as a bitset for a given self type.
885/// When multiple common clauses exist in a paramenv, they're merged together so the paramenv can be
886/// stored more efficiently.
887///
888/// # WARNING/FIXME:
889///
890/// Computing type flags for common clauses works correctly.
891/// However, folding and visiting with [`TypeFoldable`](crate::TypeFoldable) and
892/// [`TypeVisitable`](crate::TypeVisitable) does *not* work as expected.
893/// If we were to decompress `ParamEnv`s everytime we folded/visited it would be super expensive.
894/// So we don't, and assume that it's enough to fold/visit into the `self_ty`. This works because
895/// the traits represented by [`ClauseKind::CompressedTrait`] don't have generic args or anything
896/// complicated. A normal fold/visit of them will effectively only care about `self_ty`.
897#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for CompressedTraitClause<I> where
    I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for CompressedTraitClause<I> where
    I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for CompressedTraitClause<I> where
    I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            CompressedTraitClause {
                self_ty: ref __field_self_ty,
                compressed_trait_refs: ref __field_compressed_trait_refs } =>
                {
                ::core::hash::Hash::hash(__field_self_ty, __state);
                ::core::hash::Hash::hash(__field_compressed_trait_refs,
                    __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for CompressedTraitClause<I> where
    I: Interner {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (CompressedTraitClause {
                self_ty: ref __field_self_ty,
                compressed_trait_refs: ref __field_compressed_trait_refs },
                CompressedTraitClause {
                self_ty: ref __other_field_self_ty,
                compressed_trait_refs: ref __other_field_compressed_trait_refs
                }) =>
                true &&
                        ::core::cmp::PartialEq::eq(__field_self_ty,
                            __other_field_self_ty) &&
                    ::core::cmp::PartialEq::eq(__field_compressed_trait_refs,
                        __other_field_compressed_trait_refs),
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
898#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            CompressedTraitClause<I> where I: Interner,
            I::GenericArgs: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    CompressedTraitClause { self_ty: ref __binding_0, .. } => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            CompressedTraitClause<I> where
            I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
            CompressedTraitRefs: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    CompressedTraitClause {
                        self_ty: ref __binding_0,
                        compressed_trait_refs: ref __binding_1 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            CompressedTraitClause<I> where I: Interner,
            I::GenericArgs: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        CompressedTraitClause {
                            self_ty: __binding_0, compressed_trait_refs: __binding_1 }
                            => {
                            CompressedTraitClause {
                                self_ty: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                compressed_trait_refs: __binding_1,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    CompressedTraitClause {
                        self_ty: __binding_0, compressed_trait_refs: __binding_1 }
                        => {
                        CompressedTraitClause {
                            self_ty: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            compressed_trait_refs: __binding_1,
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
899#[cfg_attr(
900    feature = "nightly",
901    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for CompressedTraitClause<I>
            where I::GenericArgs: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let CompressedTraitClause {
                        self_ty: ref __binding_0,
                        compressed_trait_refs: ref __binding_1 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for CompressedTraitClause<I>
            where I::GenericArgs: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                CompressedTraitClause {
                    self_ty: ::rustc_serialize::Decodable::decode(__decoder),
                    compressed_trait_refs: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            CompressedTraitClause<I> where
            I::GenericArgs: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    CompressedTraitClause {
                        self_ty: ref __binding_0,
                        compressed_trait_refs: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
902)]
903pub struct CompressedTraitClause<I: Interner> {
904    // Note: always only contains a single self ty.
905    // Storing it as `GenericArgs` makes decompression faster.
906    // Note that some of the folds and visits we do over compressed traits
907    // ignore the trait ref and only recurses into self_ty. This is *incorrect*
908    // if `self_ty` ever contained more than one generic arg.
909    pub self_ty: I::GenericArgs,
910
911    #[type_foldable(identity)]
912    #[type_visitable(ignore)]
913    pub compressed_trait_refs: CompressedTraitRefs,
914}
915
916impl<I: Interner> fmt::Debug for CompressedTraitClause<I> {
917    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
918        f.write_fmt(format_args!("{0:?} as {1}", self.self_ty,
        self.compressed_trait_refs.iter_names().map(|i|
                        i.0).collect::<Vec<_>>().join(",")))write!(
919            f,
920            "{:?} as {}",
921            self.self_ty,
922            self.compressed_trait_refs.iter_names().map(|i| i.0).collect::<Vec<_>>().join(",")
923        )
924    }
925}
926
927impl<I: Interner> CompressedTraitClause<I> {
928    /// Returns `Some` if the passed clause is eligible to be represented as a `CommonClause`.
929    /// Only a few clauses are, but those clauses are exceedingly common.
930    pub fn from_clause(cx: I, clause: I::Clause) -> Option<Self> {
931        let kind = clause.kind();
932        let kind = kind.no_bound_vars()?;
933        match kind {
934            ClauseKind::Trait(TraitClause { trait_ref, polarity }) => {
935                if #[allow(non_exhaustive_omitted_patterns)] match polarity {
    ClausePolarity::Negative => true,
    _ => false,
}matches!(polarity, ClausePolarity::Negative) {
936                    return None;
937                }
938
939                let compressed_trait_refs =
940                    CompressedTraitRefs::from_lang_item(cx.as_trait_lang_item(trait_ref.def_id)?)?;
941
942                // The args of the trait ref should *only* contain a self ty
943                // when used in a compressed clause.
944                if true {
    {
        match (&trait_ref.args.len(), &1) {
            (left_val, right_val) => {
                if !(*left_val == *right_val) {
                    let kind = ::core::panicking::AssertKind::Eq;
                    ::core::panicking::assert_failed(kind, &*left_val,
                        &*right_val, ::core::option::Option::None);
                }
            }
        }
    };
};debug_assert_eq!(trait_ref.args.len(), 1);
945                Some(Self { self_ty: trait_ref.args, compressed_trait_refs })
946            }
947            ClauseKind::RegionOutlives(_) => None,
948            ClauseKind::TypeOutlives(_) => None,
949            ClauseKind::Projection(_) => None,
950            ClauseKind::ConstArgHasType(_, _) => None,
951            ClauseKind::WellFormed(_) => None,
952            ClauseKind::ConstEvaluatable(_) => None,
953            ClauseKind::HostEffect(_) => None,
954            ClauseKind::UnstableFeature(_) => None,
955            ClauseKind::CompressedTrait(_) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
956        }
957    }
958
959    /// Try to merge an `other` clause into `self`.
960    /// If possible, `true` is returned, and `self` will now represent both clauses in a compressed form.
961    /// Upon calling `iter_clauses`, both original clauses are returned.
962    pub fn try_merge(&mut self, other: Self) -> bool {
963        if self.self_ty == other.self_ty {
964            self.compressed_trait_refs |= other.compressed_trait_refs;
965            true
966        } else {
967            false
968        }
969    }
970}