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, BoundVarIndexKind, Interner, UnevaluatedConst};
13
14/// Represents a constant in Rust.
15#[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::Unevaluated(ref __field_0),
                    ConstKind::Unevaluated(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (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(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::UnevaluatedConst<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::Unevaluated(ref __binding_0) => { 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::Unevaluated(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __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::UnevaluatedConst<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::Unevaluated(::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::UnevaluatedConst<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::Unevaluated(ref __binding_0) => {
                        { __binding_0.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    Unevaluated(ty::UnevaluatedConst<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    /// Unevaluated non-const-item, 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            Unevaluated(uv) => f.write_fmt(format_args!("{0:?}", uv))write!(f, "{uv:?}"),
63            Value(val) => f.write_fmt(format_args!("{0:?}", val))write!(f, "{val:?}"),
64            Error(_) => f.write_fmt(format_args!("{{const error}}"))write!(f, "{{const error}}"),
65            Expr(expr) => f.write_fmt(format_args!("{0:?}", expr))write!(f, "{expr:?}"),
66        }
67    }
68}
69
70impl<I: Interner> UnevaluatedConst<I> {
71    #[inline]
72    pub fn new(
73        interner: I,
74        kind: UnevaluatedConstKind<I>,
75        args: I::GenericArgs,
76    ) -> UnevaluatedConst<I> {
77        if truecfg!(debug_assertions) {
78            let def_id = match kind {
79                ty::UnevaluatedConstKind::Projection { def_id } => def_id.into(),
80                ty::UnevaluatedConstKind::Inherent { def_id } => def_id.into(),
81                ty::UnevaluatedConstKind::Free { def_id } => def_id.into(),
82                ty::UnevaluatedConstKind::Anon { def_id } => def_id.into(),
83            };
84            interner.debug_assert_args_compatible(def_id, args);
85        }
86        UnevaluatedConst { kind, args, _use_alias_new_instead: () }
87    }
88
89    pub fn type_of(self, interner: I) -> ty::Unnormalized<I, I::Ty> {
90        let def_id = match self.kind {
91            ty::UnevaluatedConstKind::Projection { def_id } => def_id.into(),
92            ty::UnevaluatedConstKind::Inherent { def_id } => def_id.into(),
93            ty::UnevaluatedConstKind::Free { def_id } => def_id.into(),
94            ty::UnevaluatedConstKind::Anon { def_id } => def_id.into(),
95        };
96        interner.type_of(def_id).instantiate(interner, self.args)
97    }
98}
99
100/// UnevaluatedConstKind is extremely similar to AliasTyKind, and likely should be reasoned about
101/// and handled in very similar ways. The documentation for AliasTyKind/etc. may be helpful when
102/// learning about UnevaluatedConstKind.
103#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for UnevaluatedConstKind<I> where
    I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            UnevaluatedConstKind::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)
            }
            UnevaluatedConstKind::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)
            }
            UnevaluatedConstKind::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)
            }
            UnevaluatedConstKind::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)]
