1use std::fmt;
2use std::marker::PhantomData;
3use std::ops::Deref;
4
5use derive_where::derive_where;
6use rustc_abi::ExternAbi;
7use rustc_ast_ir::Mutability;
8#[cfg(feature = "nightly")]
9use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHasher};
10#[cfg(feature = "nightly")]
11use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash_NoContext};
12use rustc_type_ir::data_structures::{NoError, UnifyKey, UnifyValue};
13use rustc_type_ir_macros::{
14 GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic,
15};
16
17use self::TyKind::*;
18pub use self::closure::*;
19use crate::inherent::*;
20use crate::ty::AliasTy;
21use crate::{
22 self as ty, BoundVarIndexKind, FloatTy, FreeAliasTy, InherentAliasTy, IntTy, Interner,
23 OpaqueAliasTy, ProjectionAliasTy, Region, UintTy, Unnormalized,
24};
25
26mod closure;
27
28#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for AliasTyKind<I> where I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for AliasTyKind<I> where I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for AliasTyKind<I> where I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
AliasTyKind::Projection { def_id: ref __field_def_id } => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_def_id, __state);
}
AliasTyKind::Inherent { def_id: ref __field_def_id } => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_def_id, __state);
}
AliasTyKind::Opaque { def_id: ref __field_def_id } => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_def_id, __state);
}
AliasTyKind::Free { 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 AliasTyKind<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) {
(AliasTyKind::Projection { def_id: ref __field_def_id },
AliasTyKind::Projection { def_id: ref __other_field_def_id
}) =>
true &&
::core::cmp::PartialEq::eq(__field_def_id,
__other_field_def_id),
(AliasTyKind::Inherent { def_id: ref __field_def_id },
AliasTyKind::Inherent { def_id: ref __other_field_def_id })
=>
true &&
::core::cmp::PartialEq::eq(__field_def_id,
__other_field_def_id),
(AliasTyKind::Opaque { def_id: ref __field_def_id },
AliasTyKind::Opaque { def_id: ref __other_field_def_id }) =>
true &&
::core::cmp::PartialEq::eq(__field_def_id,
__other_field_def_id),
(AliasTyKind::Free { def_id: ref __field_def_id },
AliasTyKind::Free { 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 }
}
}
const _: () =
{
trait DeriveWhereAssertEq {
fn assert(&self);
}
impl<I: Interner> DeriveWhereAssertEq for AliasTyKind<I> where
I: Interner {
fn assert(&self) {
struct __AssertEq<__T: ::core::cmp::Eq +
?::core::marker::Sized>(::core::marker::PhantomData<__T>);
let _: __AssertEq<I::TraitAssocTyId>;
let _: __AssertEq<I::InherentAssocTyId>;
let _: __AssertEq<I::OpaqueTyId>;
let _: __AssertEq<I::FreeTyAliasId>;
}
}
};
#[automatically_derived]
impl<I: Interner> ::core::cmp::Eq for AliasTyKind<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for AliasTyKind<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
AliasTyKind::Projection { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "Projection");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
AliasTyKind::Inherent { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "Inherent");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
AliasTyKind::Opaque { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "Opaque");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
AliasTyKind::Free { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "Free");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
29#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for AliasTyKind<I>
where I: Interner,
I::TraitAssocTyId: ::rustc_type_ir::TypeVisitable<I>,
I::InherentAssocTyId: ::rustc_type_ir::TypeVisitable<I>,
I::OpaqueTyId: ::rustc_type_ir::TypeVisitable<I>,
I::FreeTyAliasId: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
AliasTyKind::Projection { def_id: ref __binding_0 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
AliasTyKind::Inherent { def_id: ref __binding_0 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
AliasTyKind::Opaque { def_id: ref __binding_0 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
AliasTyKind::Free { def_id: ref __binding_0 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for AliasTyKind<I>
where
I::TraitAssocTyId: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::InherentAssocTyId: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::OpaqueTyId: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::FreeTyAliasId: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
AliasTyKind::Projection { def_id: ref __binding_0 } => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
AliasTyKind::Inherent { def_id: ref __binding_0 } => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
AliasTyKind::Opaque { def_id: ref __binding_0 } => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
AliasTyKind::Free { 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 AliasTyKind<I>
where I: Interner,
I::TraitAssocTyId: ::rustc_type_ir::TypeFoldable<I>,
I::InherentAssocTyId: ::rustc_type_ir::TypeFoldable<I>,
I::OpaqueTyId: ::rustc_type_ir::TypeFoldable<I>,
I::FreeTyAliasId: ::rustc_type_ir::TypeFoldable<I> {
fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
AliasTyKind::Projection { def_id: __binding_0 } => {
AliasTyKind::Projection {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
AliasTyKind::Inherent { def_id: __binding_0 } => {
AliasTyKind::Inherent {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
AliasTyKind::Opaque { def_id: __binding_0 } => {
AliasTyKind::Opaque {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
AliasTyKind::Free { def_id: __binding_0 } => {
AliasTyKind::Free {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
AliasTyKind::Projection { def_id: __binding_0 } => {
AliasTyKind::Projection {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
AliasTyKind::Inherent { def_id: __binding_0 } => {
AliasTyKind::Inherent {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
AliasTyKind::Opaque { def_id: __binding_0 } => {
AliasTyKind::Opaque {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
AliasTyKind::Free { def_id: __binding_0 } => {
AliasTyKind::Free {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for AliasTyKind<I>
where J: Interner, I: ::rustc_type_ir::LiftInto<J> {
type Lifted = AliasTyKind<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
AliasTyKind::Projection { def_id: __binding_0 } => {
AliasTyKind::Projection {
def_id: __binding_0.lift_to_interner(interner),
}
}
AliasTyKind::Inherent { def_id: __binding_0 } => {
AliasTyKind::Inherent {
def_id: __binding_0.lift_to_interner(interner),
}
}
AliasTyKind::Opaque { def_id: __binding_0 } => {
AliasTyKind::Opaque {
def_id: __binding_0.lift_to_interner(interner),
}
}
AliasTyKind::Free { def_id: __binding_0 } => {
AliasTyKind::Free {
def_id: __binding_0.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
30#[cfg_attr(
31 feature = "nightly",
32 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for AliasTyKind<I> where
I::TraitAssocTyId: ::rustc_serialize::Encodable<__E>,
I::InherentAssocTyId: ::rustc_serialize::Encodable<__E>,
I::OpaqueTyId: ::rustc_serialize::Encodable<__E>,
I::FreeTyAliasId: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
AliasTyKind::Projection { def_id: ref __binding_0 } => {
0usize
}
AliasTyKind::Inherent { def_id: ref __binding_0 } => {
1usize
}
AliasTyKind::Opaque { def_id: ref __binding_0 } => {
2usize
}
AliasTyKind::Free { def_id: ref __binding_0 } => { 3usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
AliasTyKind::Projection { def_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AliasTyKind::Inherent { def_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AliasTyKind::Opaque { def_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AliasTyKind::Free { def_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for AliasTyKind<I> where
I::TraitAssocTyId: ::rustc_serialize::Decodable<__D>,
I::InherentAssocTyId: ::rustc_serialize::Decodable<__D>,
I::OpaqueTyId: ::rustc_serialize::Decodable<__D>,
I::FreeTyAliasId: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
AliasTyKind::Projection {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
1usize => {
AliasTyKind::Inherent {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
2usize => {
AliasTyKind::Opaque {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
3usize => {
AliasTyKind::Free {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `AliasTyKind`, expected 0..4, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
AliasTyKind<I> where
I::TraitAssocTyId: ::rustc_data_structures::stable_hash::StableHash,
I::InherentAssocTyId: ::rustc_data_structures::stable_hash::StableHash,
I::OpaqueTyId: ::rustc_data_structures::stable_hash::StableHash,
I::FreeTyAliasId: ::rustc_data_structures::stable_hash::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
AliasTyKind::Projection { def_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AliasTyKind::Inherent { def_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AliasTyKind::Opaque { def_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AliasTyKind::Free { def_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
33)]
34pub enum AliasTyKind<I: Interner> {
35 Projection { def_id: I::TraitAssocTyId },
45
46 Inherent { def_id: I::InherentAssocTyId },
50
51 Opaque { def_id: I::OpaqueTyId },
61
62 Free { def_id: I::FreeTyAliasId },
67}
68
69impl<I: Interner> AliasTyKind<I> {
70 pub fn descr(self) -> &'static str {
71 match self {
72 AliasTyKind::Projection { .. } => "associated type",
73 AliasTyKind::Inherent { .. } => "inherent associated type",
74 AliasTyKind::Opaque { .. } => "opaque type",
75 AliasTyKind::Free { .. } => "type alias",
76 }
77 }
78
79 pub fn try_to_projection(self) -> Option<I::TraitAssocTyId> {
80 match self {
81 AliasTyKind::Projection { def_id } => Some(def_id),
82 _ => None,
83 }
84 }
85
86 pub fn try_to_inherent(self) -> Option<I::InherentAssocTyId> {
87 match self {
88 AliasTyKind::Inherent { def_id } => Some(def_id),
89 _ => None,
90 }
91 }
92
93 pub fn try_to_opaque(self) -> Option<I::OpaqueTyId> {
94 match self {
95 AliasTyKind::Opaque { def_id } => Some(def_id),
96 _ => None,
97 }
98 }
99
100 pub fn try_to_free(self) -> Option<I::FreeTyAliasId> {
101 match self {
102 AliasTyKind::Free { def_id } => Some(def_id),
103 _ => None,
104 }
105 }
106}
107
108#[derive(#[automatically_derived]
impl ::core::fmt::Debug for IsRigid {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self { IsRigid::Yes => "Yes", IsRigid::No => "No", })
}
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for IsRigid { }
#[automatically_derived]
impl ::core::clone::Clone for IsRigid {
#[inline]
fn clone(&self) -> IsRigid { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for IsRigid { }Copy, #[automatically_derived]
impl ::core::hash::Hash for IsRigid {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for IsRigid { }
#[automatically_derived]
impl ::core::cmp::PartialEq for IsRigid {
#[inline]
fn eq(&self, other: &IsRigid) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq)]
130#[derive(const _: () =
{
impl<I> ::rustc_type_ir::TypeVisitable<I> for IsRigid where
I: Interner {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self { IsRigid::Yes => {} IsRigid::No => {} }
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, const _: () =
{
unsafe impl<__V> ::rustc_type_ir::GenericTypeVisitable<__V> for
IsRigid {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self { IsRigid::Yes => {} IsRigid::No => {} }
}
}
};GenericTypeVisitable, const _: () =
{
impl<I> ::rustc_type_ir::TypeFoldable<I> for IsRigid where I: Interner
{
fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
IsRigid::Yes => { IsRigid::Yes }
IsRigid::No => { IsRigid::No }
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
IsRigid::Yes => { IsRigid::Yes }
IsRigid::No => { IsRigid::No }
}
}
}
};TypeFoldable_Generic)]
131#[cfg_attr(
132 feature = "nightly",
133 derive(const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for IsRigid {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { IsRigid::Yes }
1usize => { IsRigid::No }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `IsRigid`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for IsRigid {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
IsRigid::Yes => { 0usize }
IsRigid::No => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
}
}
};Encodable_NoContext, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for IsRigid {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self { IsRigid::Yes => {} IsRigid::No => {} }
}
}
};StableHash_NoContext)
134)]
135pub enum IsRigid {
136 Yes,
137 No,
138}
139
140impl IsRigid {
141 pub fn yes_if_next_solver<I: Interner>(interner: I) -> IsRigid {
142 if interner.next_trait_solver_globally() { IsRigid::Yes } else { IsRigid::No }
143 }
144}
145
146#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "IrTyKind")]
151#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for TyKind<I> where I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for TyKind<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for TyKind<I> where I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
TyKind::Bool => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
}
TyKind::Char => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
}
TyKind::Int(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
TyKind::Uint(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
TyKind::Float(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
TyKind::Adt(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);
}
TyKind::Foreign(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
TyKind::Str => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
}
TyKind::Array(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);
}
TyKind::Pat(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);
}
TyKind::Slice(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
TyKind::RawPtr(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);
}
TyKind::Ref(ref __field_0, ref __field_1, ref __field_2) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
::core::hash::Hash::hash(__field_1, __state);
::core::hash::Hash::hash(__field_2, __state);
}
TyKind::FnDef(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);
}
TyKind::FnPtr(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);
}
TyKind::UnsafeBinder(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
TyKind::Dynamic(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);
}
TyKind::Closure(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);
}
TyKind::CoroutineClosure(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);
}
TyKind::Coroutine(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);
}
TyKind::CoroutineWitness(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);
}
TyKind::Never => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
}
TyKind::Tuple(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
TyKind::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);
}
TyKind::Param(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
TyKind::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);
}
TyKind::Placeholder(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
TyKind::Infer(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
TyKind::Error(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 TyKind<I> where I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
if ::core::mem::discriminant(self) ==
::core::mem::discriminant(__other) {
match (self, __other) {
(TyKind::Int(ref __field_0), TyKind::Int(ref __other_field_0))
=>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(TyKind::Uint(ref __field_0),
TyKind::Uint(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(TyKind::Float(ref __field_0),
TyKind::Float(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(TyKind::Adt(ref __field_0, ref __field_1),
TyKind::Adt(ref __other_field_0, ref __other_field_1)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::Foreign(ref __field_0),
TyKind::Foreign(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(TyKind::Array(ref __field_0, ref __field_1),
TyKind::Array(ref __other_field_0, ref __other_field_1)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::Pat(ref __field_0, ref __field_1),
TyKind::Pat(ref __other_field_0, ref __other_field_1)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::Slice(ref __field_0),
TyKind::Slice(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(TyKind::RawPtr(ref __field_0, ref __field_1),
TyKind::RawPtr(ref __other_field_0, ref __other_field_1)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::Ref(ref __field_0, ref __field_1, ref __field_2),
TyKind::Ref(ref __other_field_0, ref __other_field_1,
ref __other_field_2)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1) &&
::core::cmp::PartialEq::eq(__field_2, __other_field_2),
(TyKind::FnDef(ref __field_0, ref __field_1),
TyKind::FnDef(ref __other_field_0, ref __other_field_1)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::FnPtr(ref __field_0, ref __field_1),
TyKind::FnPtr(ref __other_field_0, ref __other_field_1)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::UnsafeBinder(ref __field_0),
TyKind::UnsafeBinder(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(TyKind::Dynamic(ref __field_0, ref __field_1),
TyKind::Dynamic(ref __other_field_0, ref __other_field_1))
=>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::Closure(ref __field_0, ref __field_1),
TyKind::Closure(ref __other_field_0, ref __other_field_1))
=>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::CoroutineClosure(ref __field_0, ref __field_1),
TyKind::CoroutineClosure(ref __other_field_0,
ref __other_field_1)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::Coroutine(ref __field_0, ref __field_1),
TyKind::Coroutine(ref __other_field_0, ref __other_field_1))
=>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::CoroutineWitness(ref __field_0, ref __field_1),
TyKind::CoroutineWitness(ref __other_field_0,
ref __other_field_1)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::Tuple(ref __field_0),
TyKind::Tuple(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(TyKind::Alias(ref __field_0, ref __field_1),
TyKind::Alias(ref __other_field_0, ref __other_field_1)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::Param(ref __field_0),
TyKind::Param(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(TyKind::Bound(ref __field_0, ref __field_1),
TyKind::Bound(ref __other_field_0, ref __other_field_1)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1),
(TyKind::Placeholder(ref __field_0),
TyKind::Placeholder(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(TyKind::Infer(ref __field_0),
TyKind::Infer(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(TyKind::Error(ref __field_0),
TyKind::Error(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
_ => true,
}
} else { false }
}
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
152#[derive(const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for TyKind<I> where
IntTy: ::rustc_type_ir::GenericTypeVisitable<__V>,
UintTy: ::rustc_type_ir::GenericTypeVisitable<__V>,
FloatTy: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::AdtDef: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::ForeignId: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Const: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Pat: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
Mutability: ::rustc_type_ir::GenericTypeVisitable<__V>,
Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
Mutability: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::FunctionId: ::rustc_type_ir::GenericTypeVisitable<__V>,
ty::Binder<I,
I::GenericArgs>: ::rustc_type_ir::GenericTypeVisitable<__V>,
ty::Binder<I,
FnSigTys<I>>: ::rustc_type_ir::GenericTypeVisitable<__V>,
FnHeader<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
UnsafeBinderInner<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::BoundExistentialPredicates: ::rustc_type_ir::GenericTypeVisitable<__V>,
Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::ClosureId: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::CoroutineClosureId: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::CoroutineId: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::CoroutineId: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Tys: ::rustc_type_ir::GenericTypeVisitable<__V>,
IsRigid: ::rustc_type_ir::GenericTypeVisitable<__V>,
AliasTy<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::ParamTy: ::rustc_type_ir::GenericTypeVisitable<__V>,
BoundVarIndexKind: ::rustc_type_ir::GenericTypeVisitable<__V>,
ty::BoundTy<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
ty::PlaceholderType<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
InferTy: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::ErrorGuaranteed: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
TyKind::Bool => {}
TyKind::Char => {}
TyKind::Int(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
TyKind::Uint(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
TyKind::Float(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
TyKind::Adt(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);
}
}
TyKind::Foreign(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
TyKind::Str => {}
TyKind::Array(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);
}
}
TyKind::Pat(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);
}
}
TyKind::Slice(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
TyKind::RawPtr(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);
}
}
TyKind::Ref(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
__visitor);
}
}
TyKind::FnDef(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);
}
}
TyKind::FnPtr(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);
}
}
TyKind::UnsafeBinder(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
TyKind::Dynamic(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);
}
}
TyKind::Closure(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);
}
}
TyKind::CoroutineClosure(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);
}
}
TyKind::Coroutine(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);
}
}
TyKind::CoroutineWitness(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);
}
}
TyKind::Never => {}
TyKind::Tuple(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
TyKind::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);
}
}
TyKind::Param(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
TyKind::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);
}
}
TyKind::Placeholder(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
TyKind::Infer(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
TyKind::Error(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
}
}
}
};GenericTypeVisitable)]
153#[cfg_attr(
154 feature = "nightly",
155 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for TyKind<I> where
I::AdtDef: ::rustc_serialize::Encodable<__E>,
I::GenericArgs: ::rustc_serialize::Encodable<__E>,
I::ForeignId: ::rustc_serialize::Encodable<__E>,
I::Ty: ::rustc_serialize::Encodable<__E>,
I::Const: ::rustc_serialize::Encodable<__E>,
I::Pat: ::rustc_serialize::Encodable<__E>,
Region<I>: ::rustc_serialize::Encodable<__E>,
I::FunctionId: ::rustc_serialize::Encodable<__E>,
ty::Binder<I, I::GenericArgs>: ::rustc_serialize::Encodable<__E>,
ty::Binder<I, FnSigTys<I>>: ::rustc_serialize::Encodable<__E>,
FnHeader<I>: ::rustc_serialize::Encodable<__E>,
UnsafeBinderInner<I>: ::rustc_serialize::Encodable<__E>,
I::BoundExistentialPredicates: ::rustc_serialize::Encodable<__E>,
I::ClosureId: ::rustc_serialize::Encodable<__E>,
I::CoroutineClosureId: ::rustc_serialize::Encodable<__E>,
I::CoroutineId: ::rustc_serialize::Encodable<__E>,
I::Tys: ::rustc_serialize::Encodable<__E>,
AliasTy<I>: ::rustc_serialize::Encodable<__E>,
I::ParamTy: ::rustc_serialize::Encodable<__E>,
ty::BoundTy<I>: ::rustc_serialize::Encodable<__E>,
ty::PlaceholderType<I>: ::rustc_serialize::Encodable<__E>,
I::ErrorGuaranteed: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
TyKind::Bool => { 0usize }
TyKind::Char => { 1usize }
TyKind::Int(ref __binding_0) => { 2usize }
TyKind::Uint(ref __binding_0) => { 3usize }
TyKind::Float(ref __binding_0) => { 4usize }
TyKind::Adt(ref __binding_0, ref __binding_1) => { 5usize }
TyKind::Foreign(ref __binding_0) => { 6usize }
TyKind::Str => { 7usize }
TyKind::Array(ref __binding_0, ref __binding_1) => {
8usize
}
TyKind::Pat(ref __binding_0, ref __binding_1) => { 9usize }
TyKind::Slice(ref __binding_0) => { 10usize }
TyKind::RawPtr(ref __binding_0, ref __binding_1) => {
11usize
}
TyKind::Ref(ref __binding_0, ref __binding_1,
ref __binding_2) => {
12usize
}
TyKind::FnDef(ref __binding_0, ref __binding_1) => {
13usize
}
TyKind::FnPtr(ref __binding_0, ref __binding_1) => {
14usize
}
TyKind::UnsafeBinder(ref __binding_0) => { 15usize }
TyKind::Dynamic(ref __binding_0, ref __binding_1) => {
16usize
}
TyKind::Closure(ref __binding_0, ref __binding_1) => {
17usize
}
TyKind::CoroutineClosure(ref __binding_0, ref __binding_1)
=> {
18usize
}
TyKind::Coroutine(ref __binding_0, ref __binding_1) => {
19usize
}
TyKind::CoroutineWitness(ref __binding_0, ref __binding_1)
=> {
20usize
}
TyKind::Never => { 21usize }
TyKind::Tuple(ref __binding_0) => { 22usize }
TyKind::Alias(ref __binding_0, ref __binding_1) => {
23usize
}
TyKind::Param(ref __binding_0) => { 24usize }
TyKind::Bound(ref __binding_0, ref __binding_1) => {
25usize
}
TyKind::Placeholder(ref __binding_0) => { 26usize }
TyKind::Infer(ref __binding_0) => { 27usize }
TyKind::Error(ref __binding_0) => { 28usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
TyKind::Bool => {}
TyKind::Char => {}
TyKind::Int(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
TyKind::Uint(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
TyKind::Float(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
TyKind::Adt(ref __binding_0, ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::Foreign(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
TyKind::Str => {}
TyKind::Array(ref __binding_0, ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::Pat(ref __binding_0, ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::Slice(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
TyKind::RawPtr(ref __binding_0, ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::Ref(ref __binding_0, ref __binding_1,
ref __binding_2) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
}
TyKind::FnDef(ref __binding_0, ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::FnPtr(ref __binding_0, ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::UnsafeBinder(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
TyKind::Dynamic(ref __binding_0, ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::Closure(ref __binding_0, ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::CoroutineClosure(ref __binding_0, ref __binding_1)
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::Coroutine(ref __binding_0, ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::CoroutineWitness(ref __binding_0, ref __binding_1)
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::Never => {}
TyKind::Tuple(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
TyKind::Alias(ref __binding_0, ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::Param(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
TyKind::Bound(ref __binding_0, ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
TyKind::Placeholder(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
TyKind::Infer(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
TyKind::Error(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for TyKind<I> where
I::AdtDef: ::rustc_serialize::Decodable<__D>,
I::GenericArgs: ::rustc_serialize::Decodable<__D>,
I::ForeignId: ::rustc_serialize::Decodable<__D>,
I::Ty: ::rustc_serialize::Decodable<__D>,
I::Const: ::rustc_serialize::Decodable<__D>,
I::Pat: ::rustc_serialize::Decodable<__D>,
Region<I>: ::rustc_serialize::Decodable<__D>,
I::FunctionId: ::rustc_serialize::Decodable<__D>,
ty::Binder<I, I::GenericArgs>: ::rustc_serialize::Decodable<__D>,
ty::Binder<I, FnSigTys<I>>: ::rustc_serialize::Decodable<__D>,
FnHeader<I>: ::rustc_serialize::Decodable<__D>,
UnsafeBinderInner<I>: ::rustc_serialize::Decodable<__D>,
I::BoundExistentialPredicates: ::rustc_serialize::Decodable<__D>,
I::ClosureId: ::rustc_serialize::Decodable<__D>,
I::CoroutineClosureId: ::rustc_serialize::Decodable<__D>,
I::CoroutineId: ::rustc_serialize::Decodable<__D>,
I::Tys: ::rustc_serialize::Decodable<__D>,
AliasTy<I>: ::rustc_serialize::Decodable<__D>,
I::ParamTy: ::rustc_serialize::Decodable<__D>,
ty::BoundTy<I>: ::rustc_serialize::Decodable<__D>,
ty::PlaceholderType<I>: ::rustc_serialize::Decodable<__D>,
I::ErrorGuaranteed: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { TyKind::Bool }
1usize => { TyKind::Char }
2usize => {
TyKind::Int(::rustc_serialize::Decodable::decode(__decoder))
}
3usize => {
TyKind::Uint(::rustc_serialize::Decodable::decode(__decoder))
}
4usize => {
TyKind::Float(::rustc_serialize::Decodable::decode(__decoder))
}
5usize => {
TyKind::Adt(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
6usize => {
TyKind::Foreign(::rustc_serialize::Decodable::decode(__decoder))
}
7usize => { TyKind::Str }
8usize => {
TyKind::Array(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
9usize => {
TyKind::Pat(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
10usize => {
TyKind::Slice(::rustc_serialize::Decodable::decode(__decoder))
}
11usize => {
TyKind::RawPtr(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
12usize => {
TyKind::Ref(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
13usize => {
TyKind::FnDef(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
14usize => {
TyKind::FnPtr(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
15usize => {
TyKind::UnsafeBinder(::rustc_serialize::Decodable::decode(__decoder))
}
16usize => {
TyKind::Dynamic(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
17usize => {
TyKind::Closure(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
18usize => {
TyKind::CoroutineClosure(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
19usize => {
TyKind::Coroutine(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
20usize => {
TyKind::CoroutineWitness(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
21usize => { TyKind::Never }
22usize => {
TyKind::Tuple(::rustc_serialize::Decodable::decode(__decoder))
}
23usize => {
TyKind::Alias(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
24usize => {
TyKind::Param(::rustc_serialize::Decodable::decode(__decoder))
}
25usize => {
TyKind::Bound(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
26usize => {
TyKind::Placeholder(::rustc_serialize::Decodable::decode(__decoder))
}
27usize => {
TyKind::Infer(::rustc_serialize::Decodable::decode(__decoder))
}
28usize => {
TyKind::Error(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `TyKind`, expected 0..29, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
TyKind<I> where
I::AdtDef: ::rustc_data_structures::stable_hash::StableHash,
I::GenericArgs: ::rustc_data_structures::stable_hash::StableHash,
I::ForeignId: ::rustc_data_structures::stable_hash::StableHash,
I::Ty: ::rustc_data_structures::stable_hash::StableHash,
I::Const: ::rustc_data_structures::stable_hash::StableHash,
I::Pat: ::rustc_data_structures::stable_hash::StableHash,
Region<I>: ::rustc_data_structures::stable_hash::StableHash,
I::FunctionId: ::rustc_data_structures::stable_hash::StableHash,
ty::Binder<I,
I::GenericArgs>: ::rustc_data_structures::stable_hash::StableHash,
ty::Binder<I,
FnSigTys<I>>: ::rustc_data_structures::stable_hash::StableHash,
FnHeader<I>: ::rustc_data_structures::stable_hash::StableHash,
UnsafeBinderInner<I>: ::rustc_data_structures::stable_hash::StableHash,
I::BoundExistentialPredicates: ::rustc_data_structures::stable_hash::StableHash,
I::ClosureId: ::rustc_data_structures::stable_hash::StableHash,
I::CoroutineClosureId: ::rustc_data_structures::stable_hash::StableHash,
I::CoroutineId: ::rustc_data_structures::stable_hash::StableHash,
I::Tys: ::rustc_data_structures::stable_hash::StableHash,
AliasTy<I>: ::rustc_data_structures::stable_hash::StableHash,
I::ParamTy: ::rustc_data_structures::stable_hash::StableHash,
ty::BoundTy<I>: ::rustc_data_structures::stable_hash::StableHash,
ty::PlaceholderType<I>: ::rustc_data_structures::stable_hash::StableHash,
I::ErrorGuaranteed: ::rustc_data_structures::stable_hash::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
TyKind::Bool => {}
TyKind::Char => {}
TyKind::Int(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Uint(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Float(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Adt(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Foreign(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Str => {}
TyKind::Array(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Pat(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Slice(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::RawPtr(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Ref(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
TyKind::FnDef(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::FnPtr(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::UnsafeBinder(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Dynamic(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Closure(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::CoroutineClosure(ref __binding_0, ref __binding_1)
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Coroutine(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::CoroutineWitness(ref __binding_0, ref __binding_1)
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Never => {}
TyKind::Tuple(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Alias(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Param(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Bound(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
TyKind::Placeholder(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Infer(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
TyKind::Error(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
156)]
157pub enum TyKind<I: Interner> {
158 Bool,
160
161 Char,
164
165 Int(IntTy),
167
168 Uint(UintTy),
170
171 Float(FloatTy),
173
174 Adt(I::AdtDef, I::GenericArgs),
182
183 Foreign(I::ForeignId),
185
186 Str,
188
189 Array(I::Ty, I::Const),
191
192 Pat(I::Ty, I::Pat),
200
201 Slice(I::Ty),
203
204 RawPtr(I::Ty, Mutability),
206
207 Ref(Region<I>, I::Ty, Mutability),
210
211 FnDef(I::FunctionId, ty::Binder<I, I::GenericArgs>),
224
225 FnPtr(ty::Binder<I, FnSigTys<I>>, FnHeader<I>),
244
245 UnsafeBinder(UnsafeBinderInner<I>),
251
252 Dynamic(I::BoundExistentialPredicates, Region<I>),
254
255 Closure(I::ClosureId, I::GenericArgs),
261
262 CoroutineClosure(I::CoroutineClosureId, I::GenericArgs),
268
269 Coroutine(I::CoroutineId, I::GenericArgs),
275
276 CoroutineWitness(I::CoroutineId, I::GenericArgs),
301
302 Never,
304
305 Tuple(I::Tys),
307
308 Alias(IsRigid, AliasTy<I>),
313
314 Param(I::ParamTy),
316
317 Bound(BoundVarIndexKind, ty::BoundTy<I>),
334
335 Placeholder(ty::PlaceholderType<I>),
344
345 Infer(InferTy),
352
353 Error(I::ErrorGuaranteed),
357}
358
359impl<I: Interner> Eq for TyKind<I> {}
360
361impl<I: Interner> TyKind<I> {
362 pub fn fn_sig(self, interner: I) -> ty::Binder<I, ty::FnSig<I>> {
363 self.unnormalized_fn_sig(interner).skip_normalization()
364 }
365
366 pub fn unnormalized_fn_sig(self, interner: I) -> Unnormalized<I, ty::Binder<I, ty::FnSig<I>>> {
367 match self {
368 ty::FnPtr(sig_tys, hdr) => Unnormalized::new_wip(sig_tys.with(hdr)),
369 ty::FnDef(def_id, args) => {
370 interner.fn_sig(def_id).instantiate(interner, args.no_bound_vars().unwrap())
371 }
372 ty::Error(_) => {
373 Unnormalized::dummy(ty::Binder::dummy(ty::FnSig::dummy()))
375 }
376 ty::Closure(..) => {
::core::panicking::panic_fmt(format_args!("to get the signature of a closure, use `args.as_closure().sig()` not `fn_sig()`"));
}panic!(
377 "to get the signature of a closure, use `args.as_closure().sig()` not `fn_sig()`",
378 ),
379 _ => {
::core::panicking::panic_fmt(format_args!("Ty::fn_sig() called on non-fn type: {0:?}",
self));
}panic!("Ty::fn_sig() called on non-fn type: {:?}", self),
380 }
381 }
382
383 pub fn is_known_rigid(self) -> bool {
391 match self {
392 ty::Bool
393 | ty::Char
394 | ty::Int(_)
395 | ty::Uint(_)
396 | ty::Float(_)
397 | ty::Adt(_, _)
398 | ty::Foreign(_)
399 | ty::Str
400 | ty::Array(_, _)
401 | ty::Pat(_, _)
402 | ty::Slice(_)
403 | ty::RawPtr(_, _)
404 | ty::Ref(_, _, _)
405 | ty::FnDef(_, _)
406 | ty::FnPtr(..)
407 | ty::UnsafeBinder(_)
408 | ty::Dynamic(_, _)
409 | ty::Closure(_, _)
410 | ty::CoroutineClosure(_, _)
411 | ty::Coroutine(_, _)
412 | ty::CoroutineWitness(..)
413 | ty::Never
414 | ty::Tuple(_) => true,
415
416 ty::Error(_)
417 | ty::Infer(_)
418 | ty::Alias(ty::IsRigid::No | ty::IsRigid::Yes, _)
419 | ty::Param(_)
420 | ty::Bound(_, _)
421 | ty::Placeholder(_) => false,
422 }
423 }
424}
425
426impl<I: Interner> fmt::Debug for TyKind<I> {
428 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
429 match self {
430 Bool => f.write_fmt(format_args!("bool"))write!(f, "bool"),
431 Char => f.write_fmt(format_args!("char"))write!(f, "char"),
432 Int(i) => f.write_fmt(format_args!("{0:?}", i))write!(f, "{i:?}"),
433 Uint(u) => f.write_fmt(format_args!("{0:?}", u))write!(f, "{u:?}"),
434 Float(float) => f.write_fmt(format_args!("{0:?}", float))write!(f, "{float:?}"),
435 Adt(d, s) => {
436 f.write_fmt(format_args!("{0:?}", d))write!(f, "{d:?}")?;
437 let mut s = s.iter();
438 let first = s.next();
439 match first {
440 Some(first) => f.write_fmt(format_args!("<{0:?}", first))write!(f, "<{:?}", first)?,
441 None => return Ok(()),
442 };
443
444 for arg in s {
445 f.write_fmt(format_args!(", {0:?}", arg))write!(f, ", {:?}", arg)?;
446 }
447
448 f.write_fmt(format_args!(">"))write!(f, ">")
449 }
450 Foreign(d) => f.debug_tuple("Foreign").field(d).finish(),
451 Str => f.write_fmt(format_args!("str"))write!(f, "str"),
452 Array(t, c) => f.write_fmt(format_args!("[{0:?}; {1:?}]", t, c))write!(f, "[{t:?}; {c:?}]"),
453 Pat(t, p) => f.write_fmt(format_args!("pattern_type!({0:?} is {1:?})", t, p))write!(f, "pattern_type!({t:?} is {p:?})"),
454 Slice(t) => f.write_fmt(format_args!("[{0:?}]", &t))write!(f, "[{:?}]", &t),
455 RawPtr(ty, mutbl) => f.write_fmt(format_args!("*{0} {1:?}", mutbl.ptr_str(), ty))write!(f, "*{} {:?}", mutbl.ptr_str(), ty),
456 Ref(r, t, m) => f.write_fmt(format_args!("&{0:?} {1}{2:?}", r, m.prefix_str(), t))write!(f, "&{:?} {}{:?}", r, m.prefix_str(), t),
457 FnDef(d, s) => f.debug_tuple("FnDef").field(d).field(&s).finish(),
458 FnPtr(sig_tys, hdr) => f.write_fmt(format_args!("{0:?}", sig_tys.with(*hdr)))write!(f, "{:?}", sig_tys.with(*hdr)),
459 UnsafeBinder(binder) => f.write_fmt(format_args!("{0:?}", binder))write!(f, "{:?}", binder),
461 Dynamic(p, r) => f.write_fmt(format_args!("dyn {0:?} + {1:?}", p, r))write!(f, "dyn {p:?} + {r:?}"),
462 Closure(d, s) => f.debug_tuple("Closure").field(d).field(&s).finish(),
463 CoroutineClosure(d, s) => f.debug_tuple("CoroutineClosure").field(d).field(&s).finish(),
464 Coroutine(d, s) => f.debug_tuple("Coroutine").field(d).field(&s).finish(),
465 CoroutineWitness(d, s) => f.debug_tuple("CoroutineWitness").field(d).field(&s).finish(),
466 Never => f.write_fmt(format_args!("!"))write!(f, "!"),
467 Tuple(t) => {
468 f.write_fmt(format_args!("("))write!(f, "(")?;
469 let mut count = 0;
470 for ty in t.iter() {
471 if count > 0 {
472 f.write_fmt(format_args!(", "))write!(f, ", ")?;
473 }
474 f.write_fmt(format_args!("{0:?}", ty))write!(f, "{ty:?}")?;
475 count += 1;
476 }
477 if count == 1 {
479 f.write_fmt(format_args!(","))write!(f, ",")?;
480 }
481 f.write_fmt(format_args!(")"))write!(f, ")")
482 }
483 Alias(is_rigid, a) => f.debug_tuple("Alias").field(&is_rigid).field(&a).finish(),
484 Param(p) => f.write_fmt(format_args!("{0:?}", p))write!(f, "{p:?}"),
485 Bound(d, b) => crate::debug_bound_var(f, *d, b),
486 Placeholder(p) => f.write_fmt(format_args!("{0:?}", p))write!(f, "{p:?}"),
487 Infer(t) => f.write_fmt(format_args!("{0:?}", t))write!(f, "{:?}", t),
488 TyKind::Error(_) => f.write_fmt(format_args!("{{type error}}"))write!(f, "{{type error}}"),
489 }
490 }
491}
492
493impl<I: Interner> AliasTy<I> {
494 pub fn new_from_args(interner: I, kind: AliasTyKind<I>, args: I::GenericArgs) -> AliasTy<I> {
495 if truecfg!(debug_assertions) {
496 interner.debug_assert_alias_term_args_compatible(kind.into(), args);
497 }
498 AliasTy { kind, args, _use_alias_new_instead: () }
499 }
500
501 pub fn new(
502 interner: I,
503 kind: AliasTyKind<I>,
504 args: impl IntoIterator<Item: Into<I::GenericArg>>,
505 ) -> AliasTy<I> {
506 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
507 Self::new_from_args(interner, kind, args)
508 }
509
510 pub fn is_opaque(self) -> bool {
512 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
AliasTyKind::Opaque { .. } => true,
_ => false,
}matches!(self.kind, AliasTyKind::Opaque { .. })
513 }
514
515 pub fn to_ty(self, interner: I, is_rigid: ty::IsRigid) -> I::Ty {
516 Ty::new_alias(interner, is_rigid, self)
517 }
518
519 pub fn try_to_projection(self) -> Option<ProjectionAliasTy<I>> {
520 self.kind.try_to_projection().map(|kind| ty::Alias {
521 kind,
522 args: self.args,
523 _use_alias_new_instead: (),
524 })
525 }
526
527 pub fn try_to_inherent(self) -> Option<InherentAliasTy<I>> {
528 self.kind.try_to_inherent().map(|kind| ty::Alias {
529 kind,
530 args: self.args,
531 _use_alias_new_instead: (),
532 })
533 }
534
535 pub fn try_to_opaque(self) -> Option<OpaqueAliasTy<I>> {
536 self.kind.try_to_opaque().map(|kind| ty::Alias {
537 kind,
538 args: self.args,
539 _use_alias_new_instead: (),
540 })
541 }
542
543 pub fn try_to_free(self) -> Option<FreeAliasTy<I>> {
544 self.kind.try_to_free().map(|kind| ty::Alias {
545 kind,
546 args: self.args,
547 _use_alias_new_instead: (),
548 })
549 }
550}
551
552impl<I: Interner> ProjectionAliasTy<I> {
553 pub fn new_projection_from_args(
554 interner: I,
555 kind: I::TraitAssocTyId,
556 args: I::GenericArgs,
557 ) -> Self {
558 interner.debug_assert_alias_term_args_compatible(
559 ty::AliasTermKind::ProjectionTy { def_id: kind },
560 args,
561 );
562 Self { kind, args, _use_alias_new_instead: () }
563 }
564
565 pub fn projection_to_alias_ty(self) -> AliasTy<I> {
566 AliasTy {
567 kind: AliasTyKind::Projection { def_id: self.kind },
568 args: self.args,
569 _use_alias_new_instead: (),
570 }
571 }
572
573 #[track_caller]
574 pub fn projection_self_ty(self) -> I::Ty {
575 self.args.type_at(0)
576 }
577}
578
579impl<I: Interner> AliasTy<I> {
583 #[track_caller]
584 pub fn self_ty(self) -> I::Ty {
585 self.args.type_at(0)
586 }
587
588 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
589 AliasTy::new(
590 interner,
591 self.kind,
592 [self_ty.into()].into_iter().chain(self.args.iter().skip(1)),
593 )
594 }
595
596 pub fn trait_def_id(self, interner: I) -> I::TraitId {
597 let AliasTyKind::Projection { def_id } = self.kind else { { ::core::panicking::panic_fmt(format_args!("expected a projection")); }panic!("expected a projection") };
598
599 interner.projection_parent(def_id.into())
600 }
601
602 pub fn trait_ref_and_own_args(self, interner: I) -> (ty::TraitRef<I>, I::GenericArgsSlice) {
608 let AliasTyKind::Projection { def_id } = self.kind else { { ::core::panicking::panic_fmt(format_args!("expected a projection")); }panic!("expected a projection") };
609
610 interner.trait_ref_and_own_args_for_alias(def_id.into(), self.args)
611 }
612
613 pub fn trait_ref(self, interner: I) -> ty::TraitRef<I> {
622 self.trait_ref_and_own_args(interner).0
623 }
624}
625
626impl<I: Interner> InherentAliasTy<I> {
627 pub fn new_inherent_from_args(
628 interner: I,
629 kind: I::InherentAssocTyId,
630 args: I::GenericArgs,
631 ) -> Self {
632 interner.debug_assert_alias_term_args_compatible(
633 ty::AliasTermKind::InherentTy { def_id: kind },
634 args,
635 );
636 Self { kind, args, _use_alias_new_instead: () }
637 }
638
639 pub fn inherent_to_alias_ty(self) -> AliasTy<I> {
640 AliasTy {
641 kind: AliasTyKind::Inherent { def_id: self.kind },
642 args: self.args,
643 _use_alias_new_instead: (),
644 }
645 }
646}
647
648impl<I: Interner> OpaqueAliasTy<I> {
649 pub fn new_opaque_from_args(interner: I, kind: I::OpaqueTyId, args: I::GenericArgs) -> Self {
650 interner.debug_assert_alias_term_args_compatible(
651 ty::AliasTermKind::OpaqueTy { def_id: kind },
652 args,
653 );
654 Self { kind, args, _use_alias_new_instead: () }
655 }
656
657 pub fn opaque_to_alias_ty(self) -> AliasTy<I> {
658 AliasTy {
659 kind: AliasTyKind::Opaque { def_id: self.kind },
660 args: self.args,
661 _use_alias_new_instead: (),
662 }
663 }
664}
665
666impl<I: Interner> FreeAliasTy<I> {
667 pub fn new_free_from_args(interner: I, kind: I::FreeTyAliasId, args: I::GenericArgs) -> Self {
668 interner.debug_assert_alias_term_args_compatible(
669 ty::AliasTermKind::FreeTy { def_id: kind },
670 args,
671 );
672 Self { kind, args, _use_alias_new_instead: () }
673 }
674
675 pub fn free_to_alias_ty(self) -> AliasTy<I> {
676 AliasTy {
677 kind: AliasTyKind::Free { def_id: self.kind },
678 args: self.args,
679 _use_alias_new_instead: (),
680 }
681 }
682}
683
684#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for IntVarValue { }
#[automatically_derived]
impl ::core::clone::Clone for IntVarValue {
#[inline]
fn clone(&self) -> IntVarValue {
let _: ::core::clone::AssertParamIsClone<IntTy>;
let _: ::core::clone::AssertParamIsClone<UintTy>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for IntVarValue { }Copy, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for IntVarValue { }
#[automatically_derived]
impl ::core::cmp::PartialEq for IntVarValue {
#[inline]
fn eq(&self, other: &IntVarValue) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(IntVarValue::IntType(__self_0),
IntVarValue::IntType(__arg1_0)) => __self_0 == __arg1_0,
(IntVarValue::UintType(__self_0),
IntVarValue::UintType(__arg1_0)) => __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for IntVarValue {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<IntTy>;
let _: ::core::cmp::AssertParamIsEq<UintTy>;
}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for IntVarValue {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
IntVarValue::Unknown =>
::core::fmt::Formatter::write_str(f, "Unknown"),
IntVarValue::IntType(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"IntType", &__self_0),
IntVarValue::UintType(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"UintType", &__self_0),
}
}
}Debug)]
685pub enum IntVarValue {
686 Unknown,
687 IntType(IntTy),
688 UintType(UintTy),
689}
690
691impl IntVarValue {
692 pub fn is_known(self) -> bool {
693 match self {
694 IntVarValue::IntType(_) | IntVarValue::UintType(_) => true,
695 IntVarValue::Unknown => false,
696 }
697 }
698
699 pub fn is_unknown(self) -> bool {
700 !self.is_known()
701 }
702}
703
704#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for FloatVarValue { }
#[automatically_derived]
impl ::core::clone::Clone for FloatVarValue {
#[inline]
fn clone(&self) -> FloatVarValue {
let _: ::core::clone::AssertParamIsClone<FloatTy>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for FloatVarValue { }Copy, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for FloatVarValue { }
#[automatically_derived]
impl ::core::cmp::PartialEq for FloatVarValue {
#[inline]
fn eq(&self, other: &FloatVarValue) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(FloatVarValue::Known(__self_0),
FloatVarValue::Known(__arg1_0)) => __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FloatVarValue {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<FloatTy>;
}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for FloatVarValue {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
FloatVarValue::Unknown =>
::core::fmt::Formatter::write_str(f, "Unknown"),
FloatVarValue::Known(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Known",
&__self_0),
}
}
}Debug)]
705pub enum FloatVarValue {
706 Unknown,
707 Known(FloatTy),
708}
709
710impl FloatVarValue {
711 pub fn is_known(self) -> bool {
712 match self {
713 FloatVarValue::Known(_) => true,
714 FloatVarValue::Unknown => false,
715 }
716 }
717
718 pub fn is_unknown(self) -> bool {
719 !self.is_known()
720 }
721}
722
723#[automatically_derived]
impl ::core::marker::Copy for TyVid { }
impl TyVid {
#[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 TyVid {
type Output = Self;
#[inline]
fn add(self, other: usize) -> Self {
Self::from_usize(self.index() + other)
}
}
impl std::ops::AddAssign<usize> for TyVid {
#[inline]
fn add_assign(&mut self, other: usize) { *self = *self + other; }
}
impl rustc_index::Idx for TyVid {
#[inline]
fn new(value: usize) -> Self { Self::from_usize(value) }
#[inline]
fn index(self) -> usize { self.as_usize() }
}
impl ::std::iter::Step for TyVid {
#[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 TyVid {
#[inline]
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.as_u32().cmp(&other.as_u32())
}
}
impl ::std::cmp::PartialOrd for TyVid {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl From<TyVid> for u32 {
#[inline]
fn from(v: TyVid) -> u32 { v.as_u32() }
}
impl From<TyVid> for usize {
#[inline]
fn from(v: TyVid) -> usize { v.as_usize() }
}
impl From<usize> for TyVid {
#[inline]
fn from(value: usize) -> Self { Self::from_usize(value) }
}
impl From<u32> for TyVid {
#[inline]
fn from(value: u32) -> Self { Self::from_u32(value) }
}
impl ::std::cmp::Eq for TyVid {}
impl ::std::cmp::PartialEq for TyVid {
fn eq(&self, other: &Self) -> bool { self.as_u32().eq(&other.as_u32()) }
}
impl ::std::marker::StructuralPartialEq for TyVid { }
impl ::std::hash::Hash for TyVid {
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 TyVid
{
fn decode(d: &mut D) -> Self { Self::from_u32(d.read_u32()) }
}
impl<E: ::rustc_serialize::Encoder> ::rustc_serialize::Encodable<E> for TyVid
{
fn encode(&self, e: &mut E) { e.emit_u32(self.as_u32()); }
}
impl ::std::fmt::Debug for TyVid {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_fmt(format_args!("?{0}t", self.as_u32()))
}
}rustc_index::newtype_index! {
724 #[encodable]
726 #[orderable]
727 #[debug_format = "?{}t"]
728 #[gate_rustc_only]
729 pub struct TyVid {}
730}
731
732#[automatically_derived]
impl ::core::marker::Copy for IntVid { }
impl IntVid {
#[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 IntVid {
type Output = Self;
#[inline]
fn add(self, other: usize) -> Self {
Self::from_usize(self.index() + other)
}
}
impl std::ops::AddAssign<usize> for IntVid {
#[inline]
fn add_assign(&mut self, other: usize) { *self = *self + other; }
}
impl rustc_index::Idx for IntVid {
#[inline]
fn new(value: usize) -> Self { Self::from_usize(value) }
#[inline]
fn index(self) -> usize { self.as_usize() }
}
impl ::std::iter::Step for IntVid {
#[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 IntVid {
#[inline]
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.as_u32().cmp(&other.as_u32())
}
}
impl ::std::cmp::PartialOrd for IntVid {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl From<IntVid> for u32 {
#[inline]
fn from(v: IntVid) -> u32 { v.as_u32() }
}
impl From<IntVid> for usize {
#[inline]
fn from(v: IntVid) -> usize { v.as_usize() }
}
impl From<usize> for IntVid {
#[inline]
fn from(value: usize) -> Self { Self::from_usize(value) }
}
impl From<u32> for IntVid {
#[inline]
fn from(value: u32) -> Self { Self::from_u32(value) }
}
impl ::std::cmp::Eq for IntVid {}
impl ::std::cmp::PartialEq for IntVid {
fn eq(&self, other: &Self) -> bool { self.as_u32().eq(&other.as_u32()) }
}
impl ::std::marker::StructuralPartialEq for IntVid { }
impl ::std::hash::Hash for IntVid {
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 IntVid
{
fn decode(d: &mut D) -> Self { Self::from_u32(d.read_u32()) }
}
impl<E: ::rustc_serialize::Encoder> ::rustc_serialize::Encodable<E> for IntVid
{
fn encode(&self, e: &mut E) { e.emit_u32(self.as_u32()); }
}
impl ::std::fmt::Debug for IntVid {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_fmt(format_args!("?{0}i", self.as_u32()))
}
}rustc_index::newtype_index! {
733 #[encodable]
735 #[orderable]
736 #[debug_format = "?{}i"]
737 #[gate_rustc_only]
738 pub struct IntVid {}
739}
740
741#[automatically_derived]
impl ::core::marker::Copy for FloatVid { }
impl FloatVid {
#[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 FloatVid {
type Output = Self;
#[inline]
fn add(self, other: usize) -> Self {
Self::from_usize(self.index() + other)
}
}
impl std::ops::AddAssign<usize> for FloatVid {
#[inline]
fn add_assign(&mut self, other: usize) { *self = *self + other; }
}
impl rustc_index::Idx for FloatVid {
#[inline]
fn new(value: usize) -> Self { Self::from_usize(value) }
#[inline]
fn index(self) -> usize { self.as_usize() }
}
impl ::std::iter::Step for FloatVid {
#[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 FloatVid {
#[inline]
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.as_u32().cmp(&other.as_u32())
}
}
impl ::std::cmp::PartialOrd for FloatVid {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl From<FloatVid> for u32 {
#[inline]
fn from(v: FloatVid) -> u32 { v.as_u32() }
}
impl From<FloatVid> for usize {
#[inline]
fn from(v: FloatVid) -> usize { v.as_usize() }
}
impl From<usize> for FloatVid {
#[inline]
fn from(value: usize) -> Self { Self::from_usize(value) }
}
impl From<u32> for FloatVid {
#[inline]
fn from(value: u32) -> Self { Self::from_u32(value) }
}
impl ::std::cmp::Eq for FloatVid {}
impl ::std::cmp::PartialEq for FloatVid {
fn eq(&self, other: &Self) -> bool { self.as_u32().eq(&other.as_u32()) }
}
impl ::std::marker::StructuralPartialEq for FloatVid { }
impl ::std::hash::Hash for FloatVid {
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
FloatVid {
fn decode(d: &mut D) -> Self { Self::from_u32(d.read_u32()) }
}
impl<E: ::rustc_serialize::Encoder> ::rustc_serialize::Encodable<E> for
FloatVid {
fn encode(&self, e: &mut E) { e.emit_u32(self.as_u32()); }
}
impl ::std::fmt::Debug for FloatVid {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_fmt(format_args!("?{0}f", self.as_u32()))
}
}rustc_index::newtype_index! {
742 #[encodable]
744 #[orderable]
745 #[debug_format = "?{}f"]
746 #[gate_rustc_only]
747 pub struct FloatVid {}
748}
749
750#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for InferTy { }
#[automatically_derived]
impl ::core::clone::Clone for InferTy {
#[inline]
fn clone(&self) -> InferTy {
let _: ::core::clone::AssertParamIsClone<TyVid>;
let _: ::core::clone::AssertParamIsClone<IntVid>;
let _: ::core::clone::AssertParamIsClone<FloatVid>;
let _: ::core::clone::AssertParamIsClone<u32>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for InferTy { }Copy, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for InferTy { }
#[automatically_derived]
impl ::core::cmp::PartialEq for InferTy {
#[inline]
fn eq(&self, other: &InferTy) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(InferTy::TyVar(__self_0), InferTy::TyVar(__arg1_0)) =>
__self_0 == __arg1_0,
(InferTy::IntVar(__self_0), InferTy::IntVar(__arg1_0)) =>
__self_0 == __arg1_0,
(InferTy::FloatVar(__self_0), InferTy::FloatVar(__arg1_0)) =>
__self_0 == __arg1_0,
(InferTy::FreshTy(__self_0), InferTy::FreshTy(__arg1_0)) =>
__self_0 == __arg1_0,
(InferTy::FreshIntTy(__self_0), InferTy::FreshIntTy(__arg1_0))
=> __self_0 == __arg1_0,
(InferTy::FreshFloatTy(__self_0),
InferTy::FreshFloatTy(__arg1_0)) => __self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for InferTy {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<TyVid>;
let _: ::core::cmp::AssertParamIsEq<IntVid>;
let _: ::core::cmp::AssertParamIsEq<FloatVid>;
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for InferTy {
#[inline]
fn partial_cmp(&self, other: &InferTy)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for InferTy {
#[inline]
fn cmp(&self, other: &InferTy) -> ::core::cmp::Ordering {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) {
::core::cmp::Ordering::Equal =>
match (self, other) {
(InferTy::TyVar(__self_0), InferTy::TyVar(__arg1_0)) =>
::core::cmp::Ord::cmp(__self_0, __arg1_0),
(InferTy::IntVar(__self_0), InferTy::IntVar(__arg1_0)) =>
::core::cmp::Ord::cmp(__self_0, __arg1_0),
(InferTy::FloatVar(__self_0), InferTy::FloatVar(__arg1_0))
=> ::core::cmp::Ord::cmp(__self_0, __arg1_0),
(InferTy::FreshTy(__self_0), InferTy::FreshTy(__arg1_0)) =>
::core::cmp::Ord::cmp(__self_0, __arg1_0),
(InferTy::FreshIntTy(__self_0),
InferTy::FreshIntTy(__arg1_0)) =>
::core::cmp::Ord::cmp(__self_0, __arg1_0),
(InferTy::FreshFloatTy(__self_0),
InferTy::FreshFloatTy(__arg1_0)) =>
::core::cmp::Ord::cmp(__self_0, __arg1_0),
_ => unsafe { ::core::intrinsics::unreachable() }
},
cmp => cmp,
}
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for InferTy {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
InferTy::TyVar(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
InferTy::IntVar(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
InferTy::FloatVar(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
InferTy::FreshTy(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
InferTy::FreshIntTy(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
InferTy::FreshFloatTy(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
}
}
}Hash)]
756#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for InferTy {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
InferTy::TyVar(ref __binding_0) => { 0usize }
InferTy::IntVar(ref __binding_0) => { 1usize }
InferTy::FloatVar(ref __binding_0) => { 2usize }
InferTy::FreshTy(ref __binding_0) => { 3usize }
InferTy::FreshIntTy(ref __binding_0) => { 4usize }
InferTy::FreshFloatTy(ref __binding_0) => { 5usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
InferTy::TyVar(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
InferTy::IntVar(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
InferTy::FloatVar(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
InferTy::FreshTy(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
InferTy::FreshIntTy(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
InferTy::FreshFloatTy(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable_NoContext, const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for InferTy {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
InferTy::TyVar(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
InferTy::IntVar(::rustc_serialize::Decodable::decode(__decoder))
}
2usize => {
InferTy::FloatVar(::rustc_serialize::Decodable::decode(__decoder))
}
3usize => {
InferTy::FreshTy(::rustc_serialize::Decodable::decode(__decoder))
}
4usize => {
InferTy::FreshIntTy(::rustc_serialize::Decodable::decode(__decoder))
}
5usize => {
InferTy::FreshFloatTy(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `InferTy`, expected 0..6, actual {0}",
n));
}
}
}
}
};Decodable_NoContext))]
757pub enum InferTy {
758 TyVar(TyVid),
760 IntVar(IntVid),
767 FloatVar(FloatVid),
774
775 FreshTy(u32),
782 FreshIntTy(u32),
784 FreshFloatTy(u32),
786}
787
788impl UnifyValue for IntVarValue {
789 type Error = NoError;
790
791 fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
792 match (*value1, *value2) {
793 (IntVarValue::Unknown, IntVarValue::Unknown) => Ok(IntVarValue::Unknown),
794 (
795 IntVarValue::Unknown,
796 known @ (IntVarValue::UintType(_) | IntVarValue::IntType(_)),
797 )
798 | (
799 known @ (IntVarValue::UintType(_) | IntVarValue::IntType(_)),
800 IntVarValue::Unknown,
801 ) => Ok(known),
802 _ => {
::core::panicking::panic_fmt(format_args!("differing ints should have been resolved first"));
}panic!("differing ints should have been resolved first"),
803 }
804 }
805}
806
807impl UnifyKey for IntVid {
808 type Value = IntVarValue;
809 #[inline] fn index(&self) -> u32 {
811 self.as_u32()
812 }
813 #[inline]
814 fn from_index(i: u32) -> IntVid {
815 IntVid::from_u32(i)
816 }
817 fn tag() -> &'static str {
818 "IntVid"
819 }
820}
821
822impl UnifyValue for FloatVarValue {
823 type Error = NoError;
824
825 fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
826 match (*value1, *value2) {
827 (FloatVarValue::Unknown, FloatVarValue::Unknown) => Ok(FloatVarValue::Unknown),
828 (FloatVarValue::Unknown, FloatVarValue::Known(known))
829 | (FloatVarValue::Known(known), FloatVarValue::Unknown) => {
830 Ok(FloatVarValue::Known(known))
831 }
832 (FloatVarValue::Known(_), FloatVarValue::Known(_)) => {
833 {
::core::panicking::panic_fmt(format_args!("differing floats should have been resolved first"));
}panic!("differing floats should have been resolved first")
834 }
835 }
836 }
837}
838
839impl UnifyKey for FloatVid {
840 type Value = FloatVarValue;
841 #[inline]
842 fn index(&self) -> u32 {
843 self.as_u32()
844 }
845 #[inline]
846 fn from_index(i: u32) -> FloatVid {
847 FloatVid::from_u32(i)
848 }
849 fn tag() -> &'static str {
850 "FloatVid"
851 }
852}
853
854#[cfg(feature = "nightly")]
855impl StableHash for InferTy {
856 fn stable_hash<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
857 use InferTy::*;
858 std::mem::discriminant(self).stable_hash(hcx, hasher);
859 match self {
860 TyVar(_) | IntVar(_) | FloatVar(_) => {
861 {
::core::panicking::panic_fmt(format_args!("type variables should not be hashed: {0:?}",
self));
}panic!("type variables should not be hashed: {self:?}")
862 }
863 FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.stable_hash(hcx, hasher),
864 }
865 }
866}
867
868impl fmt::Display for InferTy {
869 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
870 use InferTy::*;
871 match *self {
872 TyVar(_) => f.write_fmt(format_args!("_"))write!(f, "_"),
873 IntVar(_) => f.write_fmt(format_args!("{0}", "{integer}"))write!(f, "{}", "{integer}"),
874 FloatVar(_) => f.write_fmt(format_args!("{0}", "{float}"))write!(f, "{}", "{float}"),
875 FreshTy(v) => f.write_fmt(format_args!("FreshTy({0})", v))write!(f, "FreshTy({v})"),
876 FreshIntTy(v) => f.write_fmt(format_args!("FreshIntTy({0})", v))write!(f, "FreshIntTy({v})"),
877 FreshFloatTy(v) => f.write_fmt(format_args!("FreshFloatTy({0})", v))write!(f, "FreshFloatTy({v})"),
878 }
879 }
880}
881
882impl fmt::Debug for InferTy {
883 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
884 use InferTy::*;
885 match *self {
886 TyVar(ref v) => v.fmt(f),
887 IntVar(ref v) => v.fmt(f),
888 FloatVar(ref v) => v.fmt(f),
889 FreshTy(v) => f.write_fmt(format_args!("FreshTy({0:?})", v))write!(f, "FreshTy({v:?})"),
890 FreshIntTy(v) => f.write_fmt(format_args!("FreshIntTy({0:?})", v))write!(f, "FreshIntTy({v:?})"),
891 FreshFloatTy(v) => f.write_fmt(format_args!("FreshFloatTy({0:?})", v))write!(f, "FreshFloatTy({v:?})"),
892 }
893 }
894}
895
896#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for TypeAndMut<I> where I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for TypeAndMut<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for TypeAndMut<I> where I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(TypeAndMut { ty: ref __field_ty, mutbl: ref __field_mutbl },
TypeAndMut {
ty: ref __other_field_ty, mutbl: ref __other_field_mutbl }) =>
true &&
::core::cmp::PartialEq::eq(__field_ty, __other_field_ty) &&
::core::cmp::PartialEq::eq(__field_mutbl,
__other_field_mutbl),
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for TypeAndMut<I> where I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
TypeAndMut { ty: ref __field_ty, mutbl: ref __field_mutbl } => {
::core::hash::Hash::hash(__field_ty, __state);
::core::hash::Hash::hash(__field_mutbl, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for TypeAndMut<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
TypeAndMut { ty: ref __field_ty, mutbl: ref __field_mutbl } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "TypeAndMut");
::core::fmt::DebugStruct::field(&mut __builder, "ty",
__field_ty);
::core::fmt::DebugStruct::field(&mut __builder, "mutbl",
__field_mutbl);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, PartialEq, Hash, Debug; I: Interner)]
897#[cfg_attr(
898 feature = "nightly",
899 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for TypeAndMut<I> where
I::Ty: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let TypeAndMut { ty: ref __binding_0, mutbl: ref __binding_1
} = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for TypeAndMut<I> where
I::Ty: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
TypeAndMut {
ty: ::rustc_serialize::Decodable::decode(__decoder),
mutbl: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
TypeAndMut<I> where
I::Ty: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TypeAndMut { ty: ref __binding_0, mutbl: ref __binding_1 }
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
900)]
901#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for TypeAndMut<I>
where I: Interner, I::Ty: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
TypeAndMut { ty: ref __binding_0, mutbl: ref __binding_1 }
=> {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for TypeAndMut<I> where
I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
Mutability: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
TypeAndMut { ty: ref __binding_0, mutbl: 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);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for TypeAndMut<I>
where I: Interner, I::Ty: ::rustc_type_ir::TypeFoldable<I> {
fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
TypeAndMut { ty: __binding_0, mutbl: __binding_1 } => {
TypeAndMut {
ty: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
mutbl: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
TypeAndMut { ty: __binding_0, mutbl: __binding_1 } => {
TypeAndMut {
ty: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
mutbl: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable_Generic)]
902pub struct TypeAndMut<I: Interner> {
903 pub ty: I::Ty,
904 pub mutbl: Mutability,
905}
906
907impl<I: Interner> Eq for TypeAndMut<I> {}
908
909#[derive(#[automatically_derived]
impl ::core::fmt::Debug for SplattedArgIndexError {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
SplattedArgIndexError::InvalidIndex { splatted_arg_index: __self_0
} =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"InvalidIndex", "splatted_arg_index", &__self_0),
SplattedArgIndexError::OutOfBounds {
splatted_arg_index: __self_0, args_len: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"OutOfBounds", "splatted_arg_index", __self_0, "args_len",
&__self_1),
}
}
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for SplattedArgIndexError { }
#[automatically_derived]
impl ::core::clone::Clone for SplattedArgIndexError {
#[inline]
fn clone(&self) -> SplattedArgIndexError {
let _: ::core::clone::AssertParamIsClone<u8>;
let _: ::core::clone::AssertParamIsClone<u16>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for SplattedArgIndexError { }Copy, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for SplattedArgIndexError { }
#[automatically_derived]
impl ::core::cmp::PartialEq for SplattedArgIndexError {
#[inline]
fn eq(&self, other: &SplattedArgIndexError) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(SplattedArgIndexError::InvalidIndex {
splatted_arg_index: __self_0 },
SplattedArgIndexError::InvalidIndex {
splatted_arg_index: __arg1_0 }) => __self_0 == __arg1_0,
(SplattedArgIndexError::OutOfBounds {
splatted_arg_index: __self_0, args_len: __self_1 },
SplattedArgIndexError::OutOfBounds {
splatted_arg_index: __arg1_0, args_len: __arg1_1 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for SplattedArgIndexError {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u8>;
let _: ::core::cmp::AssertParamIsEq<u16>;
}
}Eq)]
911pub enum SplattedArgIndexError {
912 InvalidIndex { splatted_arg_index: u8 },
916
917 OutOfBounds { splatted_arg_index: u8, args_len: u16 },
919}
920
921#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for FnSigKind<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for FnSigKind<I> where I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for FnSigKind<I> where I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(FnSigKind {
flags: ref __field_flags,
splatted: ref __field_splatted,
_marker: ref __field__marker }, FnSigKind {
flags: ref __other_field_flags,
splatted: ref __other_field_splatted,
_marker: ref __other_field__marker }) =>
true &&
::core::cmp::PartialEq::eq(__field_flags,
__other_field_flags) &&
::core::cmp::PartialEq::eq(__field_splatted,
__other_field_splatted) &&
::core::cmp::PartialEq::eq(__field__marker,
__other_field__marker),
}
}
}
const _: () =
{
trait DeriveWhereAssertEq {
fn assert(&self);
}
impl<I: Interner> DeriveWhereAssertEq for FnSigKind<I> where
I: Interner {
fn assert(&self) {
struct __AssertEq<__T: ::core::cmp::Eq +
?::core::marker::Sized>(::core::marker::PhantomData<__T>);
let _: __AssertEq<u8>;
let _: __AssertEq<u8>;
let _: __AssertEq<PhantomData<fn() -> I>>;
}
}
};
#[automatically_derived]
impl<I: Interner> ::core::cmp::Eq for FnSigKind<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for FnSigKind<I> where I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
FnSigKind {
flags: ref __field_flags,
splatted: ref __field_splatted,
_marker: ref __field__marker } => {
::core::hash::Hash::hash(__field_flags, __state);
::core::hash::Hash::hash(__field_splatted, __state);
::core::hash::Hash::hash(__field__marker, __state);
}
}
}
}#[derive_where(Copy, Clone, PartialEq, Eq, Hash; I: Interner)]
923#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for FnSigKind<I>
where I: Interner {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self { FnSigKind { .. } => {} }
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for FnSigKind<I>
where I: Interner {
fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
FnSigKind {
flags: __binding_0,
splatted: __binding_1,
_marker: __binding_2 } => {
FnSigKind {
flags: __binding_0,
splatted: __binding_1,
_marker: __binding_2,
}
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
FnSigKind {
flags: __binding_0,
splatted: __binding_1,
_marker: __binding_2 } => {
FnSigKind {
flags: __binding_0,
splatted: __binding_1,
_marker: __binding_2,
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for FnSigKind<I>
where J: Interner, I: ::rustc_type_ir::LiftInto<J> {
type Lifted = FnSigKind<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
FnSigKind {
flags: __binding_0,
splatted: __binding_1,
_marker: __binding_2 } => {
FnSigKind {
flags: __binding_0,
splatted: __binding_1,
_marker: PhantomData,
}
}
}
}
}
};Lift_Generic)]
924#[cfg_attr(
925 feature = "nightly",
926 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for FnSigKind<I> where
PhantomData<fn() -> I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let FnSigKind {
flags: ref __binding_0,
splatted: ref __binding_1,
_marker: ref __binding_2 } = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for FnSigKind<I> where
PhantomData<fn() -> I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
FnSigKind {
flags: ::rustc_serialize::Decodable::decode(__decoder),
splatted: ::rustc_serialize::Decodable::decode(__decoder),
_marker: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
FnSigKind<I> where
PhantomData<fn()
-> I>: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
FnSigKind {
flags: ref __binding_0,
splatted: ref __binding_1,
_marker: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
927)]
928pub struct FnSigKind<I: Interner> {
929 #[lift(identity)]
932 #[type_visitable(ignore)]
933 #[type_foldable(identity)]
934 flags: u8,
935
936 #[lift(identity)]
940 #[type_visitable(ignore)]
941 #[type_foldable(identity)]
942 splatted: u8,
943
944 #[type_visitable(ignore)]
945 #[type_foldable(identity)]
946 _marker: PhantomData<fn() -> I>,
947}
948
949impl<I: Interner> fmt::Debug for FnSigKind<I> {
950 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
951 let mut f = f.debug_tuple("FnSigKind");
952
953 if self.is_safe() {
954 f.field(&"Safe");
955 } else {
956 f.field(&"Unsafe");
957 }
958
959 f.field(&self.abi());
960
961 if self.c_variadic() {
962 f.field(&"CVariadic");
963 }
964
965 if let Some(index) = self.splatted() {
966 f.field(&::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Splatted({0})", index))
})format!("Splatted({})", index));
967 }
968
969 f.finish()
970 }
971}
972
973impl<I: Interner> Default for FnSigKind<I> {
974 fn default() -> Self {
977 Self { flags: 0, splatted: 0, _marker: PhantomData }
978 .set_abi(ExternAbi::Rust)
979 .set_safety(I::Safety::unsafe_mode())
980 .set_c_variadic(false)
981 .set_no_splatted_args()
982 }
983}
984
985impl<I: Interner> FnSigKind<I> {
986 const EXTERN_ABI_MASK: u8 = 0b111111;
988
989 const SAFE_FLAG: u8 = 1 << 6;
991
992 const C_VARIADIC_FLAG: u8 = 1 << 7;
994
995 pub const NO_SPLATTED_ARG_INDEX: u8 = u8::MAX;
1003
1004 pub fn new(
1007 abi: ExternAbi,
1008 safety: I::Safety,
1009 c_variadic: bool,
1010 splatted: Option<u8>,
1011 args_len: usize,
1012 ) -> Result<Self, SplattedArgIndexError> {
1013 Self::default()
1014 .set_abi(abi)
1015 .set_safety(safety)
1016 .set_c_variadic(c_variadic)
1017 .set_splatted(splatted, args_len)
1018 }
1019
1020 pub fn dummy() -> Self {
1022 Self::default().set_safety(I::Safety::safe())
1023 }
1024
1025 #[must_use = "this method does not modify the receiver"]
1027 pub fn set_abi(mut self, abi: ExternAbi) -> Self {
1028 let abi_index = abi.as_packed();
1029 if !(abi_index <= Self::EXTERN_ABI_MASK) {
::core::panicking::panic("assertion failed: abi_index <= Self::EXTERN_ABI_MASK")
};assert!(abi_index <= Self::EXTERN_ABI_MASK);
1030
1031 self.flags &= !Self::EXTERN_ABI_MASK;
1032 self.flags |= abi_index;
1033
1034 self
1035 }
1036
1037 #[must_use = "this method does not modify the receiver"]
1039 pub fn set_safety(mut self, safety: I::Safety) -> Self {
1040 if safety.is_safe() {
1041 self.flags |= Self::SAFE_FLAG;
1042 } else {
1043 self.flags &= !Self::SAFE_FLAG;
1044 }
1045
1046 self
1047 }
1048
1049 #[must_use = "this method does not modify the receiver"]
1051 pub fn set_c_variadic(mut self, c_variadic: bool) -> Self {
1052 if c_variadic {
1053 self.flags |= Self::C_VARIADIC_FLAG;
1054 } else {
1055 self.flags &= !Self::C_VARIADIC_FLAG;
1056 }
1057
1058 self
1059 }
1060
1061 #[must_use = "this method does not modify the receiver"]
1064 pub fn set_splatted(
1065 mut self,
1066 splatted: Option<u8>,
1067 args_len: usize,
1068 ) -> Result<Self, SplattedArgIndexError> {
1069 if let Some(splatted_arg_index) = splatted {
1070 if splatted_arg_index == Self::NO_SPLATTED_ARG_INDEX {
1071 return Err(SplattedArgIndexError::InvalidIndex { splatted_arg_index });
1074 } else if usize::from(splatted_arg_index) >= args_len {
1075 return Err(SplattedArgIndexError::OutOfBounds {
1076 splatted_arg_index,
1077 args_len: args_len as u16,
1078 });
1079 }
1080
1081 self.splatted = splatted_arg_index;
1082 } else {
1083 self.splatted = Self::NO_SPLATTED_ARG_INDEX;
1084 }
1085
1086 Ok(self)
1087 }
1088
1089 #[must_use = "this method does not modify the receiver"]
1091 pub fn set_no_splatted_args(mut self) -> Self {
1092 self.splatted = Self::NO_SPLATTED_ARG_INDEX;
1093 self
1094 }
1095
1096 pub fn abi(self) -> ExternAbi {
1098 let abi_index = self.flags & Self::EXTERN_ABI_MASK;
1099 ExternAbi::from_packed(abi_index)
1100 }
1101
1102 pub fn is_safe(self) -> bool {
1104 self.flags & Self::SAFE_FLAG != 0
1105 }
1106
1107 pub fn safety(self) -> I::Safety {
1109 if self.is_safe() { I::Safety::safe() } else { I::Safety::unsafe_mode() }
1110 }
1111
1112 pub fn c_variadic(self) -> bool {
1114 self.flags & Self::C_VARIADIC_FLAG != 0
1115 }
1116
1117 pub fn splatted(self) -> Option<u8> {
1119 if self.splatted == Self::NO_SPLATTED_ARG_INDEX { None } else { Some(self.splatted) }
1120 }
1121}
1122
1123#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for FnSig<I> where I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for FnSig<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for FnSig<I> where I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(FnSig {
inputs_and_output: ref __field_inputs_and_output,
fn_sig_kind: ref __field_fn_sig_kind }, FnSig {
inputs_and_output: ref __other_field_inputs_and_output,
fn_sig_kind: ref __other_field_fn_sig_kind }) =>
true &&
::core::cmp::PartialEq::eq(__field_inputs_and_output,
__other_field_inputs_and_output) &&
::core::cmp::PartialEq::eq(__field_fn_sig_kind,
__other_field_fn_sig_kind),
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for FnSig<I> where I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
FnSig {
inputs_and_output: ref __field_inputs_and_output,
fn_sig_kind: ref __field_fn_sig_kind } => {
::core::hash::Hash::hash(__field_inputs_and_output, __state);
::core::hash::Hash::hash(__field_fn_sig_kind, __state);
}
}
}
}#[derive_where(Clone, Copy, PartialEq, Hash; I: Interner)]
1124#[cfg_attr(
1125 feature = "nightly",
1126 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for FnSig<I> where
I::Tys: ::rustc_serialize::Encodable<__E>,
FnSigKind<I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let FnSig {
inputs_and_output: ref __binding_0,
fn_sig_kind: ref __binding_1 } = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for FnSig<I> where
I::Tys: ::rustc_serialize::Decodable<__D>,
FnSigKind<I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
FnSig {
inputs_and_output: ::rustc_serialize::Decodable::decode(__decoder),
fn_sig_kind: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
FnSig<I> where
I::Tys: ::rustc_data_structures::stable_hash::StableHash,
FnSigKind<I>: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
FnSig {
inputs_and_output: ref __binding_0,
fn_sig_kind: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
1127)]
1128#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for FnSig<I> where
I: Interner, I::Tys: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
FnSig { inputs_and_output: ref __binding_0, .. } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for FnSig<I> where
I::Tys: ::rustc_type_ir::GenericTypeVisitable<__V>,
FnSigKind<I>: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
FnSig {
inputs_and_output: ref __binding_0,
fn_sig_kind: 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);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for FnSig<I> where
I: Interner, I::Tys: ::rustc_type_ir::TypeFoldable<I> {
fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
FnSig {
inputs_and_output: __binding_0, fn_sig_kind: __binding_1 }
=> {
FnSig {
inputs_and_output: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
fn_sig_kind: __binding_1,
}
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
FnSig {
inputs_and_output: __binding_0, fn_sig_kind: __binding_1 }
=> {
FnSig {
inputs_and_output: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
fn_sig_kind: __binding_1,
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for FnSig<I> where
J: Interner, I: ::rustc_type_ir::LiftInto<J> {
type Lifted = FnSig<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
FnSig {
inputs_and_output: __binding_0, fn_sig_kind: __binding_1 }
=> {
FnSig {
inputs_and_output: __binding_0.lift_to_interner(interner),
fn_sig_kind: __binding_1.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
1129pub struct FnSig<I: Interner> {
1130 pub inputs_and_output: I::Tys,
1131 #[type_visitable(ignore)]
1132 #[type_foldable(identity)]
1133 pub fn_sig_kind: FnSigKind<I>,
1134}
1135
1136impl<I: Interner> Eq for FnSig<I> {}
1137
1138impl<I: Interner> FnSig<I> {
1139 pub fn inputs(self) -> I::FnInputTys {
1140 self.inputs_and_output.inputs()
1141 }
1142
1143 pub fn output(self) -> I::Ty {
1144 self.inputs_and_output.output()
1145 }
1146
1147 pub fn is_fn_trait_compatible(self) -> bool {
1148 !self.c_variadic() && self.safety().is_safe() && self.abi() == ExternAbi::Rust
1149 }
1150
1151 #[must_use = "this method does not modify the receiver"]
1153 pub fn set_safety(self, safety: I::Safety) -> Self {
1154 Self { fn_sig_kind: self.fn_sig_kind.set_safety(safety), ..self }
1155 }
1156
1157 #[must_use = "this method does not modify the receiver"]
1160 pub fn set_splatted(
1161 self,
1162 splatted: Option<u8>,
1163 args_len: usize,
1164 ) -> Result<Self, SplattedArgIndexError> {
1165 Ok(Self { fn_sig_kind: self.fn_sig_kind.set_splatted(splatted, args_len)?, ..self })
1166 }
1167
1168 pub fn safety(self) -> I::Safety {
1169 self.fn_sig_kind.safety()
1170 }
1171
1172 pub fn abi(self) -> ExternAbi {
1173 self.fn_sig_kind.abi()
1174 }
1175
1176 pub fn c_variadic(self) -> bool {
1177 self.fn_sig_kind.c_variadic()
1178 }
1179
1180 pub fn splatted(self) -> Option<u8> {
1181 self.fn_sig_kind.splatted()
1182 }
1183
1184 pub fn dummy() -> Self {
1187 Self { inputs_and_output: Default::default(), fn_sig_kind: FnSigKind::dummy() }
1188 }
1189}
1190
1191impl<I: Interner> ty::Binder<I, FnSig<I>> {
1192 #[inline]
1193 pub fn inputs(self) -> ty::Binder<I, I::FnInputTys> {
1194 self.map_bound(|fn_sig| fn_sig.inputs())
1195 }
1196
1197 #[inline]
1198 #[track_caller]
1199 pub fn input(self, index: usize) -> ty::Binder<I, I::Ty> {
1200 self.map_bound(|fn_sig| fn_sig.inputs().get(index).unwrap())
1201 }
1202
1203 pub fn inputs_and_output(self) -> ty::Binder<I, I::Tys> {
1204 self.map_bound(|fn_sig| fn_sig.inputs_and_output)
1205 }
1206
1207 #[inline]
1208 pub fn output(self) -> ty::Binder<I, I::Ty> {
1209 self.map_bound(|fn_sig| fn_sig.output())
1210 }
1211
1212 pub fn fn_sig_kind(self) -> FnSigKind<I> {
1213 self.skip_binder().fn_sig_kind
1214 }
1215
1216 pub fn c_variadic(self) -> bool {
1217 self.skip_binder().c_variadic()
1218 }
1219
1220 pub fn splatted(self) -> Option<u8> {
1221 self.skip_binder().splatted()
1222 }
1223
1224 pub fn safety(self) -> I::Safety {
1225 self.skip_binder().safety()
1226 }
1227
1228 pub fn abi(self) -> ExternAbi {
1229 self.skip_binder().abi()
1230 }
1231
1232 pub fn is_fn_trait_compatible(&self) -> bool {
1233 self.skip_binder().is_fn_trait_compatible()
1234 }
1235
1236 pub fn split(self) -> (ty::Binder<I, FnSigTys<I>>, FnHeader<I>) {
1238 let hdr = FnHeader { fn_sig_kind: self.fn_sig_kind() };
1239 (self.map_bound(|sig| FnSigTys { inputs_and_output: sig.inputs_and_output }), hdr)
1240 }
1241}
1242
1243impl<I: Interner> fmt::Debug for FnSig<I> {
1244 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1245 let sig = self;
1246 let FnSig { inputs_and_output: _, fn_sig_kind } = sig;
1247
1248 f.write_fmt(format_args!("{0}", fn_sig_kind.safety().prefix_str()))write!(f, "{}", fn_sig_kind.safety().prefix_str())?;
1249 if fn_sig_kind.abi() != ExternAbi::Rust {
1250 f.write_fmt(format_args!("extern \"{0:?}\" ", fn_sig_kind.abi()))write!(f, "extern \"{:?}\" ", fn_sig_kind.abi())?;
1251 }
1252
1253 f.write_fmt(format_args!("fn("))write!(f, "fn(")?;
1254 let inputs = sig.inputs();
1255 for (i, ty) in inputs.iter().enumerate() {
1256 if i > 0 {
1257 f.write_fmt(format_args!(", "))write!(f, ", ")?;
1258 }
1259 if Some(i) == fn_sig_kind.splatted().map(usize::from) {
1260 f.write_fmt(format_args!("#[rustc_splat] "))write!(f, "#[rustc_splat] ")?;
1261 }
1262 f.write_fmt(format_args!("{0:?}", ty))write!(f, "{ty:?}")?;
1263 }
1264 if fn_sig_kind.c_variadic() {
1265 if inputs.is_empty() {
1266 f.write_fmt(format_args!("..."))write!(f, "...")?;
1267 } else {
1268 f.write_fmt(format_args!(", ..."))write!(f, ", ...")?;
1269 }
1270 }
1271 f.write_fmt(format_args!(")"))write!(f, ")")?;
1272
1273 let output = sig.output();
1274 match output.kind() {
1275 Tuple(list) if list.is_empty() => Ok(()),
1276 _ => f.write_fmt(format_args!(" -> {0:?}", sig.output()))write!(f, " -> {:?}", sig.output()),
1277 }
1278 }
1279}
1280
1281#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for UnsafeBinderInner<I> where
I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for UnsafeBinderInner<I> where
I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for UnsafeBinderInner<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(UnsafeBinderInner(ref __field_0),
UnsafeBinderInner(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for UnsafeBinderInner<I> where
I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
UnsafeBinderInner(ref __field_0) => {
::core::hash::Hash::hash(__field_0, __state);
}
}
}
}#[derive_where(Clone, Copy, PartialEq, Hash; I: Interner)]
1284#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
UnsafeBinderInner<I> where
ty::Binder<I,
I::Ty>: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
UnsafeBinderInner(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext))]
1285#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
UnsafeBinderInner<I> where I: Interner,
ty::Binder<I, I::Ty>: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
UnsafeBinderInner(ref __binding_0) => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for
UnsafeBinderInner<I> where
ty::Binder<I, I::Ty>: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
UnsafeBinderInner(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
UnsafeBinderInner<I> where I: Interner,
ty::Binder<I, I::Ty>: ::rustc_type_ir::TypeFoldable<I> {
fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
UnsafeBinderInner(__binding_0) => {
UnsafeBinderInner(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
UnsafeBinderInner(__binding_0) => {
UnsafeBinderInner(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder))
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
UnsafeBinderInner<I> where J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
type Lifted = UnsafeBinderInner<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
UnsafeBinderInner(__binding_0) => {
UnsafeBinderInner(__binding_0.lift_to_interner(interner))
}
}
}
}
};Lift_Generic)]
1286pub struct UnsafeBinderInner<I: Interner>(ty::Binder<I, I::Ty>);
1287
1288impl<I: Interner> Eq for UnsafeBinderInner<I> {}
1289
1290impl<I: Interner> From<ty::Binder<I, I::Ty>> for UnsafeBinderInner<I> {
1291 fn from(value: ty::Binder<I, I::Ty>) -> Self {
1292 UnsafeBinderInner(value)
1293 }
1294}
1295
1296impl<I: Interner> From<UnsafeBinderInner<I>> for ty::Binder<I, I::Ty> {
1297 fn from(value: UnsafeBinderInner<I>) -> Self {
1298 value.0
1299 }
1300}
1301
1302impl<I: Interner> fmt::Debug for UnsafeBinderInner<I> {
1303 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1304 self.0.fmt(f)
1305 }
1306}
1307
1308impl<I: Interner> Deref for UnsafeBinderInner<I> {
1309 type Target = ty::Binder<I, I::Ty>;
1310
1311 fn deref(&self) -> &Self::Target {
1312 &self.0
1313 }
1314}
1315
1316#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for FnSigTys<I> where I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for FnSigTys<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for FnSigTys<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
FnSigTys { inputs_and_output: ref __field_inputs_and_output } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "FnSigTys");
::core::fmt::DebugStruct::field(&mut __builder,
"inputs_and_output", __field_inputs_and_output);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for FnSigTys<I> where I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(FnSigTys { inputs_and_output: ref __field_inputs_and_output },
FnSigTys {
inputs_and_output: ref __other_field_inputs_and_output }) =>
true &&
::core::cmp::PartialEq::eq(__field_inputs_and_output,
__other_field_inputs_and_output),
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for FnSigTys<I> where I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
FnSigTys { inputs_and_output: ref __field_inputs_and_output } => {
::core::hash::Hash::hash(__field_inputs_and_output, __state);
}
}
}
}#[derive_where(Clone, Copy, Debug, PartialEq, Hash; I: Interner)]
1318#[cfg_attr(
1319 feature = "nightly",
1320 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for FnSigTys<I> where
I::Tys: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let FnSigTys { inputs_and_output: ref __binding_0 } = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for FnSigTys<I> where
I::Tys: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
FnSigTys {
inputs_and_output: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
FnSigTys<I> where
I::Tys: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
FnSigTys { inputs_and_output: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
1321)]
1322#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for FnSigTys<I>
where I: Interner, I::Tys: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
FnSigTys { inputs_and_output: ref __binding_0 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for FnSigTys<I> where
I::Tys: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
FnSigTys { inputs_and_output: 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 FnSigTys<I>
where I: Interner, I::Tys: ::rustc_type_ir::TypeFoldable<I> {
fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
FnSigTys { inputs_and_output: __binding_0 } => {
FnSigTys {
inputs_and_output: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
FnSigTys { inputs_and_output: __binding_0 } => {
FnSigTys {
inputs_and_output: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for FnSigTys<I>
where J: Interner, I: ::rustc_type_ir::LiftInto<J> {
type Lifted = FnSigTys<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
FnSigTys { inputs_and_output: __binding_0 } => {
FnSigTys {
inputs_and_output: __binding_0.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
1323pub struct FnSigTys<I: Interner> {
1324 pub inputs_and_output: I::Tys,
1325}
1326
1327impl<I: Interner> Eq for FnSigTys<I> {}
1328
1329impl<I: Interner> FnSigTys<I> {
1330 pub fn inputs(self) -> I::FnInputTys {
1331 self.inputs_and_output.inputs()
1332 }
1333
1334 pub fn output(self) -> I::Ty {
1335 self.inputs_and_output.output()
1336 }
1337}
1338
1339impl<I: Interner> ty::Binder<I, FnSigTys<I>> {
1340 pub fn with(self, hdr: FnHeader<I>) -> ty::Binder<I, FnSig<I>> {
1342 self.map_bound(|sig_tys| FnSig {
1343 inputs_and_output: sig_tys.inputs_and_output,
1344 fn_sig_kind: hdr.fn_sig_kind,
1345 })
1346 }
1347
1348 #[inline]
1349 pub fn inputs(self) -> ty::Binder<I, I::FnInputTys> {
1350 self.map_bound(|sig_tys| sig_tys.inputs())
1351 }
1352
1353 #[inline]
1354 #[track_caller]
1355 pub fn input(self, index: usize) -> ty::Binder<I, I::Ty> {
1356 self.map_bound(|sig_tys| sig_tys.inputs().get(index).unwrap())
1357 }
1358
1359 pub fn inputs_and_output(self) -> ty::Binder<I, I::Tys> {
1360 self.map_bound(|sig_tys| sig_tys.inputs_and_output)
1361 }
1362
1363 #[inline]
1364 pub fn output(self) -> ty::Binder<I, I::Ty> {
1365 self.map_bound(|sig_tys| sig_tys.output())
1366 }
1367}
1368
1369#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for FnHeader<I> where I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for FnHeader<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for FnHeader<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
FnHeader { fn_sig_kind: ref __field_fn_sig_kind } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "FnHeader");
::core::fmt::DebugStruct::field(&mut __builder, "fn_sig_kind",
__field_fn_sig_kind);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for FnHeader<I> where I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(FnHeader { fn_sig_kind: ref __field_fn_sig_kind }, FnHeader {
fn_sig_kind: ref __other_field_fn_sig_kind }) =>
true &&
::core::cmp::PartialEq::eq(__field_fn_sig_kind,
__other_field_fn_sig_kind),
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for FnHeader<I> where I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
FnHeader { fn_sig_kind: ref __field_fn_sig_kind } => {
::core::hash::Hash::hash(__field_fn_sig_kind, __state);
}
}
}
}#[derive_where(Clone, Copy, Debug, PartialEq, Hash; I: Interner)]
1370#[cfg_attr(
1371 feature = "nightly",
1372 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for FnHeader<I> where
FnSigKind<I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let FnHeader { fn_sig_kind: ref __binding_0 } = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for FnHeader<I> where
FnSigKind<I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
FnHeader {
fn_sig_kind: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
FnHeader<I> where
FnSigKind<I>: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
FnHeader { fn_sig_kind: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
1373)]
1374#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for FnHeader<I>
where I: Interner {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self { FnHeader { .. } => {} }
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for FnHeader<I> where
FnSigKind<I>: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
FnHeader { fn_sig_kind: 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 FnHeader<I>
where I: Interner {
fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
FnHeader { fn_sig_kind: __binding_0 } => {
FnHeader { fn_sig_kind: __binding_0 }
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
FnHeader { fn_sig_kind: __binding_0 } => {
FnHeader { fn_sig_kind: __binding_0 }
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for FnHeader<I>
where J: Interner, I: ::rustc_type_ir::LiftInto<J> {
type Lifted = FnHeader<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
FnHeader { fn_sig_kind: __binding_0 } => {
FnHeader {
fn_sig_kind: __binding_0.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
1375pub struct FnHeader<I: Interner> {
1376 #[type_visitable(ignore)]
1377 #[type_foldable(identity)]
1378 pub fn_sig_kind: FnSigKind<I>,
1379}
1380
1381impl<I: Interner> FnHeader<I> {
1382 pub fn c_variadic(self) -> bool {
1383 self.fn_sig_kind.c_variadic()
1384 }
1385
1386 pub fn safety(self) -> I::Safety {
1387 self.fn_sig_kind.safety()
1388 }
1389
1390 pub fn abi(self) -> ExternAbi {
1391 self.fn_sig_kind.abi()
1392 }
1393
1394 pub fn splatted(self) -> Option<u8> {
1395 self.fn_sig_kind.splatted()
1396 }
1397
1398 pub fn dummy() -> Self {
1400 Self { fn_sig_kind: FnSigKind::dummy() }
1401 }
1402}
1403
1404impl<I: Interner> Eq for FnHeader<I> {}
1405
1406#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for CoroutineWitnessTypes<I> where
I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for CoroutineWitnessTypes<I> where
I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for CoroutineWitnessTypes<I> where
I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
CoroutineWitnessTypes {
types: ref __field_types, assumptions: ref __field_assumptions
} => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f,
"CoroutineWitnessTypes");
::core::fmt::DebugStruct::field(&mut __builder, "types",
__field_types);
::core::fmt::DebugStruct::field(&mut __builder, "assumptions",
__field_assumptions);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for CoroutineWitnessTypes<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(CoroutineWitnessTypes {
types: ref __field_types, assumptions: ref __field_assumptions
}, CoroutineWitnessTypes {
types: ref __other_field_types,
assumptions: ref __other_field_assumptions }) =>
true &&
::core::cmp::PartialEq::eq(__field_types,
__other_field_types) &&
::core::cmp::PartialEq::eq(__field_assumptions,
__other_field_assumptions),
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for CoroutineWitnessTypes<I> where
I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
CoroutineWitnessTypes {
types: ref __field_types, assumptions: ref __field_assumptions
} => {
::core::hash::Hash::hash(__field_types, __state);
::core::hash::Hash::hash(__field_assumptions, __state);
}
}
}
}#[derive_where(Clone, Copy, Debug, PartialEq, Hash; I: Interner)]
1407#[cfg_attr(
1408 feature = "nightly",
1409 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for CoroutineWitnessTypes<I>
where I::Tys: ::rustc_serialize::Encodable<__E>,
I::RegionAssumptions: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let CoroutineWitnessTypes {
types: ref __binding_0, assumptions: ref __binding_1 } =
*self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for CoroutineWitnessTypes<I>
where I::Tys: ::rustc_serialize::Decodable<__D>,
I::RegionAssumptions: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
CoroutineWitnessTypes {
types: ::rustc_serialize::Decodable::decode(__decoder),
assumptions: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
CoroutineWitnessTypes<I> where
I::Tys: ::rustc_data_structures::stable_hash::StableHash,
I::RegionAssumptions: ::rustc_data_structures::stable_hash::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
CoroutineWitnessTypes {
types: ref __binding_0, assumptions: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
1410)]
1411#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
CoroutineWitnessTypes<I> where I: Interner,
I::Tys: ::rustc_type_ir::TypeVisitable<I>,
I::RegionAssumptions: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
CoroutineWitnessTypes {
types: ref __binding_0, assumptions: ref __binding_1 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for
CoroutineWitnessTypes<I> where
I::Tys: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::RegionAssumptions: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
CoroutineWitnessTypes {
types: ref __binding_0, assumptions: 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);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
CoroutineWitnessTypes<I> where I: Interner,
I::Tys: ::rustc_type_ir::TypeFoldable<I>,
I::RegionAssumptions: ::rustc_type_ir::TypeFoldable<I> {
fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
CoroutineWitnessTypes {
types: __binding_0, assumptions: __binding_1 } => {
CoroutineWitnessTypes {
types: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
assumptions: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
CoroutineWitnessTypes {
types: __binding_0, assumptions: __binding_1 } => {
CoroutineWitnessTypes {
types: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
assumptions: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
CoroutineWitnessTypes<I> where J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
type Lifted = CoroutineWitnessTypes<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
CoroutineWitnessTypes {
types: __binding_0, assumptions: __binding_1 } => {
CoroutineWitnessTypes {
types: __binding_0.lift_to_interner(interner),
assumptions: __binding_1.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
1412pub struct CoroutineWitnessTypes<I: Interner> {
1413 pub types: I::Tys,
1414 pub assumptions: I::RegionAssumptions,
1415}
1416
1417impl<I: Interner> Eq for CoroutineWitnessTypes<I> {}