Skip to main content

rustc_type_ir/
const_kind.rs

1use std::fmt;
2
3use derive_where::derive_where;
4#[cfg(feature = "nightly")]
5use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHasher};
6#[cfg(feature = "nightly")]
7use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash, StableHash_NoContext};
8use rustc_type_ir_macros::{
9    GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic,
10};
11
12use crate::{self as ty, AliasConst, BoundVarIndexKind, Interner};
13
14/// Represents a constant in Rust.
15#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ConstKind<I> where I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for ConstKind<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ConstKind<I> where I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            ConstKind::Param(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            ConstKind::Infer(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            ConstKind::Bound(ref __field_0, ref __field_1) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
                ::core::hash::Hash::hash(__field_1, __state);
            }
            ConstKind::Placeholder(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            ConstKind::Alias(ref __field_0, ref __field_1) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
                ::core::hash::Hash::hash(__field_1, __state);
            }
            ConstKind::Value(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            ConstKind::Error(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            ConstKind::Expr(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ConstKind<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) {
                (ConstKind::Param(ref __field_0),
                    ConstKind::Param(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (ConstKind::Infer(ref __field_0),
                    ConstKind::Infer(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (ConstKind::Bound(ref __field_0, ref __field_1),
                    ConstKind::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),
                (ConstKind::Placeholder(ref __field_0),
                    ConstKind::Placeholder(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (ConstKind::Alias(ref __field_0, ref __field_1),
                    ConstKind::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),
                (ConstKind::Value(ref __field_0),
                    ConstKind::Value(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (ConstKind::Error(ref __field_0),
                    ConstKind::Error(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (ConstKind::Expr(ref __field_0),
                    ConstKind::Expr(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                _ => unsafe { ::core::hint::unreachable_unchecked() },
            }
        } else { false }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
16#[derive(const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for ConstKind<I> where
            I::ParamConst: ::rustc_type_ir::GenericTypeVisitable<__V>,
            InferConst: ::rustc_type_ir::GenericTypeVisitable<__V>,
            BoundVarIndexKind: ::rustc_type_ir::GenericTypeVisitable<__V>,
            ty::BoundConst<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            ty::PlaceholderConst<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            ty::IsRigid: ::rustc_type_ir::GenericTypeVisitable<__V>,
            ty::AliasConst<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::ValueConst: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::ErrorGuaranteed: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::ExprConst: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    ConstKind::Param(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    ConstKind::Infer(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    ConstKind::Bound(ref __binding_0, ref __binding_1) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                    ConstKind::Placeholder(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    ConstKind::Alias(ref __binding_0, ref __binding_1) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                    ConstKind::Value(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    ConstKind::Error(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    ConstKind::Expr(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable)]
17#[cfg_attr(
18    feature = "nightly",
19    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for ConstKind<I> where
            I::ParamConst: ::rustc_serialize::Encodable<__E>,
            ty::BoundConst<I>: ::rustc_serialize::Encodable<__E>,
            ty::PlaceholderConst<I>: ::rustc_serialize::Encodable<__E>,
            ty::AliasConst<I>: ::rustc_serialize::Encodable<__E>,
            I::ValueConst: ::rustc_serialize::Encodable<__E>,
            I::ErrorGuaranteed: ::rustc_serialize::Encodable<__E>,
            I::ExprConst: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        ConstKind::Param(ref __binding_0) => { 0usize }
                        ConstKind::Infer(ref __binding_0) => { 1usize }
                        ConstKind::Bound(ref __binding_0, ref __binding_1) => {
                            2usize
                        }
                        ConstKind::Placeholder(ref __binding_0) => { 3usize }
                        ConstKind::Alias(ref __binding_0, ref __binding_1) => {
                            4usize
                        }
                        ConstKind::Value(ref __binding_0) => { 5usize }
                        ConstKind::Error(ref __binding_0) => { 6usize }
                        ConstKind::Expr(ref __binding_0) => { 7usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    ConstKind::Param(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    ConstKind::Infer(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    ConstKind::Bound(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    ConstKind::Placeholder(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    ConstKind::Alias(ref __binding_0, ref __binding_1) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    ConstKind::Value(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    ConstKind::Error(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    ConstKind::Expr(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 ConstKind<I> where
            I::ParamConst: ::rustc_serialize::Decodable<__D>,
            ty::BoundConst<I>: ::rustc_serialize::Decodable<__D>,
            ty::PlaceholderConst<I>: ::rustc_serialize::Decodable<__D>,
            ty::AliasConst<I>: ::rustc_serialize::Decodable<__D>,
            I::ValueConst: ::rustc_serialize::Decodable<__D>,
            I::ErrorGuaranteed: ::rustc_serialize::Decodable<__D>,
            I::ExprConst: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        ConstKind::Param(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        ConstKind::Infer(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    2usize => {
                        ConstKind::Bound(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    3usize => {
                        ConstKind::Placeholder(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    4usize => {
                        ConstKind::Alias(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    5usize => {
                        ConstKind::Value(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    6usize => {
                        ConstKind::Error(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    7usize => {
                        ConstKind::Expr(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ConstKind`, expected 0..8, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            ConstKind<I> where
            I::ParamConst: ::rustc_data_structures::stable_hash::StableHash,
            ty::BoundConst<I>: ::rustc_data_structures::stable_hash::StableHash,
            ty::PlaceholderConst<I>: ::rustc_data_structures::stable_hash::StableHash,
            ty::AliasConst<I>: ::rustc_data_structures::stable_hash::StableHash,
            I::ValueConst: ::rustc_data_structures::stable_hash::StableHash,
            I::ErrorGuaranteed: ::rustc_data_structures::stable_hash::StableHash,
            I::ExprConst: ::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 {
                    ConstKind::Param(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    ConstKind::Infer(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    ConstKind::Bound(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    ConstKind::Placeholder(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    ConstKind::Alias(ref __binding_0, ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    ConstKind::Value(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    ConstKind::Error(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    ConstKind::Expr(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
20)]
21pub enum ConstKind<I: Interner> {
22    /// A const generic parameter.
23    Param(I::ParamConst),
24
25    /// Infer the value of the const.
26    Infer(InferConst),
27
28    /// Bound const variable, used only when preparing a trait query.
29    Bound(BoundVarIndexKind, ty::BoundConst<I>),
30
31    /// A placeholder const - universally quantified higher-ranked const.
32    Placeholder(ty::PlaceholderConst<I>),
33
34    /// An unnormalized const item such as an anon const or assoc const or free const item.
35    /// Right now anything other than anon consts does not actually work properly but this
36    /// should
37    Alias(ty::IsRigid, ty::AliasConst<I>),
38
39    /// Used to hold computed value.
40    Value(I::ValueConst),
41
42    /// A placeholder for a const which could not be computed; this is
43    /// propagated to avoid useless error messages.
44    Error(I::ErrorGuaranteed),
45
46    /// A non-const-item expression awaiting evaluation, used by `feature(generic_const_exprs)` to represent
47    /// const arguments such as `N + 1` or `foo(N)`
48    Expr(I::ExprConst),
49}
50
51impl<I: Interner> Eq for ConstKind<I> {}
52
53impl<I: Interner> fmt::Debug for ConstKind<I> {
54    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
55        use ConstKind::*;
56
57        match self {
58            Param(param) => f.write_fmt(format_args!("{0:?}", param))write!(f, "{param:?}"),
59            Infer(var) => f.write_fmt(format_args!("{0:?}", var))write!(f, "{var:?}"),
60            Bound(debruijn, var) => crate::debug_bound_var(f, *debruijn, var),
61            Placeholder(placeholder) => f.write_fmt(format_args!("{0:?}", placeholder))write!(f, "{placeholder:?}"),
62            Alias(is_rigid, alias_const) => {
63                f.write_fmt(format_args!("AliasConst({0:?}, {1:?})", is_rigid, alias_const))write!(f, "AliasConst({is_rigid:?}, {alias_const:?})")
64            }
65            Value(val) => f.write_fmt(format_args!("{0:?}", val))write!(f, "{val:?}"),
66            Error(_) => f.write_fmt(format_args!("{{const error}}"))write!(f, "{{const error}}"),
67            Expr(expr) => f.write_fmt(format_args!("{0:?}", expr))write!(f, "{expr:?}"),
68        }
69    }
70}
71
72impl<I: Interner> AliasConst<I> {
73    #[inline]
74    pub fn new(interner: I, kind: AliasConstKind<I>, args: I::GenericArgs) -> AliasConst<I> {
75        if truecfg!(debug_assertions) {
76            interner.debug_assert_alias_term_args_compatible(kind.into(), args);
77        }
78        AliasConst { kind, args, _use_alias_new_instead: () }
79    }
80
81    pub fn type_of(self, interner: I) -> ty::Unnormalized<I, I::Ty> {
82        let def_id = match self.kind {
83            ty::AliasConstKind::Projection { def_id } => def_id.into(),
84            ty::AliasConstKind::InherentSelf { .. } => {
85                {
    ::core::panicking::panic_fmt(format_args!("AliasConst::type_of got InherentSelf - args should always be InherentImpl at this point"));
}panic!(
86                    "AliasConst::type_of got InherentSelf - args should always be InherentImpl at this point"
87                )
88            }
89            ty::AliasConstKind::InherentImpl { def_id } => def_id.into(),
90            ty::AliasConstKind::Free { def_id } => def_id.into(),
91            ty::AliasConstKind::Anon { def_id } => def_id.into(),
92        };
93        interner.type_of(def_id).instantiate(interner, self.args)
94    }
95}
96
97/// AliasConstKind is extremely similar to AliasTyKind, and likely should be reasoned about
98/// and handled in very similar ways. The documentation for AliasTyKind/etc. may be helpful when
99/// learning about AliasConstKind.
100#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for AliasConstKind<I> where I: Interner
    {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for AliasConstKind<I> where I: Interner
    {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for AliasConstKind<I> where I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            AliasConstKind::Projection { def_id: ref __field_def_id } => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_def_id, __state);
            }
            AliasConstKind::InherentSelf { def_id: ref __field_def_id } => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_def_id, __state);
            }
            AliasConstKind::InherentImpl { def_id: ref __field_def_id } => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_def_id, __state);
            }
            AliasConstKind::Free { def_id: ref __field_def_id } => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_def_id, __state);
            }
            AliasConstKind::Anon { def_id: ref __field_def_id } => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_def_id, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for AliasConstKind<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) {
                (AliasConstKind::Projection { def_id: ref __field_def_id },
                    AliasConstKind::Projection {
                    def_id: ref __other_field_def_id }) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_def_id,
                            __other_field_def_id),
                (AliasConstKind::InherentSelf { def_id: ref __field_def_id },
                    AliasConstKind::InherentSelf {
                    def_id: ref __other_field_def_id }) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_def_id,
                            __other_field_def_id),
                (AliasConstKind::InherentImpl { def_id: ref __field_def_id },
                    AliasConstKind::InherentImpl {
                    def_id: ref __other_field_def_id }) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_def_id,
                            __other_field_def_id),
                (AliasConstKind::Free { def_id: ref __field_def_id },
                    AliasConstKind::Free { def_id: ref __other_field_def_id })
                    =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_def_id,
                            __other_field_def_id),
                (AliasConstKind::Anon { def_id: ref __field_def_id },
                    AliasConstKind::Anon { def_id: ref __other_field_def_id })
                    =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_def_id,
                            __other_field_def_id),
                _ => unsafe { ::core::hint::unreachable_unchecked() },
            }
        } else { false }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for AliasConstKind<I> where I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            AliasConstKind::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)
            }
            AliasConstKind::InherentSelf { def_id: ref __field_def_id } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "InherentSelf");
                ::core::fmt::DebugStruct::field(&mut __builder, "def_id",
                    __field_def_id);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
            AliasConstKind::InherentImpl { def_id: ref __field_def_id } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "InherentImpl");
                ::core::fmt::DebugStruct::field(&mut __builder, "def_id",
                    __field_def_id);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
            AliasConstKind::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)
            }
            AliasConstKind::Anon { def_id: ref __field_def_id } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "Anon");
                ::core::fmt::DebugStruct::field(&mut __builder, "def_id",
                    __field_def_id);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
101#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            AliasConstKind<I> where I: Interner,
            I::TraitAssocConstId: ::rustc_type_ir::TypeVisitable<I>,
            I::InherentAssocConstId: ::rustc_type_ir::TypeVisitable<I>,
            I::FreeConstAliasId: ::rustc_type_ir::TypeVisitable<I>,
            I::AnonConstId: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    AliasConstKind::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);
                                }
                            }
                        }
                    }
                    AliasConstKind::InherentSelf { 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);
                                }
                            }
                        }
                    }
                    AliasConstKind::InherentImpl { 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);
                                }
                            }
                        }
                    }
                    AliasConstKind::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);
                                }
                            }
                        }
                    }
                    AliasConstKind::Anon { 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, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for AliasConstKind<I>
            where
            I::TraitAssocConstId: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::InherentAssocConstId: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::InherentAssocConstId: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::FreeConstAliasId: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::AnonConstId: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    AliasConstKind::Projection { def_id: ref __binding_0 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    AliasConstKind::InherentSelf { def_id: ref __binding_0 } =>
                        {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    AliasConstKind::InherentImpl { def_id: ref __binding_0 } =>
                        {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    AliasConstKind::Free { def_id: ref __binding_0 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    AliasConstKind::Anon { def_id: ref __binding_0 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            AliasConstKind<I> where I: Interner,
            I::TraitAssocConstId: ::rustc_type_ir::TypeFoldable<I>,
            I::InherentAssocConstId: ::rustc_type_ir::TypeFoldable<I>,
            I::FreeConstAliasId: ::rustc_type_ir::TypeFoldable<I>,
            I::AnonConstId: ::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 {
                        AliasConstKind::Projection { def_id: __binding_0 } => {
                            AliasConstKind::Projection {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                            }
                        }
                        AliasConstKind::InherentSelf { def_id: __binding_0 } => {
                            AliasConstKind::InherentSelf {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                            }
                        }
                        AliasConstKind::InherentImpl { def_id: __binding_0 } => {
                            AliasConstKind::InherentImpl {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                            }
                        }
                        AliasConstKind::Free { def_id: __binding_0 } => {
                            AliasConstKind::Free {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                            }
                        }
                        AliasConstKind::Anon { def_id: __binding_0 } => {
                            AliasConstKind::Anon {
                                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 {
                    AliasConstKind::Projection { def_id: __binding_0 } => {
                        AliasConstKind::Projection {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                    AliasConstKind::InherentSelf { def_id: __binding_0 } => {
                        AliasConstKind::InherentSelf {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                    AliasConstKind::InherentImpl { def_id: __binding_0 } => {
                        AliasConstKind::InherentImpl {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                    AliasConstKind::Free { def_id: __binding_0 } => {
                        AliasConstKind::Free {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                    AliasConstKind::Anon { def_id: __binding_0 } => {
                        AliasConstKind::Anon {
                            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
            AliasConstKind<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = AliasConstKind<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    AliasConstKind::Projection { def_id: __binding_0 } => {
                        AliasConstKind::Projection {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                    AliasConstKind::InherentSelf { def_id: __binding_0 } => {
                        AliasConstKind::InherentSelf {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                    AliasConstKind::InherentImpl { def_id: __binding_0 } => {
                        AliasConstKind::InherentImpl {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                    AliasConstKind::Free { def_id: __binding_0 } => {
                        AliasConstKind::Free {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                    AliasConstKind::Anon { def_id: __binding_0 } => {
                        AliasConstKind::Anon {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
102#[cfg_attr(
103    feature = "nightly",
104    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for AliasConstKind<I> where
            I::TraitAssocConstId: ::rustc_serialize::Encodable<__E>,
            I::InherentAssocConstId: ::rustc_serialize::Encodable<__E>,
            I::FreeConstAliasId: ::rustc_serialize::Encodable<__E>,
            I::AnonConstId: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        AliasConstKind::Projection { def_id: ref __binding_0 } => {
                            0usize
                        }
                        AliasConstKind::InherentSelf { def_id: ref __binding_0 } =>
                            {
                            1usize
                        }
                        AliasConstKind::InherentImpl { def_id: ref __binding_0 } =>
                            {
                            2usize
                        }
                        AliasConstKind::Free { def_id: ref __binding_0 } => {
                            3usize
                        }
                        AliasConstKind::Anon { def_id: ref __binding_0 } => {
                            4usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    AliasConstKind::Projection { def_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    AliasConstKind::InherentSelf { def_id: ref __binding_0 } =>
                        {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    AliasConstKind::InherentImpl { def_id: ref __binding_0 } =>
                        {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    AliasConstKind::Free { def_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    AliasConstKind::Anon { 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 AliasConstKind<I> where
            I::TraitAssocConstId: ::rustc_serialize::Decodable<__D>,
            I::InherentAssocConstId: ::rustc_serialize::Decodable<__D>,
            I::FreeConstAliasId: ::rustc_serialize::Decodable<__D>,
            I::AnonConstId: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        AliasConstKind::Projection {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    1usize => {
                        AliasConstKind::InherentSelf {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    2usize => {
                        AliasConstKind::InherentImpl {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    3usize => {
                        AliasConstKind::Free {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    4usize => {
                        AliasConstKind::Anon {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `AliasConstKind`, expected 0..5, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            AliasConstKind<I> where
            I::TraitAssocConstId: ::rustc_data_structures::stable_hash::StableHash,
            I::InherentAssocConstId: ::rustc_data_structures::stable_hash::StableHash,
            I::FreeConstAliasId: ::rustc_data_structures::stable_hash::StableHash,
            I::AnonConstId: ::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 {
                    AliasConstKind::Projection { def_id: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    AliasConstKind::InherentSelf { def_id: ref __binding_0 } =>
                        {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    AliasConstKind::InherentImpl { def_id: ref __binding_0 } =>
                        {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    AliasConstKind::Free { def_id: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    AliasConstKind::Anon { def_id: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
105)]
106pub enum AliasConstKind<I: Interner> {
107    /// A projection `<Type as Trait>::AssocConst`
108    Projection { def_id: I::TraitAssocConstId },
109    /// An associated const in an inherent `impl`.
110    ///
111    /// The generic args are in "Self form", i.e.
112    /// there is a single `Self` type parameter, followed by any GAT args on the inherent const
113    /// itself.
114    ///
115    /// The "impl form" args can be obtained by generating fresh vars for each of the impl params,
116    /// instantiating the impl block's Self type with the fresh vars, equating the resulting type
117    /// with the `Self` generic argument, and using the result of what the fresh vars resolved to as
118    /// the "impl form" args. Doing so without considering the extra predicates generated by the
119    /// equate is a lossy operation, consider the following impl block:
120    ///
121    /// ```rust,ignore (illustrative)
122    /// impl<T> Struct<'static, T> {
123    ///     const ASSOC<A>: () = ();
124    /// }
125    /// ```
126    ///
127    /// If we have `Struct::<'a, u32>::Assoc<usize>`, the Self args form would be `[Struct<'a, u32>,
128    /// usize]`. The "impl form" args would be `[u32, usize]`, with an extra constraint generated
129    /// that `'a == 'static`. Disregarding this extra constraint would be wrong.
130    ///
131    /// Hence, when HIR lowering wants to construct an inherent alias, it must use the "Self form"
132    /// to let the trait solver do the equate and consider additional constraints.
133    ///
134    /// FIXME(inherent_associated_types): This ideally ought be a list of candidate DefIds that a
135    /// path could resolve to, then the trait solver does the above-written routine to figure out
136    /// which exact impl to use. `InherentSelf` could be conceptually be thought of as corresponding
137    /// to `Projection` where the def_id is a trait, and `InherentImpl` is `Projection` where the
138    /// def_id is an impl.
139    InherentSelf { def_id: I::InherentAssocConstId },
140    /// An associated const in an inherent `impl`. See [`Self::InherentSelf`] for a description on
141    /// the difference between `InherentSelf` and `InherentImpl`.
142    InherentImpl { def_id: I::InherentAssocConstId },
143    /// A free constant, outside an impl block.
144    Free { def_id: I::FreeConstAliasId },
145    /// Anonymous constant, e.g. the `1 + 2` in `[u8; 1 + 2]`.
146    Anon { def_id: I::AnonConstId },
147}
148
149pub enum AliasConstInherentArgsKind {
150    WithSelf,
151    Impl,
152}
153
154impl<I: Interner> AliasConstKind<I> {
155    pub fn new_from_def_id(
156        interner: I,
157        def_id: I::DefId,
158        inherent_args: AliasConstInherentArgsKind,
159    ) -> Self {
160        interner.alias_const_kind_from_def_id(def_id, inherent_args)
161    }
162
163    pub fn is_direct_const(self, interner: I) -> bool {
164        interner.is_direct_const(self)
165    }
166
167    pub fn def_span(self, interner: I) -> I::Span {
168        match self {
169            AliasConstKind::Projection { def_id } => interner.def_span(def_id.into()),
170            AliasConstKind::InherentSelf { def_id } => interner.def_span(def_id.into()),
171            AliasConstKind::InherentImpl { def_id } => interner.def_span(def_id.into()),
172            AliasConstKind::Free { def_id } => interner.def_span(def_id.into()),
173            AliasConstKind::Anon { def_id } => interner.def_span(def_id.into()),
174        }
175    }
176
177    pub fn opt_def_id(self) -> Option<I::DefId> {
178        match self {
179            AliasConstKind::Projection { def_id } => Some(def_id.into()),
180            AliasConstKind::InherentSelf { def_id } => Some(def_id.into()),
181            AliasConstKind::InherentImpl { def_id } => Some(def_id.into()),
182            AliasConstKind::Free { def_id } => Some(def_id.into()),
183            AliasConstKind::Anon { def_id } => Some(def_id.into()),
184        }
185    }
186}
187
188#[automatically_derived]
impl ::core::marker::Copy for ConstVid { }
impl ConstVid {
    #[doc = r" Maximum value the index can take, as a `u32`."]
    pub const MAX_AS_U32: u32 = 0xFFFF_FF00;
    #[doc = r" Maximum value the index can take."]
    pub const MAX: Self = Self::from_u32(0xFFFF_FF00);
    #[doc = r" Zero value of the index."]
    pub const ZERO: Self = Self::from_u32(0);
    #[doc = r" Creates a new index from a given `usize`."]
    #[doc = r""]
    #[doc = r" # Panics"]
    #[doc = r""]
    #[doc = r" Will panic if `value` exceeds `MAX`."]
    #[inline]
    pub const fn from_usize(value: usize) -> Self {
        if !(value <= (0xFFFF_FF00 as usize)) {
            ::core::panicking::panic("assertion failed: value <= (0xFFFF_FF00 as usize)")
        };
        unsafe { Self::from_u32_unchecked(value as u32) }
    }
    #[doc = r" Creates a new index from a given `u32`."]
    #[doc = r""]
    #[doc = r" # Panics"]
    #[doc = r""]
    #[doc = r" Will panic if `value` exceeds `MAX`."]
    #[inline]
    pub const fn from_u32(value: u32) -> Self {
        if !(value <= 0xFFFF_FF00) {
            ::core::panicking::panic("assertion failed: value <= 0xFFFF_FF00")
        };
        unsafe { Self::from_u32_unchecked(value) }
    }
    #[doc = r" Creates a new index from a given `u16`."]
    #[doc = r""]
    #[doc = r" # Panics"]
    #[doc = r""]
    #[doc = r" Will panic if `value` exceeds `MAX`."]
    #[inline]
    pub const fn from_u16(value: u16) -> Self {
        let value = value as u32;
        if !(value <= 0xFFFF_FF00) {
            ::core::panicking::panic("assertion failed: value <= 0xFFFF_FF00")
        };
        unsafe { Self::from_u32_unchecked(value) }
    }
    #[doc = r" Creates a new index from a given `u32`."]
    #[doc = r""]
    #[doc = r" # Safety"]
    #[doc = r""]
    #[doc =
    r" The provided value must be less than or equal to the maximum value for the newtype."]
    #[doc =
    r" Providing a value outside this range is undefined due to layout restrictions."]
    #[doc = r""]
    #[doc = r" Prefer using `from_u32`."]
    #[inline]
    pub const unsafe fn from_u32_unchecked(value: u32) -> Self {
        Self {
            private_use_as_methods_instead: unsafe {
                std::mem::transmute(value)
            },
        }
    }
    #[doc = r" Extracts the value of this index as a `usize`."]
    #[inline]
    pub const fn index(self) -> usize { self.as_usize() }
    #[doc = r" Extracts the value of this index as a `u32`."]
    #[inline]
    pub const fn as_u32(self) -> u32 {
        unsafe { std::mem::transmute(self.private_use_as_methods_instead) }
    }
    #[doc = r" Extracts the value of this index as a `usize`."]
    #[inline]
    pub const fn as_usize(self) -> usize { self.as_u32() as usize }
}
impl std::ops::Add<usize> for ConstVid {
    type Output = Self;
    #[inline]
    fn add(self, other: usize) -> Self {
        Self::from_usize(self.index() + other)
    }
}
impl std::ops::AddAssign<usize> for ConstVid {
    #[inline]
    fn add_assign(&mut self, other: usize) { *self = *self + other; }
}
impl rustc_index::Idx for ConstVid {
    #[inline]
    fn new(value: usize) -> Self { Self::from_usize(value) }
    #[inline]
    fn index(self) -> usize { self.as_usize() }
}
impl ::std::iter::Step for ConstVid {
    #[inline]
    fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
        <usize as
                ::std::iter::Step>::steps_between(&Self::index(*start),
            &Self::index(*end))
    }
    #[inline]
    fn forward_checked(start: Self, u: usize) -> Option<Self> {
        Self::index(start).checked_add(u).map(Self::from_usize)
    }
    #[inline]
    fn backward_checked(start: Self, u: usize) -> Option<Self> {
        Self::index(start).checked_sub(u).map(Self::from_usize)
    }
    #[inline]
    fn forward_overflowing(start: Self, u: usize) -> (Self, bool) {
        let (s, o) = Self::index(start).overflowing_add(u);
        (Self::from_usize(s), o)
    }
    #[inline]
    fn backward_overflowing(start: Self, u: usize) -> (Self, bool) {
        let (s, o) = Self::index(start).overflowing_sub(u);
        (Self::from_usize(s), o)
    }
}
impl ::std::cmp::Ord for ConstVid {
    #[inline]
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.as_u32().cmp(&other.as_u32())
    }
}
impl ::std::cmp::PartialOrd for ConstVid {
    #[inline]
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
impl From<ConstVid> for u32 {
    #[inline]
    fn from(v: ConstVid) -> u32 { v.as_u32() }
}
impl From<ConstVid> for usize {
    #[inline]
    fn from(v: ConstVid) -> usize { v.as_usize() }
}
impl From<usize> for ConstVid {
    #[inline]
    fn from(value: usize) -> Self { Self::from_usize(value) }
}
impl From<u32> for ConstVid {
    #[inline]
    fn from(value: u32) -> Self { Self::from_u32(value) }
}
impl ::std::cmp::Eq for ConstVid {}
impl ::std::cmp::PartialEq for ConstVid {
    fn eq(&self, other: &Self) -> bool { self.as_u32().eq(&other.as_u32()) }
}
impl ::std::marker::StructuralPartialEq for ConstVid { }
impl ::std::hash::Hash for ConstVid {
    fn hash<H: ::std::hash::Hasher>(&self, state: &mut H) {
        self.as_u32().hash(state)
    }
}
impl<D: ::rustc_serialize::Decoder> ::rustc_serialize::Decodable<D> for
    ConstVid {
    fn decode(d: &mut D) -> Self { Self::from_u32(d.read_u32()) }
}
impl<E: ::rustc_serialize::Encoder> ::rustc_serialize::Encodable<E> for
    ConstVid {
    fn encode(&self, e: &mut E) { e.emit_u32(self.as_u32()); }
}
impl ::std::fmt::Debug for ConstVid {
    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        fmt.write_fmt(format_args!("?{0}c", self.as_u32()))
    }
}rustc_index::newtype_index! {
189    /// A **`const`** **v**ariable **ID**.
190    #[encodable]
191    #[orderable]
192    #[debug_format = "?{}c"]
193    #[gate_rustc_only]
194    pub struct ConstVid {}
195}
196
197/// An inference variable for a const, for use in const generics.
198#[derive(#[automatically_derived]
impl ::core::marker::Copy for InferConst { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for InferConst { }
#[automatically_derived]
impl ::core::clone::Clone for InferConst {
    #[inline]
    fn clone(&self) -> InferConst {
        let _: ::core::clone::AssertParamIsClone<ConstVid>;
        let _: ::core::clone::AssertParamIsClone<u32>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::Eq for InferConst {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<ConstVid>;
        let _: ::core::cmp::AssertParamIsEq<u32>;
    }
}Eq, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for InferConst { }
#[automatically_derived]
impl ::core::cmp::PartialEq for InferConst {
    #[inline]
    fn eq(&self, other: &InferConst) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (InferConst::Var(__self_0), InferConst::Var(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (InferConst::Fresh(__self_0), InferConst::Fresh(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::PartialOrd for InferConst {
    #[inline]
    fn partial_cmp(&self, other: &InferConst)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for InferConst {
    #[inline]
    fn cmp(&self, other: &InferConst) -> ::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) {
                    (InferConst::Var(__self_0), InferConst::Var(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    (InferConst::Fresh(__self_0), InferConst::Fresh(__arg1_0))
                        => ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    _ => unsafe { ::core::intrinsics::unreachable() }
                },
            cmp => cmp,
        }
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for InferConst {
    #[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 {
            InferConst::Var(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            InferConst::Fresh(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
        }
    }
}Hash)]
199#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<__E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for InferConst {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        InferConst::Var(ref __binding_0) => { 0usize }
                        InferConst::Fresh(ref __binding_0) => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    InferConst::Var(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    InferConst::Fresh(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<__D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for InferConst {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        InferConst::Var(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        InferConst::Fresh(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `InferConst`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext))]
200pub enum InferConst {
201    /// Infer the value of the const.
202    Var(ConstVid),
203    /// A fresh const variable. See `TypeFreshener` for more details.
204    Fresh(u32),
205}
206
207impl fmt::Debug for InferConst {
208    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
209        match self {
210            InferConst::Var(var) => f.write_fmt(format_args!("{0:?}", var))write!(f, "{var:?}"),
211            InferConst::Fresh(var) => f.write_fmt(format_args!("Fresh({0:?})", var))write!(f, "Fresh({var:?})"),
212        }
213    }
214}
215
216#[cfg(feature = "nightly")]
217impl StableHash for InferConst {
218    fn stable_hash<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
219        match self {
220            InferConst::Var(_) => {
221                {
    ::core::panicking::panic_fmt(format_args!("const variables should not be hashed: {0:?}",
            self));
}panic!("const variables should not be hashed: {self:?}")
222            }
223            InferConst::Fresh(i) => i.stable_hash(hcx, hasher),
224        }
225    }
226}
227
228/// This datastructure is used to represent the value of constants used in the type system.
229///
230/// We explicitly choose a different datastructure from the way values are processed within
231/// CTFE, as in the type system equal values (according to their `PartialEq`) must also have
232/// equal representation (`==` on the rustc data structure, e.g. `ValTree`) and vice versa.
233/// Since CTFE uses `AllocId` to represent pointers, it often happens that two different
234/// `AllocId`s point to equal values. So we may end up with different representations for
235/// two constants whose value is `&42`. Furthermore any kind of struct that has padding will
236/// have arbitrary values within that padding, even if the values of the struct are the same.
237///
238/// `ValTree` does not have this problem with representation, as it only contains integers or
239/// lists of (nested) `ty::Const`s (which may indirectly contain more `ValTree`s).
240#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ValTreeKind<I> where I: Interner {
    #[inline]
    fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for ValTreeKind<I> where I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for ValTreeKind<I> where I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            ValTreeKind::Leaf(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Leaf");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            ValTreeKind::Branch(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Branch");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ValTreeKind<I> where I: Interner {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            ValTreeKind::Leaf(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            ValTreeKind::Branch(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
        }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner> DeriveWhereAssertEq for ValTreeKind<I> where
            I: Interner {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<I::ScalarInt>;
                let _: __AssertEq<I::Consts>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner> ::core::cmp::Eq for ValTreeKind<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ValTreeKind<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) {
                (ValTreeKind::Leaf(ref __field_0),
                    ValTreeKind::Leaf(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (ValTreeKind::Branch(ref __field_0),
                    ValTreeKind::Branch(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                _ => unsafe { ::core::hint::unreachable_unchecked() },
            }
        } else { false }
    }
}#[derive_where(Clone, Copy, Debug, Hash, Eq, PartialEq; I: Interner)]
241#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for ValTreeKind<I>
            where I: Interner,
            I::ScalarInt: ::rustc_type_ir::TypeVisitable<I>,
            I::Consts: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    ValTreeKind::Leaf(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);
                                }
                            }
                        }
                    }
                    ValTreeKind::Branch(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for ValTreeKind<I>
            where I: Interner, I::ScalarInt: ::rustc_type_ir::TypeFoldable<I>,
            I::Consts: ::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 {
                        ValTreeKind::Leaf(__binding_0) => {
                            ValTreeKind::Leaf(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                        ValTreeKind::Branch(__binding_0) => {
                            ValTreeKind::Branch(::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 {
                    ValTreeKind::Leaf(__binding_0) => {
                        ValTreeKind::Leaf(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                    ValTreeKind::Branch(__binding_0) => {
                        ValTreeKind::Branch(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic, const _: () =
    {
        unsafe impl<I: Interner, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for ValTreeKind<I>
            where I::ScalarInt: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::Consts: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    ValTreeKind::Leaf(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    ValTreeKind::Branch(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable)]
242#[cfg_attr(
243    feature = "nightly",
244    derive(const _: () =
    {
        impl<I: Interner, __D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for ValTreeKind<I> where
            I::ScalarInt: ::rustc_serialize::Decodable<__D>,
            I::Consts: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        ValTreeKind::Leaf(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        ValTreeKind::Branch(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ValTreeKind`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for ValTreeKind<I> where
            I::ScalarInt: ::rustc_serialize::Encodable<__E>,
            I::Consts: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        ValTreeKind::Leaf(ref __binding_0) => { 0usize }
                        ValTreeKind::Branch(ref __binding_0) => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    ValTreeKind::Leaf(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    ValTreeKind::Branch(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            ValTreeKind<I> where
            I::ScalarInt: ::rustc_data_structures::stable_hash::StableHash,
            I::Consts: ::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 {
                    ValTreeKind::Leaf(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    ValTreeKind::Branch(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
245)]
246pub enum ValTreeKind<I: Interner> {
247    /// integers, `bool`, `char` are represented as scalars.
248    /// See the `ScalarInt` documentation for how `ScalarInt` guarantees that equal values
249    /// of these types have the same representation.
250    Leaf(I::ScalarInt),
251
252    /// The fields of any kind of aggregate. Structs, tuples and arrays are represented by
253    /// listing their fields' values in order.
254    ///
255    /// Enums are represented by storing their variant index as a u32 field, followed by all
256    /// the fields of the variant.
257    ///
258    /// ZST types are represented as an empty slice.
259    Branch(I::Consts),
260}
261
262impl<I: Interner> ValTreeKind<I> {
263    /// Converts to a `ValTreeKind::Leaf` value, `panic`'ing
264    /// if this valtree is some other kind.
265    #[inline]
266    pub fn to_leaf(&self) -> I::ScalarInt {
267        match self {
268            ValTreeKind::Leaf(s) => *s,
269            ValTreeKind::Branch(..) => {
    ::core::panicking::panic_fmt(format_args!("expected leaf, got {0:?}",
            self));
}panic!("expected leaf, got {:?}", self),
270        }
271    }
272
273    /// Converts to a `ValTreeKind::Branch` value, `panic`'ing
274    /// if this valtree is some other kind.
275    #[inline]
276    pub fn to_branch(&self) -> I::Consts {
277        match self {
278            ValTreeKind::Branch(branch) => *branch,
279            ValTreeKind::Leaf(..) => {
    ::core::panicking::panic_fmt(format_args!("expected branch, got {0:?}",
            self));
}panic!("expected branch, got {:?}", self),
280        }
281    }
282
283    /// Attempts to convert to a `ValTreeKind::Leaf` value.
284    pub fn try_to_leaf(&self) -> Option<I::ScalarInt> {
285        match self {
286            ValTreeKind::Leaf(s) => Some(*s),
287            ValTreeKind::Branch(_) => None,
288        }
289    }
290
291    /// Attempts to convert to a `ValTreeKind::Branch` value.
292    pub fn try_to_branch(&self) -> Option<I::Consts> {
293        match self {
294            ValTreeKind::Branch(branch) => Some(*branch),
295            ValTreeKind::Leaf(_) => None,
296        }
297    }
298}
299
300#[derive(#[automatically_derived]
impl ::core::marker::Copy for AnonConstKind { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for AnonConstKind { }
#[automatically_derived]
impl ::core::clone::Clone for AnonConstKind {
    #[inline]
    fn clone(&self) -> AnonConstKind { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for AnonConstKind { }
#[automatically_derived]
impl ::core::cmp::PartialEq for AnonConstKind {
    #[inline]
    fn eq(&self, other: &AnonConstKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for AnonConstKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for AnonConstKind {
    #[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::fmt::Debug for AnonConstKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                AnonConstKind::GCE => "GCE",
                AnonConstKind::MCG => "MCG",
                AnonConstKind::RepeatExprCount => "RepeatExprCount",
                AnonConstKind::NonTypeSystemAnon => "NonTypeSystemAnon",
                AnonConstKind::NonTypeSystemInline => "NonTypeSystemInline",
            })
    }
}Debug)]
301#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<__E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for AnonConstKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        AnonConstKind::GCE => { 0usize }
                        AnonConstKind::MCG => { 1usize }
                        AnonConstKind::RepeatExprCount => { 2usize }
                        AnonConstKind::NonTypeSystemAnon => { 3usize }
                        AnonConstKind::NonTypeSystemInline => { 4usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };Encodable_NoContext, const _: () =
    {
        impl<__D: ::rustc_serialize::Decoder>
            ::rustc_serialize::Decodable<__D> for AnonConstKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { AnonConstKind::GCE }
                    1usize => { AnonConstKind::MCG }
                    2usize => { AnonConstKind::RepeatExprCount }
                    3usize => { AnonConstKind::NonTypeSystemAnon }
                    4usize => { AnonConstKind::NonTypeSystemInline }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `AnonConstKind`, expected 0..5, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            AnonConstKind {
            #[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 {
                    AnonConstKind::GCE => {}
                    AnonConstKind::MCG => {}
                    AnonConstKind::RepeatExprCount => {}
                    AnonConstKind::NonTypeSystemAnon => {}
                    AnonConstKind::NonTypeSystemInline => {}
                }
            }
        }
    };StableHash))]
302pub enum AnonConstKind {
303    /// `feature(generic_const_exprs)` anon consts are allowed to use arbitrary generic parameters in scope
304    GCE,
305    /// stable `min_const_generics` anon consts are not allowed to use any generic parameters
306    ///
307    /// under `feature(min_generic_const_args)`, these may be inline consts as well, and should be
308    /// treated the same as anon consts.
309    MCG,
310    /// anon consts used as the length of a repeat expr are syntactically allowed to use generic parameters
311    /// but must not depend on the actual instantiation. See #76200 for more information
312    RepeatExprCount,
313    /// anon consts outside of the type system, e.g. enum discriminants
314    NonTypeSystemAnon,
315    /// inline consts outside of the type system
316    NonTypeSystemInline,
317}