rustc_type_ir/
generic_arg.rs1use derive_where::derive_where;
2#[cfg(feature = "nightly")]
3use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
4use rustc_type_ir_macros::GenericTypeVisitable;
5
6use crate::Interner;
7
8#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for GenericArgKind<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
GenericArgKind::Lifetime(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "Lifetime");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
GenericArgKind::Type(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "Type");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
GenericArgKind::Const(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "Const");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, PartialEq, Debug; I: Interner)]
9#[derive(GenericTypeVisitable)]
10#[cfg_attr(
11 feature = "nightly",
12 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for GenericArgKind<I> where
I::Region: ::rustc_serialize::Decodable<__D>,
I::Ty: ::rustc_serialize::Decodable<__D>,
I::Const: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
GenericArgKind::Lifetime(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
GenericArgKind::Type(::rustc_serialize::Decodable::decode(__decoder))
}
2usize => {
GenericArgKind::Const(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `GenericArgKind`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for GenericArgKind<I> where
I::Region: ::rustc_serialize::Encodable<__E>,
I::Ty: ::rustc_serialize::Encodable<__E>,
I::Const: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
GenericArgKind::Lifetime(ref __binding_0) => { 0usize }
GenericArgKind::Type(ref __binding_0) => { 1usize }
GenericArgKind::Const(ref __binding_0) => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
GenericArgKind::Lifetime(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
GenericArgKind::Type(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
GenericArgKind::Const(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
GenericArgKind<I> where
I::Region: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::Ty: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::Const: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
GenericArgKind::Lifetime(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericArgKind::Type(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
GenericArgKind::Const(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_NoContext)
13)]
14pub enum GenericArgKind<I: Interner> {
15 Lifetime(I::Region),
16 Type(I::Ty),
17 Const(I::Const),
18}
19
20impl<I: Interner> Eq for GenericArgKind<I> {}
21
22#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for TermKind<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
TermKind::Ty(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "Ty");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
TermKind::Const(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "Const");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, PartialEq, Debug; I: Interner)]
23#[derive(GenericTypeVisitable)]
24#[cfg_attr(
25 feature = "nightly",
26 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for TermKind<I> where
I::Ty: ::rustc_serialize::Decodable<__D>,
I::Const: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
TermKind::Ty(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
TermKind::Const(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `TermKind`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for TermKind<I> where
I::Ty: ::rustc_serialize::Encodable<__E>,
I::Const: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
TermKind::Ty(ref __binding_0) => { 0usize }
TermKind::Const(ref __binding_0) => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
TermKind::Ty(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
TermKind::Const(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TermKind<I> where
I::Ty: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::Const: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
TermKind::Ty(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TermKind::Const(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_NoContext)
27)]
28pub enum TermKind<I: Interner> {
29 Ty(I::Ty),
30 Const(I::Const),
31}
32
33impl<I: Interner> Eq for TermKind<I> {}