Skip to main content

rustc_type_ir/
ty_kind.rs

1use std::fmt;
2use std::marker::PhantomData;
3use std::ops::Deref;
4
5use derive_where::derive_where;
6use rustc_abi::ExternAbi;
7use rustc_ast_ir::Mutability;
8#[cfg(feature = "nightly")]
9use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHasher};
10#[cfg(feature = "nightly")]
11use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash_NoContext};
12use rustc_type_ir::data_structures::{NoError, UnifyKey, UnifyValue};
13use rustc_type_ir_macros::{
14    GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic,
15};
16
17use self::TyKind::*;
18pub use self::closure::*;
19use crate::inherent::*;
20use crate::ty::AliasTy;
21use crate::{
22    self as ty, BoundVarIndexKind, FloatTy, FreeAliasTy, InherentAliasTy, IntTy, Interner,
23    OpaqueAliasTy, ProjectionAliasTy, Region, UintTy, Unnormalized,
24};
25
26mod closure;
27
28#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for AliasTyKind<I> where I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            AliasTyKind::Projection { def_id: ref __field_def_id } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "Projection");
                ::core::fmt::DebugStruct::field(&mut __builder, "def_id",
                    __field_def_id);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
            AliasTyKind::Inherent { def_id: ref __field_def_id } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "Inherent");
                ::core::fmt::DebugStruct::field(&mut __builder, "def_id",
                    __field_def_id);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
            AliasTyKind::Opaque { def_id: ref __field_def_id } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "Opaque");
                ::core::fmt::DebugStruct::field(&mut __builder, "def_id",
                    __field_def_id);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
            AliasTyKind::Free { def_id: ref __field_def_id } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "Free");
                ::core::fmt::DebugStruct::field(&mut __builder, "def_id",
                    __field_def_id);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
