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#[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 Param(I::ParamConst),
24
25 Infer(InferConst),
27
28 Bound(BoundVarIndexKind, ty::BoundConst<I>),
30
31 Placeholder(ty::PlaceholderConst<I>),
33
34 Alias(ty::IsRigid, ty::AliasConst<I>),
38
39 Value(I::ValueConst),
41
42 Error(I::ErrorGuaranteed),
45
46 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#[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 Projection { def_id: I::TraitAssocConstId },
109 InherentSelf { def_id: I::InherentAssocConstId },
140 InherentImpl { def_id: I::InherentAssocConstId },
143 Free { def_id: I::FreeConstAliasId },
145 Anon { def_id: I::AnonConstId },
147}
148
149impl<I: Interner> AliasConstKind<I> {
150 pub fn is_direct_const(self, interner: I) -> bool {
151 interner.is_direct_const(self)
152 }
153
154 pub fn def_span(self, interner: I) -> I::Span {
155 match self {
156 AliasConstKind::Projection { def_id } => interner.def_span(def_id.into()),
157 AliasConstKind::InherentSelf { def_id } => interner.def_span(def_id.into()),
158 AliasConstKind::InherentImpl { def_id } => interner.def_span(def_id.into()),
159 AliasConstKind::Free { def_id } => interner.def_span(def_id.into()),
160 AliasConstKind::Anon { def_id } => interner.def_span(def_id.into()),
161 }
162 }
163}
164
165#[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! {
166 #[encodable]
168 #[orderable]
169 #[debug_format = "?{}c"]
170 #[gate_rustc_only]
171 pub struct ConstVid {}
172}
173
174#[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) -> Self {
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: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Var(__self_0), Self::Var(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Fresh(__self_0), Self::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: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for InferConst {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
match (self, other) {
(Self::Var(__self_0), Self::Var(__arg1_0)) =>
::core::cmp::Ord::cmp(__self_0, __arg1_0),
(Self::Fresh(__self_0), Self::Fresh(__arg1_0)) =>
::core::cmp::Ord::cmp(__self_0, __arg1_0),
_ =>
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other)),
}
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for InferConst {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::Var(__self_0) => ::core::hash::Hash::hash(__self_0, state),
Self::Fresh(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
}
}
}Hash)]
176#[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))]
177pub enum InferConst {
178 Var(ConstVid),
180 Fresh(u32),
182}
183
184impl fmt::Debug for InferConst {
185 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
186 match self {
187 InferConst::Var(var) => f.write_fmt(format_args!("{0:?}", var))write!(f, "{var:?}"),
188 InferConst::Fresh(var) => f.write_fmt(format_args!("Fresh({0:?})", var))write!(f, "Fresh({var:?})"),
189 }
190 }
191}
192
193#[cfg(feature = "nightly")]
194impl StableHash for InferConst {
195 fn stable_hash<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
196 match self {
197 InferConst::Var(_) => {
198 {
::core::panicking::panic_fmt(format_args!("const variables should not be hashed: {0:?}",
self));
}panic!("const variables should not be hashed: {self:?}")
199 }
200 InferConst::Fresh(i) => i.stable_hash(hcx, hasher),
201 }
202 }
203}
204
205#[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)]
218#[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)]
219#[cfg_attr(
220 feature = "nightly",
221 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)
222)]
223pub enum ValTreeKind<I: Interner> {
224 Leaf(I::ScalarInt),
228
229 Branch(I::Consts),
237}
238
239impl<I: Interner> ValTreeKind<I> {
240 #[inline]
243 pub fn to_leaf(&self) -> I::ScalarInt {
244 match self {
245 ValTreeKind::Leaf(s) => *s,
246 ValTreeKind::Branch(..) => {
::core::panicking::panic_fmt(format_args!("expected leaf, got {0:?}",
self));
}panic!("expected leaf, got {:?}", self),
247 }
248 }
249
250 #[inline]
253 pub fn to_branch(&self) -> I::Consts {
254 match self {
255 ValTreeKind::Branch(branch) => *branch,
256 ValTreeKind::Leaf(..) => {
::core::panicking::panic_fmt(format_args!("expected branch, got {0:?}",
self));
}panic!("expected branch, got {:?}", self),
257 }
258 }
259
260 pub fn try_to_leaf(&self) -> Option<I::ScalarInt> {
262 match self {
263 ValTreeKind::Leaf(s) => Some(*s),
264 ValTreeKind::Branch(_) => None,
265 }
266 }
267
268 pub fn try_to_branch(&self) -> Option<I::Consts> {
270 match self {
271 ValTreeKind::Branch(branch) => Some(*branch),
272 ValTreeKind::Leaf(_) => None,
273 }
274 }
275}
276
277#[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) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for AnonConstKind { }
#[automatically_derived]
impl ::core::cmp::PartialEq for AnonConstKind {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for AnonConstKind { }Eq, #[automatically_derived]
impl ::core::hash::Hash for AnonConstKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for 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)]
278#[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))]
279pub enum AnonConstKind {
280 GCE,
282 MCG,
287 RepeatExprCount,
290 NonTypeSystemAnon,
292 NonTypeSystemInline,
294}