104#[derive(const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
            UnevaluatedConstKind<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::UnevaluatedConstId: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    UnevaluatedConstKind::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);
                                }
                            }
                        }
                    }
                    UnevaluatedConstKind::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);
                                }
                            }
                        }
                    }
                    UnevaluatedConstKind::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);
                                }
                            }
                        }
                    }
                    UnevaluatedConstKind::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, GenericTypeVisitable, const _: () =
    {
        impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
            UnevaluatedConstKind<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::UnevaluatedConstId: ::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 {
                        UnevaluatedConstKind::Projection { def_id: __binding_0 } =>
                            {
                            UnevaluatedConstKind::Projection {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                            }
                        }
                        UnevaluatedConstKind::Inherent { def_id: __binding_0 } => {
                            UnevaluatedConstKind::Inherent {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                            }
                        }
                        UnevaluatedConstKind::Free { def_id: __binding_0 } => {
                            UnevaluatedConstKind::Free {
                                def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                            }
                        }
                        UnevaluatedConstKind::Anon { def_id: __binding_0 } => {
                            UnevaluatedConstKind::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 {
                    UnevaluatedConstKind::Projection { def_id: __binding_0 } =>
                        {
                        UnevaluatedConstKind::Projection {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                    UnevaluatedConstKind::Inherent { def_id: __binding_0 } => {
                        UnevaluatedConstKind::Inherent {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                    UnevaluatedConstKind::Free { def_id: __binding_0 } => {
                        UnevaluatedConstKind::Free {
                            def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                    UnevaluatedConstKind::Anon { def_id: __binding_0 } => {
                        UnevaluatedConstKind::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
            UnevaluatedConstKind<I> where J: Interner,
            I: ::rustc_type_ir::LiftInto<J> {
            type Lifted = UnevaluatedConstKind<J>;
            fn lift_to_interner(self, interner: J) -> Self::Lifted {
                match self {
                    UnevaluatedConstKind::Projection { def_id: __binding_0 } =>
                        {
                        UnevaluatedConstKind::Projection {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                    UnevaluatedConstKind::Inherent { def_id: __binding_0 } => {
                        UnevaluatedConstKind::Inherent {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                    UnevaluatedConstKind::Free { def_id: __binding_0 } => {
                        UnevaluatedConstKind::Free {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                    UnevaluatedConstKind::Anon { def_id: __binding_0 } => {
                        UnevaluatedConstKind::Anon {
                            def_id: __binding_0.lift_to_interner(interner),
                        }
                    }
                }
            }
        }
    };Lift_Generic)]
105#[cfg_attr(
106    feature = "nightly",
107    derive(const _: () =
    {
        impl<I: Interner, __E: ::rustc_serialize::Encoder>
            ::rustc_serialize::Encodable<__E> for UnevaluatedConstKind<I>
            where I::TraitAssocConstId: ::rustc_serialize::Encodable<__E>,
            I::InherentAssocConstId: ::rustc_serialize::Encodable<__E>,
            I::FreeConstAliasId: ::rustc_serialize::Encodable<__E>,
            I::UnevaluatedConstId: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        UnevaluatedConstKind::Projection { def_id: ref __binding_0 }
                            => {
                            0usize
                        }
                        UnevaluatedConstKind::Inherent { def_id: ref __binding_0 }
                            => {
                            1usize
                        }
                        UnevaluatedConstKind::Free { def_id: ref __binding_0 } => {
                            2usize
                        }
                        UnevaluatedConstKind::Anon { def_id: ref __binding_0 } => {
                            3usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    UnevaluatedConstKind::Projection { def_id: ref __binding_0 }
                        => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    UnevaluatedConstKind::Inherent { def_id: ref __binding_0 }
                        => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    UnevaluatedConstKind::Free { def_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    UnevaluatedConstKind::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 UnevaluatedConstKind<I>
            where I::TraitAssocConstId: ::rustc_serialize::Decodable<__D>,
            I::InherentAssocConstId: ::rustc_serialize::Decodable<__D>,
            I::FreeConstAliasId: ::rustc_serialize::Decodable<__D>,
            I::UnevaluatedConstId: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        UnevaluatedConstKind::Projection {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    1usize => {
                        UnevaluatedConstKind::Inherent {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    2usize => {
                        UnevaluatedConstKind::Free {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    3usize => {
                        UnevaluatedConstKind::Anon {
                            def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `UnevaluatedConstKind`, expected 0..4, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable_NoContext, const _: () =
    {
        impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
            UnevaluatedConstKind<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::UnevaluatedConstId: ::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 {
                    UnevaluatedConstKind::Projection { def_id: ref __binding_0 }
                        => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    UnevaluatedConstKind::Inherent { def_id: ref __binding_0 }
                        => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    UnevaluatedConstKind::Free { def_id: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    UnevaluatedConstKind::Anon { def_id: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext)
108)]
109pub enum UnevaluatedConstKind<I: Interner> {
110    /// A projection `<Type as Trait>::AssocConst`
111    Projection { def_id: I::TraitAssocConstId },
112    /// An associated constant in an inherent `impl`
113    Inherent { def_id: I::InherentAssocConstId },
114    /// A free constant, outside an impl block.
115    Free { def_id: I::FreeConstAliasId },
116    /// Anonymous constant, e.g. the `1 + 2` in `[u8; 1 + 2]`.
117    Anon { def_id: I::UnevaluatedConstId },
118}
119
120impl<I: Interner> UnevaluatedConstKind<I> {
121    pub fn new_from_def_id(interner: I, def_id: I::DefId) -> Self {
122        interner.unevaluated_const_kind_from_def_id(def_id)
123    }
124
125    pub fn is_type_const(self, interner: I) -> bool {
126        match self {
127            UnevaluatedConstKind::Projection { def_id } => interner.is_type_const(def_id.into()),
128            UnevaluatedConstKind::Inherent { def_id } => interner.is_type_const(def_id.into()),
129            UnevaluatedConstKind::Free { def_id } => interner.is_type_const(def_id.into()),
130            UnevaluatedConstKind::Anon { def_id } => interner.is_type_const(def_id.into()),
131        }
132    }
133
134    pub fn def_span(self, interner: I) -> I::Span {
135        match self {
136            UnevaluatedConstKind::Projection { def_id } => interner.def_span(def_id.into()),
137            UnevaluatedConstKind::Inherent { def_id } => interner.def_span(def_id.into()),
138            UnevaluatedConstKind::Free { def_id } => interner.def_span(def_id.into()),
139            UnevaluatedConstKind::Anon { def_id } => interner.def_span(def_id.into()),
140        }
141    }
142
143    pub fn opt_def_id(self) -> Option<I::DefId> {
144        match self {
145            UnevaluatedConstKind::Projection { def_id } => Some(def_id.into()),
146            UnevaluatedConstKind::Inherent { def_id } => Some(def_id.into()),
147            UnevaluatedConstKind::Free { def_id } => Some(def_id.into()),
148            UnevaluatedConstKind::Anon { def_id } => Some(def_id.into()),
149        }
150    }
151}
152
153impl ::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! {
154    /// A **`const`** **v**ariable **ID**.
155    #[encodable]
156    #[orderable]
157    #[debug_format = "?{}c"]
158    #[gate_rustc_only]
159    pub struct ConstVid {}
160}
161
162/// An inference variable for a const, for use in const generics.
163#[derive(#[automatically_derived]
impl ::core::marker::Copy for InferConst { }Copy, #[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::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)]
164#[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))]
165pub enum InferConst {
166    /// Infer the value of the const.
167    Var(ConstVid),
168    /// A fresh const variable. See `TypeFreshener` for more details.
169    Fresh(u32),
170}
171
172impl fmt::Debug for InferConst {
173    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
174        match self {
175            InferConst::Var(var) => f.write_fmt(format_args!("{0:?}", var))write!(f, "{var:?}"),
176            InferConst::Fresh(var) => f.write_fmt(format_args!("Fresh({0:?})", var))write!(f, "Fresh({var:?})"),
177        }
178    }
179}
180
181#[cfg(feature = "nightly")]
182impl StableHash for InferConst {
183    fn stable_hash<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
184        match self {
185            InferConst::Var(_) => {
186                {
    ::core::panicking::panic_fmt(format_args!("const variables should not be hashed: {0:?}",
            self));
}panic!("const variables should not be hashed: {self:?}")
187            }
188            InferConst::Fresh(i) => i.stable_hash(hcx, hasher),
189        }
190    }
191}
192
193/// This datastructure is used to represent the value of constants used in the type system.
194///
195/// We explicitly choose a different datastructure from the way values are processed within
196/// CTFE, as in the type system equal values (according to their `PartialEq`) must also have
197/// equal representation (`==` on the rustc data structure, e.g. `ValTree`) and vice versa.
198/// Since CTFE uses `AllocId` to represent pointers, it often happens that two different
199/// `AllocId`s point to equal values. So we may end up with different representations for
200/// two constants whose value is `&42`. Furthermore any kind of struct that has padding will
201/// have arbitrary values within that padding, even if the values of the struct are the same.
202///
203/// `ValTree` does not have this problem with representation, as it only contains integers or
204/// lists of (nested) `ty::Const`s (which may indirectly contain more `ValTree`s).
205#[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)]
206#[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, GenericTypeVisitable)]
207#[cfg_attr(
208    feature = "nightly",
209    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)
210)]
211pub enum ValTreeKind<I: Interner> {
212    /// integers, `bool`, `char` are represented as scalars.
213    /// See the `ScalarInt` documentation for how `ScalarInt` guarantees that equal values
214    /// of these types have the same representation.
215    Leaf(I::ScalarInt),
216
217    /// The fields of any kind of aggregate. Structs, tuples and arrays are represented by
218    /// listing their fields' values in order.
219    ///
220    /// Enums are represented by storing their variant index as a u32 field, followed by all
221    /// the fields of the variant.
222    ///
223    /// ZST types are represented as an empty slice.
224    Branch(I::Consts),
225}
226
227impl<I: Interner> ValTreeKind<I> {
228    /// Converts to a `ValTreeKind::Leaf` value, `panic`'ing
229    /// if this valtree is some other kind.
230    #[inline]
231    pub fn to_leaf(&self) -> I::ScalarInt {
232        match self {
233            ValTreeKind::Leaf(s) => *s,
234            ValTreeKind::Branch(..) => {
    ::core::panicking::panic_fmt(format_args!("expected leaf, got {0:?}",
            self));
}panic!("expected leaf, got {:?}", self),
235        }
236    }
237
238    /// Converts to a `ValTreeKind::Branch` value, `panic`'ing
239    /// if this valtree is some other kind.
240    #[inline]
241    pub fn to_branch(&self) -> I::Consts {
242        match self {
243            ValTreeKind::Branch(branch) => *branch,
244            ValTreeKind::Leaf(..) => {
    ::core::panicking::panic_fmt(format_args!("expected branch, got {0:?}",
            self));
}panic!("expected branch, got {:?}", self),
245        }
246    }
247
248    /// Attempts to convert to a `ValTreeKind::Leaf` value.
249    pub fn try_to_leaf(&self) -> Option<I::ScalarInt> {
250        match self {
251            ValTreeKind::Leaf(s) => Some(*s),
252            ValTreeKind::Branch(_) => None,
253        }
254    }
255
256    /// Attempts to convert to a `ValTreeKind::Branch` value.
257    pub fn try_to_branch(&self) -> Option<I::Consts> {
258        match self {
259            ValTreeKind::Branch(branch) => Some(*branch),
260            ValTreeKind::Leaf(_) => None,
261        }
262    }
263}
264
265#[derive(#[automatically_derived]
impl ::core::marker::Copy for AnonConstKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AnonConstKind {
    #[inline]
    fn clone(&self) -> AnonConstKind { *self }
}Clone, #[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::NonTypeSystem => "NonTypeSystem",
            })
    }
}Debug)]
266#[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::NonTypeSystem => { 3usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    AnonConstKind::GCE => {}
                    AnonConstKind::MCG => {}
                    AnonConstKind::RepeatExprCount => {}
                    AnonConstKind::NonTypeSystem => {}
                }
            }
        }
    };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::NonTypeSystem }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `AnonConstKind`, expected 0..4, 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::NonTypeSystem => {}
                }
            }
        }
    };StableHash))]
267pub enum AnonConstKind {
268    /// `feature(generic_const_exprs)` anon consts are allowed to use arbitrary generic parameters in scope
269    GCE,
270    /// stable `min_const_generics` anon consts are not allowed to use any generic parameters
271    MCG,
272    /// anon consts used as the length of a repeat expr are syntactically allowed to use generic parameters
273    /// but must not depend on the actual instantiation. See #76200 for more information
274    RepeatExprCount,
275    /// anon consts outside of the type system, e.g. enum discriminants
276    NonTypeSystem,
277}