29#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for AliasTyKind<I>
            where I: Interner,
            I::TraitAssocTyId: ::rustc_type_ir::TypeVisitable<I>,
            I::InherentAssocTyId: ::rustc_type_ir::TypeVisitable<I>,
            I::OpaqueTyId: ::rustc_type_ir::TypeVisitable<I>,
            I::FreeTyAliasId: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    AliasTyKind::Projection { def_id: 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);
                                }
                            }
                        }
                    }
                    AliasTyKind::Inherent { def_id: 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);
                                }
                            }
                        }
                    }
                    AliasTyKind::Opaque { def_id: 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);
                                }
                            }
                        }
                    }
                    AliasTyKind::Free { def_id: 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, GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for AliasTyKind<I>
            where I: Interner,
            I::TraitAssocTyId: ::rustc_type_ir::TypeFoldable<I>,
            I::InherentAssocTyId: ::rustc_type_ir::TypeFoldable<I>,
            I::OpaqueTyId: ::rustc_type_ir::TypeFoldable<I>,
            I::FreeTyAliasId: ::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 {
                        AliasTyKind::Projection { def_id: __binding_0 } => {
                            AliasTyKind::Projection {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                            }
                        }
                        AliasTyKind::Inherent { def_id: __binding_0 } => {
                            AliasTyKind::Inherent {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                            }
                        }
                        AliasTyKind::Opaque { def_id: __binding_0 } => {
                            AliasTyKind::Opaque {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                            }
                        }
                        AliasTyKind::Free { def_id: __binding_0 } => {
                            AliasTyKind::Free {
                                def_id: ::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 {
                    AliasTyKind::Projection { def_id: __binding_0 } => {
                        AliasTyKind::Projection {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                    AliasTyKind::Inherent { def_id: __binding_0 } => {
                        AliasTyKind::Inherent {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                    AliasTyKind::Opaque { def_id: __binding_0 } => {
                        AliasTyKind::Opaque {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                    AliasTyKind::Free { def_id: __binding_0 } => {
                        AliasTyKind::Free {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for AliasTyKind<I>
            where J: Interner, I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = AliasTyKind<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    AliasTyKind::Projection { def_id: __binding_0 } => {
                        AliasTyKind::Projection {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                    AliasTyKind::Inherent { def_id: __binding_0 } => {
                        AliasTyKind::Inherent {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                    AliasTyKind::Opaque { def_id: __binding_0 } => {
                        AliasTyKind::Opaque {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                    AliasTyKind::Free { def_id: __binding_0 } => {
                        AliasTyKind::Free {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
30#[cfg_attr(
31    feature = "nightly",
32    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for AliasTyKind<I> where
            I::TraitAssocTyId: ::rustc_serialize::Encodable<__E>,
            I::InherentAssocTyId: ::rustc_serialize::Encodable<__E>,
            I::OpaqueTyId: ::rustc_serialize::Encodable<__E>,
            I::FreeTyAliasId: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        AliasTyKind::Projection { def_id: ref __binding_0 } => {
                            0usize
                        }
                        AliasTyKind::Inherent { def_id: ref __binding_0 } => {
                            1usize
                        }
                        AliasTyKind::Opaque { def_id: ref __binding_0 } => {
                            2usize
                        }
                        AliasTyKind::Free { def_id: ref __binding_0 } => { 3usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    AliasTyKind::Projection { def_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    AliasTyKind::Inherent { def_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    AliasTyKind::Opaque { def_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    AliasTyKind::Free { def_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for AliasTyKind<I> where
            I::TraitAssocTyId: ::rustc_serialize::Decodable<__D>,
            I::InherentAssocTyId: ::rustc_serialize::Decodable<__D>,
            I::OpaqueTyId: ::rustc_serialize::Decodable<__D>,
            I::FreeTyAliasId: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        AliasTyKind::Projection {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    1usize => {
                        AliasTyKind::Inherent {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    2usize => {
                        AliasTyKind::Opaque {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    3usize => {
                        AliasTyKind::Free {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `AliasTyKind`, expected 0..4, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            AliasTyKind<I> where
            I::TraitAssocTyId: ::rustc_data_structures::stable_hash::StableHash,
            I::InherentAssocTyId: ::rustc_data_structures::stable_hash::StableHash,
            I::OpaqueTyId: ::rustc_data_structures::stable_hash::StableHash,
            I::FreeTyAliasId: ::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) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    AliasTyKind::Projection { def_id: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    AliasTyKind::Inherent { def_id: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    AliasTyKind::Opaque { def_id: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    AliasTyKind::Free { def_id: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
33)]
34pub enum AliasTyKind<I: Interner> {
35    /// A projection `<Type as Trait>::AssocType`.
36    ///
37    /// Can get normalized away if monomorphic enough.
38    ///
39    /// The `def_id` is the `DefId` of the `TraitItem` for the associated type.
40    ///
41    /// Note that the `def_id` is not the `DefId` of the `TraitRef` containing this
42    /// associated type, which is in `interner.associated_item(def_id).container`,
43    /// aka. `interner.parent(def_id)`.
44    Projection { def_id: I::TraitAssocTyId },
45
46    /// An associated type in an inherent `impl`
47    ///
48    /// The `def_id` is the `DefId` of the `ImplItem` for the associated type.
49    Inherent { def_id: I::InherentAssocTyId },
50
51    /// An opaque type (usually from `impl Trait` in type aliases or function return types)
52    ///
53    /// `def_id` is the `DefId` of the `OpaqueType` item.
54    ///
55    ///
56    /// Can only be normalized away in `PostAnalysis` mode or its defining scope.
57    ///
58    /// During codegen, `interner.type_of(def_id)` can be used to get the type of the
59    /// underlying type if the type is an opaque.
60    Opaque { def_id: I::OpaqueTyId },
61
62    /// A type alias that actually checks its trait bounds.
63    ///
64    /// Currently only used if the type alias references opaque types.
65    /// Can always be normalized away.
66    Free { def_id: I::FreeTyAliasId },
67}
68
69impl<I: Interner> AliasTyKind<I> {
70    pub fn descr(self) -> &'static str {
71        match self {
72            AliasTyKind::Projection { .. } => "associated type",
73            AliasTyKind::Inherent { .. } => "inherent associated type",
74            AliasTyKind::Opaque { .. } => "opaque type",
75            AliasTyKind::Free { .. } => "type alias",
76        }
77    }
78
79    pub fn try_to_projection(self) -> Option<I::TraitAssocTyId> {
80        match self {
81            AliasTyKind::Projection { def_id } => Some(def_id),
82            _ => None,
83        }
84    }
85
86    pub fn try_to_inherent(self) -> Option<I::InherentAssocTyId> {
87        match self {
88            AliasTyKind::Inherent { def_id } => Some(def_id),
89            _ => None,
90        }
91    }
92
93    pub fn try_to_opaque(self) -> Option<I::OpaqueTyId> {
94        match self {
95            AliasTyKind::Opaque { def_id } => Some(def_id),
96            _ => None,
97        }
98    }
99
100    pub fn try_to_free(self) -> Option<I::FreeTyAliasId> {
101        match self {
102            AliasTyKind::Free { def_id } => Some(def_id),
103            _ => None,
104        }
105    }
106}
107
108/// Whether an alias type is rigid or potentially normalizeable.
109///
110/// This is not used by the old solver and is always `IsRigid::No` there. In the new solver,
111/// aliases which cannot be further normalized in their current scope normalize to themselves
112/// with `IsRigid::Yes`. At this point we no longer have to try and renormalize this alias
113/// later on.
114///
115/// FIXME(#155345): Alias handling is currently still in flux for the new trait
116/// solver and this is currently somewhat messy. Please reach out on
117/// #t-types/trait-system-refactor-initiative if you encounter this and it isn't
118/// immediately clear what to do.
119#[derive(#[automatically_derived]
impl ::core::fmt::Debug for IsRigid {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self { IsRigid::Yes => "Yes", IsRigid::No => "No", })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for IsRigid {
    #[inline]
    fn clone(&self) -> IsRigid { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for IsRigid { }Copy, #[automatically_derived]
impl ::core::hash::Hash for IsRigid {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state)
    }
}Hash, #[automatically_derived]
impl ::core::cmp::PartialEq for IsRigid {
    #[inline]
    fn eq(&self, other: &IsRigid) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq)]
120#[derive(const _: () =
    {
        impl<I> ::rustc_type_ir::TypeVisitable<I> for IsRigid where
            I: Interner {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self { IsRigid::Yes => {} IsRigid::No => {} }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, GenericTypeVisitable, const _: () =
    {
        impl<I> ::rustc_type_ir::TypeFoldable<I> for IsRigid where I: Interner
            {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        IsRigid::Yes => { IsRigid::Yes }
                        IsRigid::No => { IsRigid::No }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    IsRigid::Yes => { IsRigid::Yes }
                    IsRigid::No => { IsRigid::No }
                }
            }
        }
    };TypeFoldable_Generic)]
121#[cfg_attr(
122    feature = "nightly",
123    derive(const _: () =
    {
        impl<__D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for IsRigid {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { IsRigid::Yes }
                    1usize => { IsRigid::No }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `IsRigid`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<__E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for IsRigid {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        IsRigid::Yes => { 0usize }
                        IsRigid::No => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self { IsRigid::Yes => {} IsRigid::No => {} }
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for IsRigid {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self { IsRigid::Yes => {} IsRigid::No => {} }
            }
        }
    };StableHash_NoContext)
124)]
125pub enum IsRigid {
126    Yes,
127    No,
128}
129
130impl IsRigid {
131    pub fn yes_if_next_solver<I: Interner>(interner: I) -> IsRigid {
132        if interner.next_trait_solver_globally() { IsRigid::Yes } else { IsRigid::No }
133    }
134}
135
136/// Defines the kinds of types used by the type system.
137///
138/// Types written by the user start out as `hir::TyKind` and get
139/// converted to this representation using `<dyn HirTyLowerer>::lower_ty`.
140#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "IrTyKind")]
141#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for TyKind<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) {
                (TyKind::Int(ref __field_0), TyKind::Int(ref __other_field_0))
                    =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (TyKind::Uint(ref __field_0),
                    TyKind::Uint(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (TyKind::Float(ref __field_0),
                    TyKind::Float(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (TyKind::Adt(ref __field_0, ref __field_1),
                    TyKind::Adt(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),
                (TyKind::Foreign(ref __field_0),
                    TyKind::Foreign(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (TyKind::Array(ref __field_0, ref __field_1),
                    TyKind::Array(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),
                (TyKind::Pat(ref __field_0, ref __field_1),
                    TyKind::Pat(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),
                (TyKind::Slice(ref __field_0),
                    TyKind::Slice(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (TyKind::RawPtr(ref __field_0, ref __field_1),
                    TyKind::RawPtr(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),
                (TyKind::Ref(ref __field_0, ref __field_1, ref __field_2),
                    TyKind::Ref(ref __other_field_0, ref __other_field_1,
                    ref __other_field_2)) =>
                    true &&
                                ::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
                            ::core::cmp::PartialEq::eq(__field_1, __other_field_1) &&
                        ::core::cmp::PartialEq::eq(__field_2, __other_field_2),
                (TyKind::FnDef(ref __field_0, ref __field_1),
                    TyKind::FnDef(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),
                (TyKind::FnPtr(ref __field_0, ref __field_1),
                    TyKind::FnPtr(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),
                (TyKind::UnsafeBinder(ref __field_0),
                    TyKind::UnsafeBinder(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (TyKind::Dynamic(ref __field_0, ref __field_1),
                    TyKind::Dynamic(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),
                (TyKind::Closure(ref __field_0, ref __field_1),
                    TyKind::Closure(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),
                (TyKind::CoroutineClosure(ref __field_0, ref __field_1),
                    TyKind::CoroutineClosure(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),
                (TyKind::Coroutine(ref __field_0, ref __field_1),
                    TyKind::Coroutine(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),
                (TyKind::CoroutineWitness(ref __field_0, ref __field_1),
                    TyKind::CoroutineWitness(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),
                (TyKind::Tuple(ref __field_0),
                    TyKind::Tuple(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (TyKind::Alias(ref __field_0, ref __field_1),
                    TyKind::Alias(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),
                (TyKind::Param(ref __field_0),
                    TyKind::Param(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (TyKind::Bound(ref __field_0, ref __field_1),
                    TyKind::Bound(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),
                (TyKind::Placeholder(ref __field_0),
                    TyKind::Placeholder(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (TyKind::Infer(ref __field_0),
                    TyKind::Infer(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (TyKind::Error(ref __field_0),
                    TyKind::Error(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                _ => true,
            }
        } else { false }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
142#[derive(GenericTypeVisitable)]
143#[cfg_attr(
144    feature = "nightly",
145    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for TyKind<I> where
            I::AdtDef: ::rustc_serialize::Encodable<__E>,
            I::GenericArgs: ::rustc_serialize::Encodable<__E>,
            I::ForeignId: ::rustc_serialize::Encodable<__E>,
            I::Ty: ::rustc_serialize::Encodable<__E>,
            I::Const: ::rustc_serialize::Encodable<__E>,
            I::Pat: ::rustc_serialize::Encodable<__E>,
            Region<I>: ::rustc_serialize::Encodable<__E>,
            I::FunctionId: ::rustc_serialize::Encodable<__E>,
            ty::Binder<I, I::GenericArgs>: ::rustc_serialize::Encodable<__E>,
            ty::Binder<I, FnSigTys<I>>: ::rustc_serialize::Encodable<__E>,
            FnHeader<I>: ::rustc_serialize::Encodable<__E>,
            UnsafeBinderInner<I>: ::rustc_serialize::Encodable<__E>,
            I::BoundExistentialPredicates: ::rustc_serialize::Encodable<__E>,
            I::ClosureId: ::rustc_serialize::Encodable<__E>,
            I::CoroutineClosureId: ::rustc_serialize::Encodable<__E>,
            I::CoroutineId: ::rustc_serialize::Encodable<__E>,
            I::Tys: ::rustc_serialize::Encodable<__E>,
            AliasTy<I>: ::rustc_serialize::Encodable<__E>,
            I::ParamTy: ::rustc_serialize::Encodable<__E>,
            ty::BoundTy<I>: ::rustc_serialize::Encodable<__E>,
            ty::PlaceholderType<I>: ::rustc_serialize::Encodable<__E>,
            I::ErrorGuaranteed: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        TyKind::Bool => { 0usize }
                        TyKind::Char => { 1usize }
                        TyKind::Int(ref __binding_0) => { 2usize }
                        TyKind::Uint(ref __binding_0) => { 3usize }
                        TyKind::Float(ref __binding_0) => { 4usize }
                        TyKind::Adt(ref __binding_0, ref __binding_1) => { 5usize }
                        TyKind::Foreign(ref __binding_0) => { 6usize }
                        TyKind::Str => { 7usize }
                        TyKind::Array(ref __binding_0, ref __binding_1) => {
                            8usize
                        }
                        TyKind::Pat(ref __binding_0, ref __binding_1) => { 9usize }
                        TyKind::Slice(ref __binding_0) => { 10usize }
                        TyKind::RawPtr(ref __binding_0, ref __binding_1) => {
                            11usize
                        }
                        TyKind::Ref(ref __binding_0, ref __binding_1,
                            ref __binding_2) => {
                            12usize
                        }
                        TyKind::FnDef(ref __binding_0, ref __binding_1) => {
                            13usize
                        }
                        TyKind::FnPtr(ref __binding_0, ref __binding_1) => {
                            14usize
                        }
                        TyKind::UnsafeBinder(ref __binding_0) => { 15usize }
                        TyKind::Dynamic(ref __binding_0, ref __binding_1) => {
                            16usize
                        }
                        TyKind::Closure(ref __binding_0, ref __binding_1) => {
                            17usize
                        }
                        TyKind::CoroutineClosure(ref __binding_0, ref __binding_1)
                            => {
                            18usize
                        }
                        TyKind::Coroutine(ref __binding_0, ref __binding_1) => {
                            19usize
                        }
                        TyKind::CoroutineWitness(ref __binding_0, ref __binding_1)
                            => {
                            20usize
                        }
                        TyKind::Never => { 21usize }
                        TyKind::Tuple(ref __binding_0) => { 22usize }
                        TyKind::Alias(ref __binding_0, ref __binding_1) => {
                            23usize
                        }
                        TyKind::Param(ref __binding_0) => { 24usize }
                        TyKind::Bound(ref __binding_0, ref __binding_1) => {
                            25usize
                        }
                        TyKind::Placeholder(ref __binding_0) => { 26usize }
                        TyKind::Infer(ref __binding_0) => { 27usize }
                        TyKind::Error(ref __binding_0) => { 28usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    TyKind::Bool => {}
                    TyKind::Char => {}
                    TyKind::Int(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TyKind::Uint(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TyKind::Float(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TyKind::Adt(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::Foreign(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TyKind::Str => {}
                    TyKind::Array(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::Pat(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::Slice(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TyKind::RawPtr(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::Ref(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                            __encoder);
                    }
                    TyKind::FnDef(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::FnPtr(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::UnsafeBinder(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TyKind::Dynamic(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::Closure(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::CoroutineClosure(ref __binding_0, ref __binding_1)
                        => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::Coroutine(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::CoroutineWitness(ref __binding_0, ref __binding_1)
                        => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::Never => {}
                    TyKind::Tuple(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TyKind::Alias(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::Param(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TyKind::Bound(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    TyKind::Placeholder(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TyKind::Infer(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    TyKind::Error(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for TyKind<I> where
            I::AdtDef: ::rustc_serialize::Decodable<__D>,
            I::GenericArgs: ::rustc_serialize::Decodable<__D>,
            I::ForeignId: ::rustc_serialize::Decodable<__D>,
            I::Ty: ::rustc_serialize::Decodable<__D>,
            I::Const: ::rustc_serialize::Decodable<__D>,
            I::Pat: ::rustc_serialize::Decodable<__D>,
            Region<I>: ::rustc_serialize::Decodable<__D>,
            I::FunctionId: ::rustc_serialize::Decodable<__D>,
            ty::Binder<I, I::GenericArgs>: ::rustc_serialize::Decodable<__D>,
            ty::Binder<I, FnSigTys<I>>: ::rustc_serialize::Decodable<__D>,
            FnHeader<I>: ::rustc_serialize::Decodable<__D>,
            UnsafeBinderInner<I>: ::rustc_serialize::Decodable<__D>,
            I::BoundExistentialPredicates: ::rustc_serialize::Decodable<__D>,
            I::ClosureId: ::rustc_serialize::Decodable<__D>,
            I::CoroutineClosureId: ::rustc_serialize::Decodable<__D>,
            I::CoroutineId: ::rustc_serialize::Decodable<__D>,
            I::Tys: ::rustc_serialize::Decodable<__D>,
            AliasTy<I>: ::rustc_serialize::Decodable<__D>,
            I::ParamTy: ::rustc_serialize::Decodable<__D>,
            ty::BoundTy<I>: ::rustc_serialize::Decodable<__D>,
            ty::PlaceholderType<I>: ::rustc_serialize::Decodable<__D>,
            I::ErrorGuaranteed: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { TyKind::Bool }
                    1usize => { TyKind::Char }
                    2usize => {
                        TyKind::Int(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    3usize => {
                        TyKind::Uint(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    4usize => {
                        TyKind::Float(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    5usize => {
                        TyKind::Adt(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    6usize => {
                        TyKind::Foreign(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    7usize => { TyKind::Str }
                    8usize => {
                        TyKind::Array(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    9usize => {
                        TyKind::Pat(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    10usize => {
                        TyKind::Slice(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    11usize => {
                        TyKind::RawPtr(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    12usize => {
                        TyKind::Ref(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    13usize => {
                        TyKind::FnDef(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    14usize => {
                        TyKind::FnPtr(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    15usize => {
                        TyKind::UnsafeBinder(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    16usize => {
                        TyKind::Dynamic(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    17usize => {
                        TyKind::Closure(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    18usize => {
                        TyKind::CoroutineClosure(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    19usize => {
                        TyKind::Coroutine(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    20usize => {
                        TyKind::CoroutineWitness(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    21usize => { TyKind::Never }
                    22usize => {
                        TyKind::Tuple(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    23usize => {
                        TyKind::Alias(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    24usize => {
                        TyKind::Param(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    25usize => {
                        TyKind::Bound(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    26usize => {
                        TyKind::Placeholder(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    27usize => {
                        TyKind::Infer(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    28usize => {
                        TyKind::Error(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `TyKind`, expected 0..29, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            TyKind<I> where
            I::AdtDef: ::rustc_data_structures::stable_hash::StableHash,
            I::GenericArgs: ::rustc_data_structures::stable_hash::StableHash,
            I::ForeignId: ::rustc_data_structures::stable_hash::StableHash,
            I::Ty: ::rustc_data_structures::stable_hash::StableHash,
            I::Const: ::rustc_data_structures::stable_hash::StableHash,
            I::Pat: ::rustc_data_structures::stable_hash::StableHash,
            Region<I>: ::rustc_data_structures::stable_hash::StableHash,
            I::FunctionId: ::rustc_data_structures::stable_hash::StableHash,
            ty::Binder<I,
            I::GenericArgs>: ::rustc_data_structures::stable_hash::StableHash,
            ty::Binder<I,
            FnSigTys<I>>: ::rustc_data_structures::stable_hash::StableHash,
            FnHeader<I>: ::rustc_data_structures::stable_hash::StableHash,
            UnsafeBinderInner<I>: ::rustc_data_structures::stable_hash::StableHash,
            I::BoundExistentialPredicates: ::rustc_data_structures::stable_hash::StableHash,
            I::ClosureId: ::rustc_data_structures::stable_hash::StableHash,
            I::CoroutineClosureId: ::rustc_data_structures::stable_hash::StableHash,
            I::CoroutineId: ::rustc_data_structures::stable_hash::StableHash,
            I::Tys: ::rustc_data_structures::stable_hash::StableHash,
            AliasTy<I>: ::rustc_data_structures::stable_hash::StableHash,
            I::ParamTy: ::rustc_data_structures::stable_hash::StableHash,
            ty::BoundTy<I>: ::rustc_data_structures::stable_hash::StableHash,
            ty::PlaceholderType<I>: ::rustc_data_structures::stable_hash::StableHash,
            I::ErrorGuaranteed: ::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) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    TyKind::Bool => {}
                    TyKind::Char => {}
                    TyKind::Int(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Uint(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Float(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Adt(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Foreign(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Str => {}
                    TyKind::Array(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Pat(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Slice(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::RawPtr(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Ref(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::FnDef(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::FnPtr(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::UnsafeBinder(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Dynamic(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Closure(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::CoroutineClosure(ref __binding_0, ref __binding_1)
                        => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Coroutine(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::CoroutineWitness(ref __binding_0, ref __binding_1)
                        => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Never => {}
                    TyKind::Tuple(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Alias(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Param(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Bound(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Placeholder(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Infer(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    TyKind::Error(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
146)]
147pub enum TyKind<I: Interner> {
148    /// The primitive boolean type. Written as `bool`.
149    Bool,
150
151    /// The primitive character type; holds a Unicode scalar value
152    /// (a non-surrogate code point). Written as `char`.
153    Char,
154
155    /// A primitive signed integer type. For example, `i32`.
156    Int(IntTy),
157
158    /// A primitive unsigned integer type. For example, `u32`.
159    Uint(UintTy),
160
161    /// A primitive floating-point type. For example, `f64`.
162    Float(FloatTy),
163
164    /// Algebraic data types (ADT). For example: structures, enumerations and unions.
165    ///
166    /// For example, the type `List<i32>` would be represented using the `AdtDef`
167    /// for `struct List<T>` and the args `[i32]`.
168    ///
169    /// Note that generic parameters in fields only get lazily instantiated
170    /// by using something like `adt_def.all_fields().map(|field| field.ty(interner, args))`.
171    Adt(I::AdtDef, I::GenericArgs),
172
173    /// An unsized FFI type that is opaque to Rust. Written as `extern type T`.
174    Foreign(I::ForeignId),
175
176    /// The pointee of a string slice. Written as `str`.
177    Str,
178
179    /// An array with the given length. Written as `[T; N]`.
180    Array(I::Ty, I::Const),
181
182    /// A pattern newtype.
183    ///
184    /// Takes any type and restricts its valid values to its pattern.
185    /// This will also change the layout to take advantage of this restriction.
186    /// Only `Copy` and `Clone` will automatically get implemented for pattern types.
187    /// Auto-traits treat this as if it were an aggregate with a single nested type.
188    /// Only supports integer range patterns for now.
189    Pat(I::Ty, I::Pat),
190
191    /// The pointee of an array slice. Written as `[T]`.
192    Slice(I::Ty),
193
194    /// A raw pointer. Written as `*mut T` or `*const T`
195    RawPtr(I::Ty, Mutability),
196
197    /// A reference; a pointer with an associated lifetime. Written as
198    /// `&'a mut T` or `&'a T`.
199    Ref(Region<I>, I::Ty, Mutability),
200
201    /// The anonymous type of a function declaration/definition.
202    ///
203    /// Each function has a unique type.
204    ///
205    /// For the function `fn foo() -> i32 { 3 }` this type would be
206    /// shown to the user as `fn() -> i32 {foo}`.
207    ///
208    /// For example the type of `bar` here:
209    /// ```rust
210    /// fn foo() -> i32 { 1 }
211    /// let bar = foo; // bar: fn() -> i32 {foo}
212    /// ```
213    FnDef(I::FunctionId, ty::Binder<I, I::GenericArgs>),
214
215    /// A pointer to a function.
216    ///
217    /// Written as `fn() -> i32`.
218    ///
219    /// Note that both functions and closures start out as either
220    /// [FnDef] or [Closure] which can be then be coerced to this variant.
221    ///
222    /// For example the type of `bar` here:
223    ///
224    /// ```rust
225    /// fn foo() -> i32 { 1 }
226    /// let bar: fn() -> i32 = foo;
227    /// ```
228    ///
229    /// These two fields are equivalent to a `ty::Binder<I, FnSig<I>>`. But by
230    /// splitting that into two pieces, we get a more compact data layout that
231    /// reduces the size of `TyKind` by 8 bytes. It is a very hot type, so it's
232    /// worth the mild inconvenience.
233    FnPtr(ty::Binder<I, FnSigTys<I>>, FnHeader<I>),
234
235    /// An unsafe binder type.
236    ///
237    /// A higher-ranked type used to represent a type which has had some of its
238    /// lifetimes erased. This can be used to represent types in positions where
239    /// a lifetime is literally inexpressible, such as self-referential types.
240    UnsafeBinder(UnsafeBinderInner<I>),
241
242    /// A trait object. Written as `dyn for<'b> Trait<'b, Assoc = u32> + Send + 'a`.
243    Dynamic(I::BoundExistentialPredicates, Region<I>),
244
245    /// The anonymous type of a closure. Used to represent the type of `|a| a`.
246    ///
247    /// Closure args contain both the - potentially instantiated - generic parameters
248    /// of its parent and some synthetic parameters. See the documentation for
249    /// `ClosureArgs` for more details.
250    Closure(I::ClosureId, I::GenericArgs),
251
252    /// The anonymous type of a closure. Used to represent the type of `async |a| a`.
253    ///
254    /// Coroutine-closure args contain both the - potentially instantiated - generic
255    /// parameters of its parent and some synthetic parameters. See the documentation
256    /// for `CoroutineClosureArgs` for more details.
257    CoroutineClosure(I::CoroutineClosureId, I::GenericArgs),
258
259    /// The anonymous type of a coroutine. Used to represent the type of
260    /// `|a| yield a`.
261    ///
262    /// For more info about coroutine args, visit the documentation for
263    /// `CoroutineArgs`.
264    Coroutine(I::CoroutineId, I::GenericArgs),
265
266    /// A type representing the types stored inside a coroutine.
267    ///
268    /// This should only appear as part of the `CoroutineArgs`.
269    ///
270    /// Unlike upvars, the witness can reference lifetimes from
271    /// inside of the coroutine itself. To deal with them in
272    /// the type of the coroutine, we convert them to higher ranked
273    /// lifetimes bound by the witness itself.
274    ///
275    /// This contains the `DefId` and the `GenericArgsRef` of the coroutine.
276    /// The actual witness types are computed on MIR by the `mir_coroutine_witnesses` query.
277    ///
278    /// Looking at the following example, the witness for this coroutine
279    /// may end up as something like `for<'a> [Vec<i32>, &'a Vec<i32>]`:
280    ///
281    /// ```
282    /// #![feature(coroutines)]
283    /// #[coroutine] static |a| {
284    ///     let x = &vec![3];
285    ///     yield a;
286    ///     yield x[0];
287    /// }
288    /// # ;
289    /// ```
290    CoroutineWitness(I::CoroutineId, I::GenericArgs),
291
292    /// The never type `!`.
293    Never,
294
295    /// A tuple type. For example, `(i32, bool)`.
296    Tuple(I::Tys),
297
298    /// A projection, opaque type, free type alias, or inherent associated type.
299    ///
300    /// All of these types are represented as pairs of def-id and args, and can
301    /// be normalized, so they are grouped conceptually.
302    Alias(IsRigid, AliasTy<I>),
303
304    /// A type parameter; for example, `T` in `fn f<T>(x: T) {}`.
305    Param(I::ParamTy),
306
307    /// Bound type variable, used to represent the `'a` in `for<'a> fn(&'a ())`.
308    ///
309    /// For canonical queries, we replace inference variables with bound variables,
310    /// so e.g. when checking whether `&'_ (): Trait<_>` holds, we canonicalize that to
311    /// `for<'a, T> &'a (): Trait<T>` and then convert the introduced bound variables
312    /// back to inference variables in a new inference context when inside of the query.
313    ///
314    /// It is conventional to render anonymous bound types like `^N` or `^D_N`,
315    /// where `N` is the bound variable's anonymous index into the binder, and
316    /// `D` is the debruijn index, or totally omitted if the debruijn index is zero.
317    ///
318    /// See the `rustc-dev-guide` for more details about
319    /// [higher-ranked trait bounds][1] and [canonical queries][2].
320    ///
321    /// [1]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
322    /// [2]: https://rustc-dev-guide.rust-lang.org/traits/canonical-queries.html
323    Bound(BoundVarIndexKind, ty::BoundTy<I>),
324
325    /// A placeholder type, used during higher ranked subtyping to instantiate
326    /// bound variables.
327    ///
328    /// It is conventional to render anonymous placeholder types like `!N` or `!U_N`,
329    /// where `N` is the placeholder variable's anonymous index (which corresponds
330    /// to the bound variable's index from the binder from which it was instantiated),
331    /// and `U` is the universe index in which it is instantiated, or totally omitted
332    /// if the universe index is zero.
333    Placeholder(ty::PlaceholderType<I>),
334
335    /// A type variable used during type checking.
336    ///
337    /// Similar to placeholders, inference variables also live in a universe to
338    /// correctly deal with higher ranked types. Though unlike placeholders,
339    /// that universe is stored in the `InferCtxt` instead of directly
340    /// inside of the type.
341    Infer(InferTy),
342
343    /// A placeholder for a type which could not be computed.
344    ///
345    /// This is propagated to avoid useless error messages.
346    Error(I::ErrorGuaranteed),
347}
348
349impl<I: Interner> Eq for TyKind<I> {}
350
351impl<I: Interner> TyKind<I> {
352    pub fn fn_sig(self, interner: I) -> ty::Binder<I, ty::FnSig<I>> {
353        self.unnormalized_fn_sig(interner).skip_normalization()
354    }
355
356    pub fn unnormalized_fn_sig(self, interner: I) -> Unnormalized<I, ty::Binder<I, ty::FnSig<I>>> {
357        match self {
358            ty::FnPtr(sig_tys, hdr) => Unnormalized::new_wip(sig_tys.with(hdr)),
359            ty::FnDef(def_id, args) => {
360                interner.fn_sig(def_id).instantiate(interner, args.no_bound_vars().unwrap())
361            }
362            ty::Error(_) => {
363                // ignore errors (#54954)
364                Unnormalized::dummy(ty::Binder::dummy(ty::FnSig::dummy()))
365            }
366            ty::Closure(..) => {
    ::core::panicking::panic_fmt(format_args!("to get the signature of a closure, use `args.as_closure().sig()` not `fn_sig()`"));
}panic!(
367                "to get the signature of a closure, use `args.as_closure().sig()` not `fn_sig()`",
368            ),
369            _ => {
    ::core::panicking::panic_fmt(format_args!("Ty::fn_sig() called on non-fn type: {0:?}",
            self));
}panic!("Ty::fn_sig() called on non-fn type: {:?}", self),
370        }
371    }
372
373    /// Returns `true` when the outermost type cannot be further normalized,
374    /// resolved, or instantiated.
375    ///
376    /// This includes all primitive types, but also
377    /// things like ADTs and trait objects, since even if their arguments or
378    /// nested types may be further simplified, the outermost [`ty::TyKind`] or
379    /// type constructor remains the same.
380    pub fn is_known_rigid(self) -> bool {
381        match self {
382            ty::Bool
383            | ty::Char
384            | ty::Int(_)
385            | ty::Uint(_)
386            | ty::Float(_)
387            | ty::Adt(_, _)
388            | ty::Foreign(_)
389            | ty::Str
390            | ty::Array(_, _)
391            | ty::Pat(_, _)
392            | ty::Slice(_)
393            | ty::RawPtr(_, _)
394            | ty::Ref(_, _, _)
395            | ty::FnDef(_, _)
396            | ty::FnPtr(..)
397            | ty::UnsafeBinder(_)
398            | ty::Dynamic(_, _)
399            | ty::Closure(_, _)
400            | ty::CoroutineClosure(_, _)
401            | ty::Coroutine(_, _)
402            | ty::CoroutineWitness(..)
403            | ty::Never
404            | ty::Tuple(_) => true,
405
406            ty::Error(_)
407            | ty::Infer(_)
408            | ty::Alias(ty::IsRigid::No | ty::IsRigid::Yes, _)
409            | ty::Param(_)
410            | ty::Bound(_, _)
411            | ty::Placeholder(_) => false,
412        }
413    }
414}
415
416// This is manually implemented because a derive would require `I: Debug`
417impl<I: Interner> fmt::Debug for TyKind<I> {
418    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
419        match self {
420            Bool => f.write_fmt(format_args!("bool"))write!(f, "bool"),
421            Char => f.write_fmt(format_args!("char"))write!(f, "char"),
422            Int(i) => f.write_fmt(format_args!("{0:?}", i))write!(f, "{i:?}"),
423            Uint(u) => f.write_fmt(format_args!("{0:?}", u))write!(f, "{u:?}"),
424            Float(float) => f.write_fmt(format_args!("{0:?}", float))write!(f, "{float:?}"),
425            Adt(d, s) => {
426                f.write_fmt(format_args!("{0:?}", d))write!(f, "{d:?}")?;
427                let mut s = s.iter();
428                let first = s.next();
429                match first {
430                    Some(first) => f.write_fmt(format_args!("<{0:?}", first))write!(f, "<{:?}", first)?,
431                    None => return Ok(()),
432                };
433
434                for arg in s {
435                    f.write_fmt(format_args!(", {0:?}", arg))write!(f, ", {:?}", arg)?;
436                }
437
438                f.write_fmt(format_args!(">"))write!(f, ">")
439            }
440            Foreign(d) => f.debug_tuple("Foreign").field(d).finish(),
441            Str => f.write_fmt(format_args!("str"))write!(f, "str"),
442            Array(t, c) => f.write_fmt(format_args!("[{0:?}; {1:?}]", t, c))write!(f, "[{t:?}; {c:?}]"),
443            Pat(t, p) => f.write_fmt(format_args!("pattern_type!({0:?} is {1:?})", t, p))write!(f, "pattern_type!({t:?} is {p:?})"),
444            Slice(t) => f.write_fmt(format_args!("[{0:?}]", &t))write!(f, "[{:?}]", &t),
445            RawPtr(ty, mutbl) => f.write_fmt(format_args!("*{0} {1:?}", mutbl.ptr_str(), ty))write!(f, "*{} {:?}", mutbl.ptr_str(), ty),
446            Ref(r, t, m) => f.write_fmt(format_args!("&{0:?} {1}{2:?}", r, m.prefix_str(), t))write!(f, "&{:?} {}{:?}", r, m.prefix_str(), t),
447            FnDef(d, s) => f.debug_tuple("FnDef").field(d).field(&s).finish(),
448            FnPtr(sig_tys, hdr) => f.write_fmt(format_args!("{0:?}", sig_tys.with(*hdr)))write!(f, "{:?}", sig_tys.with(*hdr)),
449            // FIXME(unsafe_binder): print this like `unsafe<'a> T<'a>`.
450            UnsafeBinder(binder) => f.write_fmt(format_args!("{0:?}", binder))write!(f, "{:?}", binder),
451            Dynamic(p, r) => f.write_fmt(format_args!("dyn {0:?} + {1:?}", p, r))write!(f, "dyn {p:?} + {r:?}"),
452            Closure(d, s) => f.debug_tuple("Closure").field(d).field(&s).finish(),
453            CoroutineClosure(d, s) => f.debug_tuple("CoroutineClosure").field(d).field(&s).finish(),
454            Coroutine(d, s) => f.debug_tuple("Coroutine").field(d).field(&s).finish(),
455            CoroutineWitness(d, s) => f.debug_tuple("CoroutineWitness").field(d).field(&s).finish(),
456            Never => f.write_fmt(format_args!("!"))write!(f, "!"),
457            Tuple(t) => {
458                f.write_fmt(format_args!("("))write!(f, "(")?;
459                let mut count = 0;
460                for ty in t.iter() {
461                    if count > 0 {
462                        f.write_fmt(format_args!(", "))write!(f, ", ")?;
463                    }
464                    f.write_fmt(format_args!("{0:?}", ty))write!(f, "{ty:?}")?;
465                    count += 1;
466                }
467                // unary tuples need a trailing comma
468                if count == 1 {
469                    f.write_fmt(format_args!(","))write!(f, ",")?;
470                }
471                f.write_fmt(format_args!(")"))write!(f, ")")
472            }
473            Alias(is_rigid, a) => f.debug_tuple("Alias").field(&is_rigid).field(&a).finish(),
474            Param(p) => f.write_fmt(format_args!("{0:?}", p))write!(f, "{p:?}"),
475            Bound(d, b) => crate::debug_bound_var(f, *d, b),
476            Placeholder(p) => f.write_fmt(format_args!("{0:?}", p))write!(f, "{p:?}"),
477            Infer(t) => f.write_fmt(format_args!("{0:?}", t))write!(f, "{:?}", t),
478            TyKind::Error(_) => f.write_fmt(format_args!("{{type error}}"))write!(f, "{{type error}}"),
479        }
480    }
481}
482
483impl<I: Interner> AliasTy<I> {
484    pub fn new_from_args(interner: I, kind: AliasTyKind<I>, args: I::GenericArgs) -> AliasTy<I> {
485        if truecfg!(debug_assertions) {
486            let def_id = match kind {
487                AliasTyKind::Projection { def_id } => def_id.into(),
488                AliasTyKind::Inherent { def_id } => def_id.into(),
489                AliasTyKind::Opaque { def_id } => def_id.into(),
490                AliasTyKind::Free { def_id } => def_id.into(),
491            };
492            interner.debug_assert_args_compatible(def_id, args);
493        }
494        AliasTy { kind, args, _use_alias_new_instead: () }
495    }
496
497    pub fn new(
498        interner: I,
499        kind: AliasTyKind<I>,
500        args: impl IntoIterator<Item: Into<I::GenericArg>>,
501    ) -> AliasTy<I> {
502        let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
503        Self::new_from_args(interner, kind, args)
504    }
505
506    /// Whether this alias type is an opaque.
507    pub fn is_opaque(self) -> bool {
508        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    AliasTyKind::Opaque { .. } => true,
    _ => false,
}matches!(self.kind, AliasTyKind::Opaque { .. })
509    }
510
511    pub fn to_ty(self, interner: I, is_rigid: ty::IsRigid) -> I::Ty {
512        Ty::new_alias(interner, is_rigid, self)
513    }
514
515    pub fn try_to_projection(self) -> Option<ProjectionAliasTy<I>> {
516        self.kind.try_to_projection().map(|kind| ty::Alias {
517            kind,
518            args: self.args,
519            _use_alias_new_instead: (),
520        })
521    }
522
523    pub fn try_to_inherent(self) -> Option<InherentAliasTy<I>> {
524        self.kind.try_to_inherent().map(|kind| ty::Alias {
525            kind,
526            args: self.args,
527            _use_alias_new_instead: (),
528        })
529    }
530
531    pub fn try_to_opaque(self) -> Option<OpaqueAliasTy<I>> {
532        self.kind.try_to_opaque().map(|kind| ty::Alias {
533            kind,
534            args: self.args,
535            _use_alias_new_instead: (),
536        })
537    }
538
539    pub fn try_to_free(self) -> Option<FreeAliasTy<I>> {
540        self.kind.try_to_free().map(|kind| ty::Alias {
541            kind,
542            args: self.args,
543            _use_alias_new_instead: (),
544        })
545    }
546}
547
548impl<I: Interner> ProjectionAliasTy<I> {
549    pub fn new_projection_from_args(
550        interner: I,
551        kind: I::TraitAssocTyId,
552        args: I::GenericArgs,
553    ) -> Self {
554        interner.debug_assert_args_compatible(kind.into(), args);
555        Self { kind, args, _use_alias_new_instead: () }
556    }
557
558    pub fn projection_to_alias_ty(self) -> AliasTy<I> {
559        AliasTy {
560            kind: AliasTyKind::Projection { def_id: self.kind },
561            args: self.args,
562            _use_alias_new_instead: (),
563        }
564    }
565
566    #[track_caller]
567    pub fn projection_self_ty(self) -> I::Ty {
568        self.args.type_at(0)
569    }
570}
571
572/// The following methods work only with (trait) associated type projections.
573// FIXME: Migrate these to the impl on ProjectionAliasTy (by making callers use `try_to_projection`
574// or similar when they guard for projections)
575impl<I: Interner> AliasTy<I> {
576    #[track_caller]
577    pub fn self_ty(self) -> I::Ty {
578        self.args.type_at(0)
579    }
580
581    pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
582        AliasTy::new(
583            interner,
584            self.kind,
585            [self_ty.into()].into_iter().chain(self.args.iter().skip(1)),
586        )
587    }
588
589    pub fn trait_def_id(self, interner: I) -> I::TraitId {
590        let AliasTyKind::Projection { def_id } = self.kind else { { ::core::panicking::panic_fmt(format_args!("expected a projection")); }panic!("expected a projection") };
591
592        interner.projection_parent(def_id.into())
593    }
594
595    /// Extracts the underlying trait reference and own args from this projection.
596    ///
597    /// For example, if this is a projection of `<T as StreamingIterator>::Item<'a>`,
598    /// then this function would return a `T: StreamingIterator` trait reference and
599    /// `['a]` as the own args.
600    pub fn trait_ref_and_own_args(self, interner: I) -> (ty::TraitRef<I>, I::GenericArgsSlice) {
601        let AliasTyKind::Projection { def_id } = self.kind else { { ::core::panicking::panic_fmt(format_args!("expected a projection")); }panic!("expected a projection") };
602
603        interner.trait_ref_and_own_args_for_alias(def_id.into(), self.args)
604    }
605
606    /// Extracts the underlying trait reference from this projection.
607    ///
608    /// For example, if this is a projection of `<T as Iterator>::Item`,
609    /// then this function would return a `T: Iterator` trait reference.
610    ///
611    /// WARNING: This will drop the args for generic associated types
612    /// consider calling [Self::trait_ref_and_own_args] to get those
613    /// as well.
614    pub fn trait_ref(self, interner: I) -> ty::TraitRef<I> {
615        self.trait_ref_and_own_args(interner).0
616    }
617}
618
619impl<I: Interner> InherentAliasTy<I> {
620    pub fn new_inherent_from_args(
621        interner: I,
622        kind: I::InherentAssocTyId,
623        args: I::GenericArgs,
624    ) -> Self {
625        interner.debug_assert_args_compatible(kind.into(), args);
626        Self { kind, args, _use_alias_new_instead: () }
627    }
628
629    pub fn inherent_to_alias_ty(self) -> AliasTy<I> {
630        AliasTy {
631            kind: AliasTyKind::Inherent { def_id: self.kind },
632            args: self.args,
633            _use_alias_new_instead: (),
634        }
635    }
636}
637
638impl<I: Interner> OpaqueAliasTy<I> {
639    pub fn new_opaque_from_args(interner: I, kind: I::OpaqueTyId, args: I::GenericArgs) -> Self {
640        interner.debug_assert_args_compatible(kind.into(), args);
641        Self { kind, args, _use_alias_new_instead: () }
642    }
643
644    pub fn opaque_to_alias_ty(self) -> AliasTy<I> {
645        AliasTy {
646            kind: AliasTyKind::Opaque { def_id: self.kind },
647            args: self.args,
648            _use_alias_new_instead: (),
649        }
650    }
651}
652
653impl<I: Interner> FreeAliasTy<I> {
654    pub fn new_free_from_args(interner: I, kind: I::FreeTyAliasId, args: I::GenericArgs) -> Self {
655        interner.debug_assert_args_compatible(kind.into(), args);
656        Self { kind, args, _use_alias_new_instead: () }
657    }
658
659    pub fn free_to_alias_ty(self) -> AliasTy<I> {
660        AliasTy {
661            kind: AliasTyKind::Free { def_id: self.kind },
662            args: self.args,
663            _use_alias_new_instead: (),
664        }
665    }
666}
667
668#[derive(#[automatically_derived]
impl ::core::clone::Clone for IntVarValue {
    #[inline]
    fn clone(&self) -> IntVarValue {
        let _: ::core::clone::AssertParamIsClone<IntTy>;
        let _: ::core::clone::AssertParamIsClone<UintTy>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for IntVarValue { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for IntVarValue {
    #[inline]
    fn eq(&self, other: &IntVarValue) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (IntVarValue::IntType(__self_0),
                    IntVarValue::IntType(__arg1_0)) => __self_0 == __arg1_0,
                (IntVarValue::UintType(__self_0),
                    IntVarValue::UintType(__arg1_0)) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for IntVarValue {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<IntTy>;
        let _: ::core::cmp::AssertParamIsEq<UintTy>;
    }
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for IntVarValue {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            IntVarValue::Unknown =>
                ::core::fmt::Formatter::write_str(f, "Unknown"),
            IntVarValue::IntType(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "IntType", &__self_0),
            IntVarValue::UintType(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "UintType", &__self_0),
        }
    }
}Debug)]
669pub enum IntVarValue {
670    Unknown,
671    IntType(IntTy),
672    UintType(UintTy),
673}
674
675impl IntVarValue {
676    pub fn is_known(self) -> bool {
677        match self {
678            IntVarValue::IntType(_) | IntVarValue::UintType(_) => true,
679            IntVarValue::Unknown => false,
680        }
681    }
682
683    pub fn is_unknown(self) -> bool {
684        !self.is_known()
685    }
686}
687
688#[derive(#[automatically_derived]
impl ::core::clone::Clone for FloatVarValue {
    #[inline]
    fn clone(&self) -> FloatVarValue {
        let _: ::core::clone::AssertParamIsClone<FloatTy>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for FloatVarValue { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for FloatVarValue {
    #[inline]
    fn eq(&self, other: &FloatVarValue) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (FloatVarValue::Known(__self_0),
                    FloatVarValue::Known(__arg1_0)) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FloatVarValue {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<FloatTy>;
    }
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for FloatVarValue {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            FloatVarValue::Unknown =>
                ::core::fmt::Formatter::write_str(f, "Unknown"),
            FloatVarValue::Known(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Known",
                    &__self_0),
        }
    }
}Debug)]
689pub enum FloatVarValue {
690    Unknown,
691    Known(FloatTy),
692}
693
694impl FloatVarValue {
695    pub fn is_known(self) -> bool {
696        match self {
697            FloatVarValue::Known(_) => true,
698            FloatVarValue::Unknown => false,
699        }
700    }
701
702    pub fn is_unknown(self) -> bool {
703        !self.is_known()
704    }
705}
706
707impl ::std::fmt::Debug for TyVid {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        fmt.write_fmt(format_args!("?{0}t", self.as_u32()))
    }
}rustc_index::newtype_index! {
708    /// A **ty**pe **v**ariable **ID**.
709    #[encodable]
710    #[orderable]
711    #[debug_format = "?{}t"]
712    #[gate_rustc_only]
713    pub struct TyVid {}
714}
715
716impl ::std::fmt::Debug for IntVid {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        fmt.write_fmt(format_args!("?{0}i", self.as_u32()))
    }
}rustc_index::newtype_index! {
717    /// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**.
718    #[encodable]
719    #[orderable]
720    #[debug_format = "?{}i"]
721    #[gate_rustc_only]
722    pub struct IntVid {}
723}
724
725impl ::std::fmt::Debug for FloatVid {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        fmt.write_fmt(format_args!("?{0}f", self.as_u32()))
    }
}rustc_index::newtype_index! {
726    /// A **float**ing-point (`f32` or `f64`) type **v**ariable **ID**.
727    #[encodable]
728    #[orderable]
729    #[debug_format = "?{}f"]
730    #[gate_rustc_only]
731    pub struct FloatVid {}
732}
733
734/// A placeholder for a type that hasn't been inferred yet.
735///
736/// E.g., if we have an empty array (`[]`), then we create a fresh
737/// type variable for the element type since we won't know until it's
738/// used what the element type is supposed to be.
739#[derive(#[automatically_derived]
impl ::core::clone::Clone for InferTy {
    #[inline]
    fn clone(&self) -> InferTy {
        let _: ::core::clone::AssertParamIsClone<TyVid>;
        let _: ::core::clone::AssertParamIsClone<IntVid>;
        let _: ::core::clone::AssertParamIsClone<FloatVid>;
        let _: ::core::clone::AssertParamIsClone<u32>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for InferTy { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for InferTy {
    #[inline]
    fn eq(&self, other: &InferTy) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (InferTy::TyVar(__self_0), InferTy::TyVar(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (InferTy::IntVar(__self_0), InferTy::IntVar(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (InferTy::FloatVar(__self_0), InferTy::FloatVar(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (InferTy::FreshTy(__self_0), InferTy::FreshTy(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (InferTy::FreshIntTy(__self_0), InferTy::FreshIntTy(__arg1_0))
                    => __self_0 == __arg1_0,
                (InferTy::FreshFloatTy(__self_0),
                    InferTy::FreshFloatTy(__arg1_0)) => __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for InferTy {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<TyVid>;
        let _: ::core::cmp::AssertParamIsEq<IntVid>;
        let _: ::core::cmp::AssertParamIsEq<FloatVid>;
        let _: ::core::cmp::AssertParamIsEq<u32>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for InferTy {
    #[inline]
    fn partial_cmp(&self, other: &InferTy)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for InferTy {
    #[inline]
    fn cmp(&self, other: &InferTy) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) {
            ::core::cmp::Ordering::Equal =>
                match (self, other) {
                    (InferTy::TyVar(__self_0), InferTy::TyVar(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    (InferTy::IntVar(__self_0), InferTy::IntVar(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    (InferTy::FloatVar(__self_0), InferTy::FloatVar(__arg1_0))
                        => ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    (InferTy::FreshTy(__self_0), InferTy::FreshTy(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    (InferTy::FreshIntTy(__self_0),
                        InferTy::FreshIntTy(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    (InferTy::FreshFloatTy(__self_0),
                        InferTy::FreshFloatTy(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    _ => unsafe { ::core::intrinsics::unreachable() }
                },
            cmp => cmp,
        }
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for InferTy {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state);
        match self {
            InferTy::TyVar(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            InferTy::IntVar(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            InferTy::FloatVar(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            InferTy::FreshTy(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            InferTy::FreshIntTy(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            InferTy::FreshFloatTy(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
        }
    }
}Hash)]
740#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<__E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for InferTy {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        InferTy::TyVar(ref __binding_0) => { 0usize }
                        InferTy::IntVar(ref __binding_0) => { 1usize }
                        InferTy::FloatVar(ref __binding_0) => { 2usize }
                        InferTy::FreshTy(ref __binding_0) => { 3usize }
                        InferTy::FreshIntTy(ref __binding_0) => { 4usize }
                        InferTy::FreshFloatTy(ref __binding_0) => { 5usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    InferTy::TyVar(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    InferTy::IntVar(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    InferTy::FloatVar(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    InferTy::FreshTy(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    InferTy::FreshIntTy(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    InferTy::FreshFloatTy(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<__D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for InferTy {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        InferTy::TyVar(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        InferTy::IntVar(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    2usize => {
                        InferTy::FloatVar(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    3usize => {
                        InferTy::FreshTy(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    4usize => {
                        InferTy::FreshIntTy(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    5usize => {
                        InferTy::FreshFloatTy(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `InferTy`, expected 0..6, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext))]
741pub enum InferTy {
742    /// A type variable.
743    TyVar(TyVid),
744    /// An integral type variable (`{integer}`).
745    ///
746    /// These are created when the compiler sees an integer literal like
747    /// `1` that could be several different types (`u8`, `i32`, `u32`, etc.).
748    /// We don't know until it's used what type it's supposed to be, so
749    /// we create a fresh type variable.
750    IntVar(IntVid),
751    /// A floating-point type variable (`{float}`).
752    ///
753    /// These are created when the compiler sees an float literal like
754    /// `1.0` that could be either an `f32` or an `f64`.
755    /// We don't know until it's used what type it's supposed to be, so
756    /// we create a fresh type variable.
757    FloatVar(FloatVid),
758
759    /// A [`FreshTy`][Self::FreshTy] is one that is generated as a replacement
760    /// for an unbound type variable.
761    ///
762    /// This is convenient for caching etc. See `TypeFreshener` for more details.
763    ///
764    /// Compare with [`TyVar`][Self::TyVar].
765    FreshTy(u32),
766    /// Like [`FreshTy`][Self::FreshTy], but as a replacement for [`IntVar`][Self::IntVar].
767    FreshIntTy(u32),
768    /// Like [`FreshTy`][Self::FreshTy], but as a replacement for [`FloatVar`][Self::FloatVar].
769    FreshFloatTy(u32),
770}
771
772impl UnifyValue for IntVarValue {
773    type Error = NoError;
774
775    fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
776        match (*value1, *value2) {
777            (IntVarValue::Unknown, IntVarValue::Unknown) => Ok(IntVarValue::Unknown),
778            (
779                IntVarValue::Unknown,
780                known @ (IntVarValue::UintType(_) | IntVarValue::IntType(_)),
781            )
782            | (
783                known @ (IntVarValue::UintType(_) | IntVarValue::IntType(_)),
784                IntVarValue::Unknown,
785            ) => Ok(known),
786            _ => {
    ::core::panicking::panic_fmt(format_args!("differing ints should have been resolved first"));
}panic!("differing ints should have been resolved first"),
787        }
788    }
789}
790
791impl UnifyKey for IntVid {
792    type Value = IntVarValue;
793    #[inline] // make this function eligible for inlining - it is quite hot.
794    fn index(&self) -> u32 {
795        self.as_u32()
796    }
797    #[inline]
798    fn from_index(i: u32) -> IntVid {
799        IntVid::from_u32(i)
800    }
801    fn tag() -> &'static str {
802        "IntVid"
803    }
804}
805
806impl UnifyValue for FloatVarValue {
807    type Error = NoError;
808
809    fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
810        match (*value1, *value2) {
811            (FloatVarValue::Unknown, FloatVarValue::Unknown) => Ok(FloatVarValue::Unknown),
812            (FloatVarValue::Unknown, FloatVarValue::Known(known))
813            | (FloatVarValue::Known(known), FloatVarValue::Unknown) => {
814                Ok(FloatVarValue::Known(known))
815            }
816            (FloatVarValue::Known(_), FloatVarValue::Known(_)) => {
817                {
    ::core::panicking::panic_fmt(format_args!("differing floats should have been resolved first"));
}panic!("differing floats should have been resolved first")
818            }
819        }
820    }
821}
822
823impl UnifyKey for FloatVid {
824    type Value = FloatVarValue;
825    #[inline]
826    fn index(&self) -> u32 {
827        self.as_u32()
828    }
829    #[inline]
830    fn from_index(i: u32) -> FloatVid {
831        FloatVid::from_u32(i)
832    }
833    fn tag() -> &'static str {
834        "FloatVid"
835    }
836}
837
838#[cfg(feature = "nightly")]
839impl StableHash for InferTy {
840    fn stable_hash<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
841        use InferTy::*;
842        std::mem::discriminant(self).stable_hash(hcx, hasher);
843        match self {
844            TyVar(_) | IntVar(_) | FloatVar(_) => {
845                {
    ::core::panicking::panic_fmt(format_args!("type variables should not be hashed: {0:?}",
            self));
}panic!("type variables should not be hashed: {self:?}")
846            }
847            FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.stable_hash(hcx, hasher),
848        }
849    }
850}
851
852impl fmt::Display for InferTy {
853    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
854        use InferTy::*;
855        match *self {
856            TyVar(_) => f.write_fmt(format_args!("_"))write!(f, "_"),
857            IntVar(_) => f.write_fmt(format_args!("{0}", "{integer}"))write!(f, "{}", "{integer}"),
858            FloatVar(_) => f.write_fmt(format_args!("{0}", "{float}"))write!(f, "{}", "{float}"),
859            FreshTy(v) => f.write_fmt(format_args!("FreshTy({0})", v))write!(f, "FreshTy({v})"),
860            FreshIntTy(v) => f.write_fmt(format_args!("FreshIntTy({0})", v))write!(f, "FreshIntTy({v})"),
861            FreshFloatTy(v) => f.write_fmt(format_args!("FreshFloatTy({0})", v))write!(f, "FreshFloatTy({v})"),
862        }
863    }
864}
865
866impl fmt::Debug for InferTy {
867    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
868        use InferTy::*;
869        match *self {
870            TyVar(ref v) => v.fmt(f),
871            IntVar(ref v) => v.fmt(f),
872            FloatVar(ref v) => v.fmt(f),
873            FreshTy(v) => f.write_fmt(format_args!("FreshTy({0:?})", v))write!(f, "FreshTy({v:?})"),
874            FreshIntTy(v) => f.write_fmt(format_args!("FreshIntTy({0:?})", v))write!(f, "FreshIntTy({v:?})"),
875            FreshFloatTy(v) => f.write_fmt(format_args!("FreshFloatTy({0:?})", v))write!(f, "FreshFloatTy({v:?})"),
876        }
877    }
878}
879
880#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for TypeAndMut<I> where I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            TypeAndMut { ty: ref __field_ty, mutbl: ref __field_mutbl } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "TypeAndMut");
                ::core::fmt::DebugStruct::field(&mut __builder, "ty",
                    __field_ty);
                ::core::fmt::DebugStruct::field(&mut __builder, "mutbl",
                    __field_mutbl);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Copy, PartialEq, Hash, Debug; I: Interner)]
881#[cfg_attr(
882    feature = "nightly",
883    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for TypeAndMut<I> where
            I::Ty: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    TypeAndMut { ty: ref __binding_0, mutbl: ref __binding_1 }
                        => {
                        ::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 TypeAndMut<I> where
            I::Ty: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                TypeAndMut {
                    ty: ::rustc_serialize::Decodable::decode(__decoder),
                    mutbl: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            TypeAndMut<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 {
                    TypeAndMut { ty: ref __binding_0, mutbl: ref __binding_1 }
                        => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
884)]
885#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for TypeAndMut<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 {
                    TypeAndMut { ty: ref __binding_0, mutbl: 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, GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for TypeAndMut<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 {
                        TypeAndMut { ty: __binding_0, mutbl: __binding_1 } => {
                            TypeAndMut {
                                ty: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                mutbl: ::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 {
                    TypeAndMut { ty: __binding_0, mutbl: __binding_1 } => {
                        TypeAndMut {
                            ty: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            mutbl: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
886pub struct TypeAndMut<I: Interner> {
887    pub ty: I::Ty,
888    pub mutbl: Mutability,
889}
890
891impl<I: Interner> Eq for TypeAndMut<I> {}
892
893/// Error type for splatted argument index errors.
894#[derive(#[automatically_derived]
impl ::core::fmt::Debug for SplattedArgIndexError {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            SplattedArgIndexError::InvalidIndex { splatted_arg_index: __self_0
                } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "InvalidIndex", "splatted_arg_index", &__self_0),
            SplattedArgIndexError::OutOfBounds {
                splatted_arg_index: __self_0, args_len: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "OutOfBounds", "splatted_arg_index", __self_0, "args_len",
                    &__self_1),
        }
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for SplattedArgIndexError {
    #[inline]
    fn clone(&self) -> SplattedArgIndexError {
        let _: ::core::clone::AssertParamIsClone<u8>;
        let _: ::core::clone::AssertParamIsClone<u16>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for SplattedArgIndexError { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for SplattedArgIndexError {
    #[inline]
    fn eq(&self, other: &SplattedArgIndexError) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (SplattedArgIndexError::InvalidIndex {
                    splatted_arg_index: __self_0 },
                    SplattedArgIndexError::InvalidIndex {
                    splatted_arg_index: __arg1_0 }) => __self_0 == __arg1_0,
                (SplattedArgIndexError::OutOfBounds {
                    splatted_arg_index: __self_0, args_len: __self_1 },
                    SplattedArgIndexError::OutOfBounds {
                    splatted_arg_index: __arg1_0, args_len: __arg1_1 }) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for SplattedArgIndexError {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<u8>;
        let _: ::core::cmp::AssertParamIsEq<u16>;
    }
}Eq)]
895pub enum SplattedArgIndexError {
896    /// The splatted argument index is invalid.
897    /// A `u8::MAX` argument index used to indicate that no argument is splatted.
898    /// Higher values are also not supported, for performance reasons.
899    InvalidIndex { splatted_arg_index: u8 },
900
901    /// The splatted argument index is outside the bounds of the function arguments.
902    OutOfBounds { splatted_arg_index: u8, args_len: u16 },
903}
904
905/// Contains the packed non-type fields of a function signature.
906#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for FnSigKind<I> where I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            FnSigKind {
                flags: ref __field_flags,
                splatted: ref __field_splatted,
                _marker: ref __field__marker } => {
                ::core::hash::Hash::hash(__field_flags, __state);
                ::core::hash::Hash::hash(__field_splatted, __state);
                ::core::hash::Hash::hash(__field__marker, __state);
            }
        }
    }
}#[derive_where(Copy, Clone, PartialEq, Eq, Hash; I: Interner)]
907#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for FnSigKind<I>
            where I: Interner {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self { FnSigKind { .. } => {} }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for FnSigKind<I>
            where I: Interner {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        FnSigKind {
                            flags: __binding_0,
                            splatted: __binding_1,
                            _marker: __binding_2 } => {
                            FnSigKind {
                                flags: __binding_0,
                                splatted: __binding_1,
                                _marker: __binding_2,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    FnSigKind {
                        flags: __binding_0,
                        splatted: __binding_1,
                        _marker: __binding_2 } => {
                        FnSigKind {
                            flags: __binding_0,
                            splatted: __binding_1,
                            _marker: __binding_2,
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for FnSigKind<I>
            where J: Interner, I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = FnSigKind<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    FnSigKind {
                        flags: __binding_0,
                        splatted: __binding_1,
                        _marker: __binding_2 } => {
                        FnSigKind {
                            flags: __binding_0,
                            splatted: __binding_1,
                            _marker: PhantomData,
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
908#[cfg_attr(
909    feature = "nightly",
910    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for FnSigKind<I> where
            PhantomData<fn() -> I>: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    FnSigKind {
                        flags: ref __binding_0,
                        splatted: ref __binding_1,
                        _marker: ref __binding_2 } => {
                        ::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, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for FnSigKind<I> where
            PhantomData<fn() -> I>: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                FnSigKind {
                    flags: ::rustc_serialize::Decodable::decode(__decoder),
                    splatted: ::rustc_serialize::Decodable::decode(__decoder),
                    _marker: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            FnSigKind<I> where
            PhantomData<fn()
                -> 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 {
                    FnSigKind {
                        flags: ref __binding_0,
                        splatted: ref __binding_1,
                        _marker: ref __binding_2 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
911)]
912pub struct FnSigKind<I: Interner> {
913    /// Holds the c_variadic and safety bitflags, and 6 bits for the `ExternAbi` variant and unwind
914    /// flag.
915    #[lift(identity)]
916    #[type_visitable(ignore)]
917    #[type_foldable(identity)]
918    flags: u8,
919
920    /// Which function argument is splatted into multiple arguments in callers, if any?
921    /// Splatting functions with `>= u8::MAX` arguments is not supported, for performance reasons.
922    /// (And spending an extra byte on an edge case is not worth the perf.)
923    #[lift(identity)]
924    #[type_visitable(ignore)]
925    #[type_foldable(identity)]
926    splatted: u8,
927
928    #[type_visitable(ignore)]
929    #[type_foldable(identity)]
930    _marker: PhantomData<fn() -> I>,
931}
932
933impl<I: Interner> fmt::Debug for FnSigKind<I> {
934    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
935        let mut f = f.debug_tuple("FnSigKind");
936
937        if self.is_safe() {
938            f.field(&"Safe");
939        } else {
940            f.field(&"Unsafe");
941        }
942
943        f.field(&self.abi());
944
945        if self.c_variadic() {
946            f.field(&"CVariadic");
947        }
948
949        if let Some(index) = self.splatted() {
950            f.field(&::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("Splatted({0})", index))
    })format!("Splatted({})", index));
951        }
952
953        f.finish()
954    }
955}
956
957impl<I: Interner> Default for FnSigKind<I> {
958    /// Create a new FnSigKind with the "Rust" ABI, "Unsafe" safety, and no C-style variadic or splatted arguments.
959    /// To modify these flags, use the `set_*` methods, for readability.
960    fn default() -> Self {
961        Self { flags: 0, splatted: 0, _marker: PhantomData }
962            .set_abi(ExternAbi::Rust)
963            .set_safety(I::Safety::unsafe_mode())
964            .set_c_variadic(false)
965            .set_no_splatted_args()
966    }
967}
968
969impl<I: Interner> FnSigKind<I> {
970    /// Mask for the `ExternAbi` variant, including the unwind flag.
971    const EXTERN_ABI_MASK: u8 = 0b111111;
972
973    /// Bitflag for `Safety::Safe`. The default is `Unsafe`.
974    const SAFE_FLAG: u8 = 1 << 6;
975
976    /// Bitflag for a trailing C-style variadic argument.
977    const C_VARIADIC_FLAG: u8 = 1 << 7;
978
979    /// The marker index for "no splatted arguments". Higher values are also not supported, for
980    /// performance reasons.
981    ///
982    /// Must have the same value as `FnDeclFlags::NO_SPLATTED_ARG_INDEX` and
983    /// `rustc_ast::FnDecl::NO_SPLATTED_ARG_INDEX`.
984    ///
985    /// This is an implementation detail, which should only be used in low-level encoding.
986    pub const NO_SPLATTED_ARG_INDEX: u8 = u8::MAX;
987
988    /// Create a new FnSigKind with the given ABI, safety, C-style variadic, and splatted argument
989    /// index.
990    pub fn new(
991        abi: ExternAbi,
992        safety: I::Safety,
993        c_variadic: bool,
994        splatted: Option<u8>,
995        args_len: usize,
996    ) -> Result<Self, SplattedArgIndexError> {
997        Self::default()
998            .set_abi(abi)
999            .set_safety(safety)
1000            .set_c_variadic(c_variadic)
1001            .set_splatted(splatted, args_len)
1002    }
1003
1004    /// Create a new safe FnSigKind with the `extern "Rust"` ABI, that isn't C-style variadic or splatted.
1005    pub fn dummy() -> Self {
1006        Self::default().set_safety(I::Safety::safe())
1007    }
1008
1009    /// Set the ABI, including the unwind flag.
1010    #[must_use = "this method does not modify the receiver"]
1011    pub fn set_abi(mut self, abi: ExternAbi) -> Self {
1012        let abi_index = abi.as_packed();
1013        if !(abi_index <= Self::EXTERN_ABI_MASK) {
    ::core::panicking::panic("assertion failed: abi_index <= Self::EXTERN_ABI_MASK")
};assert!(abi_index <= Self::EXTERN_ABI_MASK);
1014
1015        self.flags &= !Self::EXTERN_ABI_MASK;
1016        self.flags |= abi_index;
1017
1018        self
1019    }
1020
1021    /// Set the safety flag, `true` is `Safe`.
1022    #[must_use = "this method does not modify the receiver"]
1023    pub fn set_safety(mut self, safety: I::Safety) -> Self {
1024        if safety.is_safe() {
1025            self.flags |= Self::SAFE_FLAG;
1026        } else {
1027            self.flags &= !Self::SAFE_FLAG;
1028        }
1029
1030        self
1031    }
1032
1033    /// Set the C-style variadic argument flag.
1034    #[must_use = "this method does not modify the receiver"]
1035    pub fn set_c_variadic(mut self, c_variadic: bool) -> Self {
1036        if c_variadic {
1037            self.flags |= Self::C_VARIADIC_FLAG;
1038        } else {
1039            self.flags &= !Self::C_VARIADIC_FLAG;
1040        }
1041
1042        self
1043    }
1044
1045    /// Set the splatted argument index.
1046    /// The number of function arguments is used for error checking.
1047    #[must_use = "this method does not modify the receiver"]
1048    pub fn set_splatted(
1049        mut self,
1050        splatted: Option<u8>,
1051        args_len: usize,
1052    ) -> Result<Self, SplattedArgIndexError> {
1053        if let Some(splatted_arg_index) = splatted {
1054            if splatted_arg_index == Self::NO_SPLATTED_ARG_INDEX {
1055                // This index value is used as a marker for "no splatting", so it is unsupported.
1056                // Higher values are also not supported, for performance reasons.
1057                return Err(SplattedArgIndexError::InvalidIndex { splatted_arg_index });
1058            } else if usize::from(splatted_arg_index) >= args_len {
1059                return Err(SplattedArgIndexError::OutOfBounds {
1060                    splatted_arg_index,
1061                    args_len: args_len as u16,
1062                });
1063            }
1064
1065            self.splatted = splatted_arg_index;
1066        } else {
1067            self.splatted = Self::NO_SPLATTED_ARG_INDEX;
1068        }
1069
1070        Ok(self)
1071    }
1072
1073    /// Set the splatted argument index to "no splatted arguments".
1074    #[must_use = "this method does not modify the receiver"]
1075    pub fn set_no_splatted_args(mut self) -> Self {
1076        self.splatted = Self::NO_SPLATTED_ARG_INDEX;
1077        self
1078    }
1079
1080    /// Get the ABI, including the unwind flag.
1081    pub fn abi(self) -> ExternAbi {
1082        let abi_index = self.flags & Self::EXTERN_ABI_MASK;
1083        ExternAbi::from_packed(abi_index)
1084    }
1085
1086    /// Get the safety flag.
1087    pub fn is_safe(self) -> bool {
1088        self.flags & Self::SAFE_FLAG != 0
1089    }
1090
1091    /// Returns the safety mode.
1092    pub fn safety(self) -> I::Safety {
1093        if self.is_safe() { I::Safety::safe() } else { I::Safety::unsafe_mode() }
1094    }
1095
1096    /// Do the function arguments end with a C-style variadic argument?
1097    pub fn c_variadic(self) -> bool {
1098        self.flags & Self::C_VARIADIC_FLAG != 0
1099    }
1100
1101    /// Get the index of the splatted argument, if any.
1102    pub fn splatted(self) -> Option<u8> {
1103        if self.splatted == Self::NO_SPLATTED_ARG_INDEX { None } else { Some(self.splatted) }
1104    }
1105}
1106
1107#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for FnSig<I> where I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            FnSig {
                inputs_and_output: ref __field_inputs_and_output,
                fn_sig_kind: ref __field_fn_sig_kind } => {
                ::core::hash::Hash::hash(__field_inputs_and_output, __state);
                ::core::hash::Hash::hash(__field_fn_sig_kind, __state);
            }
        }
    }
}#[derive_where(Clone, Copy, PartialEq, Hash; I: Interner)]
1108#[cfg_attr(
1109    feature = "nightly",
1110    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for FnSig<I> where
            I::Tys: ::rustc_serialize::Encodable<__E>,
            FnSigKind<I>: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    FnSig {
                        inputs_and_output: ref __binding_0,
                        fn_sig_kind: ref __binding_1 } => {
                        ::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 FnSig<I> where
            I::Tys: ::rustc_serialize::Decodable<__D>,
            FnSigKind<I>: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                FnSig {
                    inputs_and_output: ::rustc_serialize::Decodable::decode(__decoder),
                    fn_sig_kind: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            FnSig<I> where
            I::Tys: ::rustc_data_structures::stable_hash::StableHash,
            FnSigKind<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 {
                    FnSig {
                        inputs_and_output: ref __binding_0,
                        fn_sig_kind: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
1111)]
1112#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for FnSig<I> where
            I: Interner, I::Tys: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    FnSig { inputs_and_output: 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, GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for FnSig<I> where
            I: Interner, I::Tys: ::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 {
                        FnSig {
                            inputs_and_output: __binding_0, fn_sig_kind: __binding_1 }
                            => {
                            FnSig {
                                inputs_and_output: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                fn_sig_kind: __binding_1,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    FnSig {
                        inputs_and_output: __binding_0, fn_sig_kind: __binding_1 }
                        => {
                        FnSig {
                            inputs_and_output: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            fn_sig_kind: __binding_1,
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for FnSig<I> where
            J: Interner, I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = FnSig<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    FnSig {
                        inputs_and_output: __binding_0, fn_sig_kind: __binding_1 }
                        => {
                        FnSig {
                            inputs_and_output: __binding_0.lift_to_interner(interner),
                            fn_sig_kind: __binding_1.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
1113pub struct FnSig<I: Interner> {
1114    pub inputs_and_output: I::Tys,
1115    #[type_visitable(ignore)]
1116    #[type_foldable(identity)]
1117    pub fn_sig_kind: FnSigKind<I>,
1118}
1119
1120impl<I: Interner> Eq for FnSig<I> {}
1121
1122impl<I: Interner> FnSig<I> {
1123    pub fn inputs(self) -> I::FnInputTys {
1124        self.inputs_and_output.inputs()
1125    }
1126
1127    pub fn output(self) -> I::Ty {
1128        self.inputs_and_output.output()
1129    }
1130
1131    pub fn is_fn_trait_compatible(self) -> bool {
1132        !self.c_variadic() && self.safety().is_safe() && self.abi() == ExternAbi::Rust
1133    }
1134
1135    /// Set the safety flag.
1136    #[must_use = "this method does not modify the receiver"]
1137    pub fn set_safety(self, safety: I::Safety) -> Self {
1138        Self { fn_sig_kind: self.fn_sig_kind.set_safety(safety), ..self }
1139    }
1140
1141    /// Set the splatted argument index.
1142    /// The number of function arguments is used for error checking.
1143    #[must_use = "this method does not modify the receiver"]
1144    pub fn set_splatted(
1145        self,
1146        splatted: Option<u8>,
1147        args_len: usize,
1148    ) -> Result<Self, SplattedArgIndexError> {
1149        Ok(Self { fn_sig_kind: self.fn_sig_kind.set_splatted(splatted, args_len)?, ..self })
1150    }
1151
1152    pub fn safety(self) -> I::Safety {
1153        self.fn_sig_kind.safety()
1154    }
1155
1156    pub fn abi(self) -> ExternAbi {
1157        self.fn_sig_kind.abi()
1158    }
1159
1160    pub fn c_variadic(self) -> bool {
1161        self.fn_sig_kind.c_variadic()
1162    }
1163
1164    pub fn splatted(self) -> Option<u8> {
1165        self.fn_sig_kind.splatted()
1166    }
1167
1168    /// Create a new safe FnSig with no arguments or return type, using the `extern "Rust"` ABI,
1169    /// that isn't C-style variadic or splatted.
1170    pub fn dummy() -> Self {
1171        Self { inputs_and_output: Default::default(), fn_sig_kind: FnSigKind::dummy() }
1172    }
1173}
1174
1175impl<I: Interner> ty::Binder<I, FnSig<I>> {
1176    #[inline]
1177    pub fn inputs(self) -> ty::Binder<I, I::FnInputTys> {
1178        self.map_bound(|fn_sig| fn_sig.inputs())
1179    }
1180
1181    #[inline]
1182    #[track_caller]
1183    pub fn input(self, index: usize) -> ty::Binder<I, I::Ty> {
1184        self.map_bound(|fn_sig| fn_sig.inputs().get(index).unwrap())
1185    }
1186
1187    pub fn inputs_and_output(self) -> ty::Binder<I, I::Tys> {
1188        self.map_bound(|fn_sig| fn_sig.inputs_and_output)
1189    }
1190
1191    #[inline]
1192    pub fn output(self) -> ty::Binder<I, I::Ty> {
1193        self.map_bound(|fn_sig| fn_sig.output())
1194    }
1195
1196    pub fn fn_sig_kind(self) -> FnSigKind<I> {
1197        self.skip_binder().fn_sig_kind
1198    }
1199
1200    pub fn c_variadic(self) -> bool {
1201        self.skip_binder().c_variadic()
1202    }
1203
1204    pub fn splatted(self) -> Option<u8> {
1205        self.skip_binder().splatted()
1206    }
1207
1208    pub fn safety(self) -> I::Safety {
1209        self.skip_binder().safety()
1210    }
1211
1212    pub fn abi(self) -> ExternAbi {
1213        self.skip_binder().abi()
1214    }
1215
1216    pub fn is_fn_trait_compatible(&self) -> bool {
1217        self.skip_binder().is_fn_trait_compatible()
1218    }
1219
1220    // Used to split a single value into the two fields in `TyKind::FnPtr`.
1221    pub fn split(self) -> (ty::Binder<I, FnSigTys<I>>, FnHeader<I>) {
1222        let hdr = FnHeader { fn_sig_kind: self.fn_sig_kind() };
1223        (self.map_bound(|sig| FnSigTys { inputs_and_output: sig.inputs_and_output }), hdr)
1224    }
1225}
1226
1227impl<I: Interner> fmt::Debug for FnSig<I> {
1228    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1229        let sig = self;
1230        let FnSig { inputs_and_output: _, fn_sig_kind } = sig;
1231
1232        f.write_fmt(format_args!("{0}", fn_sig_kind.safety().prefix_str()))write!(f, "{}", fn_sig_kind.safety().prefix_str())?;
1233        if fn_sig_kind.abi() != ExternAbi::Rust {
1234            f.write_fmt(format_args!("extern \"{0:?}\" ", fn_sig_kind.abi()))write!(f, "extern \"{:?}\" ", fn_sig_kind.abi())?;
1235        }
1236
1237        f.write_fmt(format_args!("fn("))write!(f, "fn(")?;
1238        let inputs = sig.inputs();
1239        for (i, ty) in inputs.iter().enumerate() {
1240            if i > 0 {
1241                f.write_fmt(format_args!(", "))write!(f, ", ")?;
1242            }
1243            if Some(i) == fn_sig_kind.splatted().map(usize::from) {
1244                f.write_fmt(format_args!("#[splat] "))write!(f, "#[splat] ")?;
1245            }
1246            f.write_fmt(format_args!("{0:?}", ty))write!(f, "{ty:?}")?;
1247        }
1248        if fn_sig_kind.c_variadic() {
1249            if inputs.is_empty() {
1250                f.write_fmt(format_args!("..."))write!(f, "...")?;
1251            } else {
1252                f.write_fmt(format_args!(", ..."))write!(f, ", ...")?;
1253            }
1254        }
1255        f.write_fmt(format_args!(")"))write!(f, ")")?;
1256
1257        let output = sig.output();
1258        match output.kind() {
1259            Tuple(list) if list.is_empty() => Ok(()),
1260            _ => f.write_fmt(format_args!(" -> {0:?}", sig.output()))write!(f, " -> {:?}", sig.output()),
1261        }
1262    }
1263}
1264
1265// FIXME: this is a distinct type because we need to define `Encode`/`Decode`
1266// impls in this crate for `Binder<I, I::Ty>`.
1267#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for UnsafeBinderInner<I> where
    I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            UnsafeBinderInner(ref __field_0) => {
                ::core::hash::Hash::hash(__field_0, __state);
            }
        }
    }
}#[derive_where(Clone, Copy, PartialEq, Hash; I: Interner)]
1268#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            UnsafeBinderInner<I> where
            ty::Binder<I,
            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 {
                    UnsafeBinderInner(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
1269#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            UnsafeBinderInner<I> where I: Interner,
            ty::Binder<I, I::Ty>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    UnsafeBinderInner(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, GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            UnsafeBinderInner<I> where I: Interner,
            ty::Binder<I, 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 {
                        UnsafeBinderInner(__binding_0) => {
                            UnsafeBinderInner(::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 {
                    UnsafeBinderInner(__binding_0) => {
                        UnsafeBinderInner(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
            UnsafeBinderInner<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = UnsafeBinderInner<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    UnsafeBinderInner(__binding_0) => {
                        UnsafeBinderInner(__binding_0.lift_to_interner(interner))
                    }
                }
            }
        }
    };Lift_Generic)]
1270pub struct UnsafeBinderInner<I: Interner>(ty::Binder<I, I::Ty>);
1271
1272impl<I: Interner> Eq for UnsafeBinderInner<I> {}
1273
1274impl<I: Interner> From<ty::Binder<I, I::Ty>> for UnsafeBinderInner<I> {
1275    fn from(value: ty::Binder<I, I::Ty>) -> Self {
1276        UnsafeBinderInner(value)
1277    }
1278}
1279
1280impl<I: Interner> From<UnsafeBinderInner<I>> for ty::Binder<I, I::Ty> {
1281    fn from(value: UnsafeBinderInner<I>) -> Self {
1282        value.0
1283    }
1284}
1285
1286impl<I: Interner> fmt::Debug for UnsafeBinderInner<I> {
1287    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1288        self.0.fmt(f)
1289    }
1290}
1291
1292impl<I: Interner> Deref for UnsafeBinderInner<I> {
1293    type Target = ty::Binder<I, I::Ty>;
1294
1295    fn deref(&self) -> &Self::Target {
1296        &self.0
1297    }
1298}
1299
1300// This is just a `FnSig` without the `FnHeader` fields.
1301#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for FnSigTys<I> where I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            FnSigTys { inputs_and_output: ref __field_inputs_and_output } => {
                ::core::hash::Hash::hash(__field_inputs_and_output, __state);
            }
        }
    }
}#[derive_where(Clone, Copy, Debug, PartialEq, Hash; I: Interner)]
1302#[cfg_attr(
1303    feature = "nightly",
1304    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for FnSigTys<I> where
            I::Tys: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    FnSigTys { inputs_and_output: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for FnSigTys<I> where
            I::Tys: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                FnSigTys {
                    inputs_and_output: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            FnSigTys<I> where
            I::Tys: ::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 {
                    FnSigTys { inputs_and_output: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
1305)]
1306#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for FnSigTys<I>
            where I: Interner, I::Tys: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    FnSigTys { inputs_and_output: 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, GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for FnSigTys<I>
            where I: Interner, I::Tys: ::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 {
                        FnSigTys { inputs_and_output: __binding_0 } => {
                            FnSigTys {
                                inputs_and_output: ::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 {
                    FnSigTys { inputs_and_output: __binding_0 } => {
                        FnSigTys {
                            inputs_and_output: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for FnSigTys<I>
            where J: Interner, I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = FnSigTys<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    FnSigTys { inputs_and_output: __binding_0 } => {
                        FnSigTys {
                            inputs_and_output: __binding_0.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
1307pub struct FnSigTys<I: Interner> {
1308    pub inputs_and_output: I::Tys,
1309}
1310
1311impl<I: Interner> Eq for FnSigTys<I> {}
1312
1313impl<I: Interner> FnSigTys<I> {
1314    pub fn inputs(self) -> I::FnInputTys {
1315        self.inputs_and_output.inputs()
1316    }
1317
1318    pub fn output(self) -> I::Ty {
1319        self.inputs_and_output.output()
1320    }
1321}
1322
1323impl<I: Interner> ty::Binder<I, FnSigTys<I>> {
1324    // Used to combine the two fields in `TyKind::FnPtr` into a single value.
1325    pub fn with(self, hdr: FnHeader<I>) -> ty::Binder<I, FnSig<I>> {
1326        self.map_bound(|sig_tys| FnSig {
1327            inputs_and_output: sig_tys.inputs_and_output,
1328            fn_sig_kind: hdr.fn_sig_kind,
1329        })
1330    }
1331
1332    #[inline]
1333    pub fn inputs(self) -> ty::Binder<I, I::FnInputTys> {
1334        self.map_bound(|sig_tys| sig_tys.inputs())
1335    }
1336
1337    #[inline]
1338    #[track_caller]
1339    pub fn input(self, index: usize) -> ty::Binder<I, I::Ty> {
1340        self.map_bound(|sig_tys| sig_tys.inputs().get(index).unwrap())
1341    }
1342
1343    pub fn inputs_and_output(self) -> ty::Binder<I, I::Tys> {
1344        self.map_bound(|sig_tys| sig_tys.inputs_and_output)
1345    }
1346
1347    #[inline]
1348    pub fn output(self) -> ty::Binder<I, I::Ty> {
1349        self.map_bound(|sig_tys| sig_tys.output())
1350    }
1351}
1352
1353#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for FnHeader<I> where I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            FnHeader { fn_sig_kind: ref __field_fn_sig_kind } => {
                ::core::hash::Hash::hash(__field_fn_sig_kind, __state);
            }
        }
    }
}#[derive_where(Clone, Copy, Debug, PartialEq, Hash; I: Interner)]
1354#[cfg_attr(
1355    feature = "nightly",
1356    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for FnHeader<I> where
            FnSigKind<I>: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    FnHeader { fn_sig_kind: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for FnHeader<I> where
            FnSigKind<I>: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                FnHeader {
                    fn_sig_kind: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            FnHeader<I> where
            FnSigKind<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 {
                    FnHeader { fn_sig_kind: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
1357)]
1358#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for FnHeader<I>
            where I: Interner {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self { FnHeader { .. } => {} }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for FnHeader<I>
            where I: Interner {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        FnHeader { fn_sig_kind: __binding_0 } => {
                            FnHeader { fn_sig_kind: __binding_0 }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    FnHeader { fn_sig_kind: __binding_0 } => {
                        FnHeader { fn_sig_kind: __binding_0 }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for FnHeader<I>
            where J: Interner, I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = FnHeader<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    FnHeader { fn_sig_kind: __binding_0 } => {
                        FnHeader {
                            fn_sig_kind: __binding_0.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
1359pub struct FnHeader<I: Interner> {
1360    #[type_visitable(ignore)]
1361    #[type_foldable(identity)]
1362    pub fn_sig_kind: FnSigKind<I>,
1363}
1364
1365impl<I: Interner> FnHeader<I> {
1366    pub fn c_variadic(self) -> bool {
1367        self.fn_sig_kind.c_variadic()
1368    }
1369
1370    pub fn safety(self) -> I::Safety {
1371        self.fn_sig_kind.safety()
1372    }
1373
1374    pub fn abi(self) -> ExternAbi {
1375        self.fn_sig_kind.abi()
1376    }
1377
1378    pub fn splatted(self) -> Option<u8> {
1379        self.fn_sig_kind.splatted()
1380    }
1381
1382    /// Create a new safe FnHeader with the `extern "Rust"` ABI, that isn't C-style variadic or splatted.
1383    pub fn dummy() -> Self {
1384        Self { fn_sig_kind: FnSigKind::dummy() }
1385    }
1386}
1387
1388impl<I: Interner> Eq for FnHeader<I> {}
1389
1390#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for CoroutineWitnessTypes<I> where
    I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            CoroutineWitnessTypes {
                types: ref __field_types, assumptions: ref __field_assumptions
                } => {
                ::core::hash::Hash::hash(__field_types, __state);
                ::core::hash::Hash::hash(__field_assumptions, __state);
            }
        }
    }
}#[derive_where(Clone, Copy, Debug, PartialEq, Hash; I: Interner)]
1391#[cfg_attr(
1392    feature = "nightly",
1393    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for CoroutineWitnessTypes<I>
            where I::Tys: ::rustc_serialize::Encodable<__E>,
            I::RegionAssumptions: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    CoroutineWitnessTypes {
                        types: ref __binding_0, assumptions: ref __binding_1 } => {
                        ::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 CoroutineWitnessTypes<I>
            where I::Tys: ::rustc_serialize::Decodable<__D>,
            I::RegionAssumptions: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                CoroutineWitnessTypes {
                    types: ::rustc_serialize::Decodable::decode(__decoder),
                    assumptions: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            CoroutineWitnessTypes<I> where
            I::Tys: ::rustc_data_structures::stable_hash::StableHash,
            I::RegionAssumptions: ::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 {
                    CoroutineWitnessTypes {
                        types: ref __binding_0, assumptions: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
1394)]
1395#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            CoroutineWitnessTypes<I> where I: Interner,
            I::Tys: ::rustc_type_ir::TypeVisitable<I>,
            I::RegionAssumptions: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    CoroutineWitnessTypes {
                        types: ref __binding_0, assumptions: 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, GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            CoroutineWitnessTypes<I> where I: Interner,
            I::Tys: ::rustc_type_ir::TypeFoldable<I>,
            I::RegionAssumptions: ::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 {
                        CoroutineWitnessTypes {
                            types: __binding_0, assumptions: __binding_1 } => {
                            CoroutineWitnessTypes {
                                types: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                assumptions: ::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 {
                    CoroutineWitnessTypes {
                        types: __binding_0, assumptions: __binding_1 } => {
                        CoroutineWitnessTypes {
                            types: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            assumptions: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
            CoroutineWitnessTypes<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = CoroutineWitnessTypes<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    CoroutineWitnessTypes {
                        types: __binding_0, assumptions: __binding_1 } => {
                        CoroutineWitnessTypes {
                            types: __binding_0.lift_to_interner(interner),
                            assumptions: __binding_1.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
1396pub struct CoroutineWitnessTypes<I: Interner> {
1397    pub types: I::Tys,
1398    pub assumptions: I::RegionAssumptions,
1399}
1400
1401impl<I: Interner> Eq for CoroutineWitnessTypes<I> {}