1use std::fmt;
2use std::ops::Deref;
3
4use derive_where::derive_where;
5use rustc_ast_ir::Mutability;
6#[cfg(feature = "nightly")]
7use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
8#[cfg(feature = "nightly")]
9use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
10use rustc_type_ir::data_structures::{NoError, UnifyKey, UnifyValue};
11use rustc_type_ir_macros::{
12 GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic,
13};
14
15use self::TyKind::*;
16pub use self::closure::*;
17use crate::inherent::*;
18#[cfg(feature = "nightly")]
19use crate::visit::TypeVisitable;
20use crate::{self as ty, BoundVarIndexKind, FloatTy, IntTy, Interner, UintTy};
21
22mod closure;
23
24#[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, Debug; I: Interner)]
25#[derive(GenericTypeVisitable, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for AliasTyKind<I>
where I: Interner, J: Interner,
I::DefId: ::rustc_type_ir::lift::Lift<J, Lifted = J::DefId>,
I::DefId: ::rustc_type_ir::lift::Lift<J, Lifted = J::DefId>,
I::DefId: ::rustc_type_ir::lift::Lift<J, Lifted = J::DefId>,
I::DefId: ::rustc_type_ir::lift::Lift<J, Lifted = J::DefId> {
type Lifted = AliasTyKind<J>;
fn lift_to_interner(self, interner: J) -> Option<Self::Lifted> {
Some(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)]
26#[cfg_attr(
27 feature = "nightly",
28 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for AliasTyKind<I> where
I::DefId: ::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::DefId: ::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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
AliasTyKind<I> where
I::DefId: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
AliasTyKind::Projection { def_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
AliasTyKind::Inherent { def_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
AliasTyKind::Opaque { def_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
AliasTyKind::Free { def_id: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_NoContext)
29)]
30pub enum AliasTyKind<I: Interner> {
31 Projection { def_id: I::DefId },
41
42 Inherent { def_id: I::DefId },
46
47 Opaque { def_id: I::DefId },
57
58 Free { def_id: I::DefId },
63}
64
65impl<I: Interner> AliasTyKind<I> {
66 pub fn new_from_def_id(interner: I, def_id: I::DefId) -> Self {
67 interner.alias_ty_kind_from_def_id(def_id)
68 }
69
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 def_id(self) -> I::DefId {
80 let (AliasTyKind::Projection { def_id }
81 | AliasTyKind::Inherent { def_id }
82 | AliasTyKind::Opaque { def_id }
83 | AliasTyKind::Free { def_id }) = self;
84
85 def_id
86 }
87}
88
89#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "IrTyKind")]
94#[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),
TyKind::Alias(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(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)]
95#[derive(GenericTypeVisitable)]
96#[cfg_attr(
97 feature = "nightly",
98 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>,
I::Region: ::rustc_serialize::Encodable<__E>,
I::FunctionId: ::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) => { 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) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__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>,
I::Region: ::rustc_serialize::Decodable<__D>,
I::FunctionId: ::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))
}
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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TyKind<I> where
I::AdtDef: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::GenericArgs: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::ForeignId: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::Ty: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::Const: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::Pat: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::Region: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::FunctionId: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
ty::Binder<I,
FnSigTys<I>>: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
FnHeader<I>: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
UnsafeBinderInner<I>: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::BoundExistentialPredicates: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::ClosureId: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::CoroutineClosureId: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::CoroutineId: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::Tys: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
AliasTy<I>: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::ParamTy: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
ty::BoundTy<I>: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
ty::PlaceholderType<I>: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::ErrorGuaranteed: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
TyKind::Bool => {}
TyKind::Char => {}
TyKind::Int(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Uint(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Float(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Adt(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Foreign(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Str => {}
TyKind::Array(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Pat(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Slice(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::RawPtr(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Ref(ref __binding_0, ref __binding_1,
ref __binding_2) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
TyKind::FnDef(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::FnPtr(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::UnsafeBinder(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Dynamic(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Closure(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::CoroutineClosure(ref __binding_0, ref __binding_1)
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Coroutine(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::CoroutineWitness(ref __binding_0, ref __binding_1)
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Never => {}
TyKind::Tuple(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Alias(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Param(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Bound(ref __binding_0, ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
TyKind::Placeholder(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Infer(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
TyKind::Error(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_NoContext)
99)]
100pub enum TyKind<I: Interner> {
101 Bool,
103
104 Char,
107
108 Int(IntTy),
110
111 Uint(UintTy),
113
114 Float(FloatTy),
116
117 Adt(I::AdtDef, I::GenericArgs),
125
126 Foreign(I::ForeignId),
128
129 Str,
131
132 Array(I::Ty, I::Const),
134
135 Pat(I::Ty, I::Pat),
143
144 Slice(I::Ty),
146
147 RawPtr(I::Ty, Mutability),
149
150 Ref(I::Region, I::Ty, Mutability),
153
154 FnDef(I::FunctionId, I::GenericArgs),
167
168 FnPtr(ty::Binder<I, FnSigTys<I>>, FnHeader<I>),
187
188 UnsafeBinder(UnsafeBinderInner<I>),
194
195 Dynamic(I::BoundExistentialPredicates, I::Region),
197
198 Closure(I::ClosureId, I::GenericArgs),
204
205 CoroutineClosure(I::CoroutineClosureId, I::GenericArgs),
211
212 Coroutine(I::CoroutineId, I::GenericArgs),
218
219 CoroutineWitness(I::CoroutineId, I::GenericArgs),
244
245 Never,
247
248 Tuple(I::Tys),
250
251 Alias(AliasTy<I>),
256
257 Param(I::ParamTy),
259
260 Bound(BoundVarIndexKind, ty::BoundTy<I>),
277
278 Placeholder(ty::PlaceholderType<I>),
287
288 Infer(InferTy),
295
296 Error(I::ErrorGuaranteed),
300}
301
302impl<I: Interner> Eq for TyKind<I> {}
303
304impl<I: Interner> TyKind<I> {
305 pub fn fn_sig(self, interner: I) -> ty::Binder<I, ty::FnSig<I>> {
306 match self {
307 ty::FnPtr(sig_tys, hdr) => sig_tys.with(hdr),
308 ty::FnDef(def_id, args) => interner.fn_sig(def_id).instantiate(interner, args),
309 ty::Error(_) => {
310 ty::Binder::dummy(ty::FnSig {
312 inputs_and_output: Default::default(),
313 c_variadic: false,
314 safety: I::Safety::safe(),
315 abi: I::Abi::rust(),
316 })
317 }
318 ty::Closure(..) => {
::core::panicking::panic_fmt(format_args!("to get the signature of a closure, use `args.as_closure().sig()` not `fn_sig()`"));
}panic!(
319 "to get the signature of a closure, use `args.as_closure().sig()` not `fn_sig()`",
320 ),
321 _ => {
::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),
322 }
323 }
324
325 pub fn is_known_rigid(self) -> bool {
333 match self {
334 ty::Bool
335 | ty::Char
336 | ty::Int(_)
337 | ty::Uint(_)
338 | ty::Float(_)
339 | ty::Adt(_, _)
340 | ty::Foreign(_)
341 | ty::Str
342 | ty::Array(_, _)
343 | ty::Pat(_, _)
344 | ty::Slice(_)
345 | ty::RawPtr(_, _)
346 | ty::Ref(_, _, _)
347 | ty::FnDef(_, _)
348 | ty::FnPtr(..)
349 | ty::UnsafeBinder(_)
350 | ty::Dynamic(_, _)
351 | ty::Closure(_, _)
352 | ty::CoroutineClosure(_, _)
353 | ty::Coroutine(_, _)
354 | ty::CoroutineWitness(..)
355 | ty::Never
356 | ty::Tuple(_) => true,
357
358 ty::Error(_)
359 | ty::Infer(_)
360 | ty::Alias(_)
361 | ty::Param(_)
362 | ty::Bound(_, _)
363 | ty::Placeholder(_) => false,
364 }
365 }
366}
367
368impl<I: Interner> fmt::Debug for TyKind<I> {
370 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
371 match self {
372 Bool => f.write_fmt(format_args!("bool"))write!(f, "bool"),
373 Char => f.write_fmt(format_args!("char"))write!(f, "char"),
374 Int(i) => f.write_fmt(format_args!("{0:?}", i))write!(f, "{i:?}"),
375 Uint(u) => f.write_fmt(format_args!("{0:?}", u))write!(f, "{u:?}"),
376 Float(float) => f.write_fmt(format_args!("{0:?}", float))write!(f, "{float:?}"),
377 Adt(d, s) => {
378 f.write_fmt(format_args!("{0:?}", d))write!(f, "{d:?}")?;
379 let mut s = s.iter();
380 let first = s.next();
381 match first {
382 Some(first) => f.write_fmt(format_args!("<{0:?}", first))write!(f, "<{:?}", first)?,
383 None => return Ok(()),
384 };
385
386 for arg in s {
387 f.write_fmt(format_args!(", {0:?}", arg))write!(f, ", {:?}", arg)?;
388 }
389
390 f.write_fmt(format_args!(">"))write!(f, ">")
391 }
392 Foreign(d) => f.debug_tuple("Foreign").field(d).finish(),
393 Str => f.write_fmt(format_args!("str"))write!(f, "str"),
394 Array(t, c) => f.write_fmt(format_args!("[{0:?}; {1:?}]", t, c))write!(f, "[{t:?}; {c:?}]"),
395 Pat(t, p) => f.write_fmt(format_args!("pattern_type!({0:?} is {1:?})", t, p))write!(f, "pattern_type!({t:?} is {p:?})"),
396 Slice(t) => f.write_fmt(format_args!("[{0:?}]", &t))write!(f, "[{:?}]", &t),
397 RawPtr(ty, mutbl) => f.write_fmt(format_args!("*{0} {1:?}", mutbl.ptr_str(), ty))write!(f, "*{} {:?}", mutbl.ptr_str(), ty),
398 Ref(r, t, m) => f.write_fmt(format_args!("&{0:?} {1}{2:?}", r, m.prefix_str(), t))write!(f, "&{:?} {}{:?}", r, m.prefix_str(), t),
399 FnDef(d, s) => f.debug_tuple("FnDef").field(d).field(&s).finish(),
400 FnPtr(sig_tys, hdr) => f.write_fmt(format_args!("{0:?}", sig_tys.with(*hdr)))write!(f, "{:?}", sig_tys.with(*hdr)),
401 UnsafeBinder(binder) => f.write_fmt(format_args!("{0:?}", binder))write!(f, "{:?}", binder),
403 Dynamic(p, r) => f.write_fmt(format_args!("dyn {0:?} + {1:?}", p, r))write!(f, "dyn {p:?} + {r:?}"),
404 Closure(d, s) => f.debug_tuple("Closure").field(d).field(&s).finish(),
405 CoroutineClosure(d, s) => f.debug_tuple("CoroutineClosure").field(d).field(&s).finish(),
406 Coroutine(d, s) => f.debug_tuple("Coroutine").field(d).field(&s).finish(),
407 CoroutineWitness(d, s) => f.debug_tuple("CoroutineWitness").field(d).field(&s).finish(),
408 Never => f.write_fmt(format_args!("!"))write!(f, "!"),
409 Tuple(t) => {
410 f.write_fmt(format_args!("("))write!(f, "(")?;
411 let mut count = 0;
412 for ty in t.iter() {
413 if count > 0 {
414 f.write_fmt(format_args!(", "))write!(f, ", ")?;
415 }
416 f.write_fmt(format_args!("{0:?}", ty))write!(f, "{ty:?}")?;
417 count += 1;
418 }
419 if count == 1 {
421 f.write_fmt(format_args!(","))write!(f, ",")?;
422 }
423 f.write_fmt(format_args!(")"))write!(f, ")")
424 }
425 Alias(a) => f.debug_tuple("Alias").field(&a).finish(),
426 Param(p) => f.write_fmt(format_args!("{0:?}", p))write!(f, "{p:?}"),
427 Bound(d, b) => crate::debug_bound_var(f, *d, b),
428 Placeholder(p) => f.write_fmt(format_args!("{0:?}", p))write!(f, "{p:?}"),
429 Infer(t) => f.write_fmt(format_args!("{0:?}", t))write!(f, "{:?}", t),
430 TyKind::Error(_) => f.write_fmt(format_args!("{{type error}}"))write!(f, "{{type error}}"),
431 }
432 }
433}
434
435#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for AliasTy<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
AliasTy {
args: ref __field_args,
kind: ref __field_kind,
_use_alias_ty_new_instead: ref __field__use_alias_ty_new_instead
} => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "AliasTy");
::core::fmt::DebugStruct::field(&mut __builder, "args",
__field_args);
::core::fmt::DebugStruct::field(&mut __builder, "kind",
__field_kind);
::core::fmt::DebugStruct::finish_non_exhaustive(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
441#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for AliasTy<I>
where I: Interner,
I::GenericArgs: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
AliasTy {
args: ref __binding_0,
_use_alias_ty_new_instead: ref __binding_2, .. } => {
{
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_2,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for AliasTy<I>
where I: Interner,
I::GenericArgs: ::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 {
AliasTy {
args: __binding_0,
kind: __binding_1,
_use_alias_ty_new_instead: __binding_2 } => {
AliasTy {
args: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
kind: __binding_1,
_use_alias_ty_new_instead: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
AliasTy {
args: __binding_0,
kind: __binding_1,
_use_alias_ty_new_instead: __binding_2 } => {
AliasTy {
args: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
kind: __binding_1,
_use_alias_ty_new_instead: ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for AliasTy<I>
where I: Interner, J: Interner,
I::GenericArgs: ::rustc_type_ir::lift::Lift<J, Lifted =
J::GenericArgs>,
AliasTyKind<I>: ::rustc_type_ir::lift::Lift<J, Lifted =
AliasTyKind<J>>, (): ::rustc_type_ir::lift::Lift<J, Lifted = ()> {
type Lifted = AliasTy<J>;
fn lift_to_interner(self, interner: J) -> Option<Self::Lifted> {
Some(match self {
AliasTy {
args: __binding_0,
kind: __binding_1,
_use_alias_ty_new_instead: __binding_2 } => {
AliasTy {
args: __binding_0.lift_to_interner(interner)?,
kind: __binding_1.lift_to_interner(interner)?,
_use_alias_ty_new_instead: __binding_2.lift_to_interner(interner)?,
}
}
})
}
}
};Lift_Generic)]
442#[cfg_attr(
443 feature = "nightly",
444 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for AliasTy<I> where
I::GenericArgs: ::rustc_serialize::Decodable<__D>,
AliasTyKind<I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
AliasTy {
args: ::rustc_serialize::Decodable::decode(__decoder),
kind: ::rustc_serialize::Decodable::decode(__decoder),
_use_alias_ty_new_instead: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for AliasTy<I> where
I::GenericArgs: ::rustc_serialize::Encodable<__E>,
AliasTyKind<I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
AliasTy {
args: ref __binding_0,
kind: ref __binding_1,
_use_alias_ty_new_instead: 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);
}
}
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
AliasTy<I> where
I::GenericArgs: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
AliasTyKind<I>: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
AliasTy {
args: ref __binding_0,
kind: ref __binding_1,
_use_alias_ty_new_instead: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_NoContext)
445)]
446pub struct AliasTy<I: Interner> {
447 pub args: I::GenericArgs,
458
459 #[type_foldable(identity)]
460 #[type_visitable(ignore)]
461 pub kind: AliasTyKind<I>,
462
463 #[derive_where(skip(Debug))]
465 pub(crate) _use_alias_ty_new_instead: (),
466}
467
468impl<I: Interner> Eq for AliasTy<I> {}
469
470impl<I: Interner> AliasTy<I> {
471 pub fn new_from_args(interner: I, kind: AliasTyKind<I>, args: I::GenericArgs) -> AliasTy<I> {
472 interner.debug_assert_args_compatible(kind.def_id(), args);
473 AliasTy { kind, args, _use_alias_ty_new_instead: () }
474 }
475
476 pub fn new(
477 interner: I,
478 kind: AliasTyKind<I>,
479 args: impl IntoIterator<Item: Into<I::GenericArg>>,
480 ) -> AliasTy<I> {
481 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
482 Self::new_from_args(interner, kind, args)
483 }
484
485 pub fn is_opaque(self) -> bool {
487 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
AliasTyKind::Opaque { .. } => true,
_ => false,
}matches!(self.kind, AliasTyKind::Opaque { .. })
488 }
489
490 pub fn to_ty(self, interner: I) -> I::Ty {
491 Ty::new_alias(interner, self)
492 }
493}
494
495impl<I: Interner> AliasTy<I> {
497 #[track_caller]
498 pub fn self_ty(self) -> I::Ty {
499 self.args.type_at(0)
500 }
501
502 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
503 AliasTy::new(
504 interner,
505 self.kind,
506 [self_ty.into()].into_iter().chain(self.args.iter().skip(1)),
507 )
508 }
509
510 pub fn trait_def_id(self, interner: I) -> I::DefId {
511 let AliasTyKind::Projection { def_id } = self.kind else { { ::core::panicking::panic_fmt(format_args!("expected a projection")); }panic!("expected a projection") };
512
513 interner.parent(def_id)
514 }
515
516 pub fn trait_ref_and_own_args(self, interner: I) -> (ty::TraitRef<I>, I::GenericArgsSlice) {
522 let AliasTyKind::Projection { def_id } = self.kind else { { ::core::panicking::panic_fmt(format_args!("expected a projection")); }panic!("expected a projection") };
523
524 interner.trait_ref_and_own_args_for_alias(def_id, self.args)
525 }
526
527 pub fn trait_ref(self, interner: I) -> ty::TraitRef<I> {
536 self.trait_ref_and_own_args(interner).0
537 }
538}
539
540#[derive(#[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::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)]
541pub enum IntVarValue {
542 Unknown,
543 IntType(IntTy),
544 UintType(UintTy),
545}
546
547impl IntVarValue {
548 pub fn is_known(self) -> bool {
549 match self {
550 IntVarValue::IntType(_) | IntVarValue::UintType(_) => true,
551 IntVarValue::Unknown => false,
552 }
553 }
554
555 pub fn is_unknown(self) -> bool {
556 !self.is_known()
557 }
558}
559
560#[derive(#[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::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)]
561pub enum FloatVarValue {
562 Unknown,
563 Known(FloatTy),
564}
565
566impl FloatVarValue {
567 pub fn is_known(self) -> bool {
568 match self {
569 FloatVarValue::Known(_) => true,
570 FloatVarValue::Unknown => false,
571 }
572 }
573
574 pub fn is_unknown(self) -> bool {
575 !self.is_known()
576 }
577}
578
579impl ::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! {
580 #[encodable]
582 #[orderable]
583 #[debug_format = "?{}t"]
584 #[gate_rustc_only]
585 pub struct TyVid {}
586}
587
588impl ::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! {
589 #[encodable]
591 #[orderable]
592 #[debug_format = "?{}i"]
593 #[gate_rustc_only]
594 pub struct IntVid {}
595}
596
597impl ::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! {
598 #[encodable]
600 #[orderable]
601 #[debug_format = "?{}f"]
602 #[gate_rustc_only]
603 pub struct FloatVid {}
604}
605
606#[derive(#[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::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> {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
match (self, other) {
(InferTy::TyVar(__self_0), InferTy::TyVar(__arg1_0)) =>
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
(InferTy::IntVar(__self_0), InferTy::IntVar(__arg1_0)) =>
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
(InferTy::FloatVar(__self_0), InferTy::FloatVar(__arg1_0)) =>
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
(InferTy::FreshTy(__self_0), InferTy::FreshTy(__arg1_0)) =>
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
(InferTy::FreshIntTy(__self_0), InferTy::FreshIntTy(__arg1_0)) =>
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
(InferTy::FreshFloatTy(__self_0), InferTy::FreshFloatTy(__arg1_0))
=> ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
_ =>
::core::cmp::PartialOrd::partial_cmp(&__self_discr,
&__arg1_discr),
}
}
}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)]
612#[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))]
613pub enum InferTy {
614 TyVar(TyVid),
616 IntVar(IntVid),
623 FloatVar(FloatVid),
630
631 FreshTy(u32),
638 FreshIntTy(u32),
640 FreshFloatTy(u32),
642}
643
644impl UnifyValue for IntVarValue {
645 type Error = NoError;
646
647 fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
648 match (*value1, *value2) {
649 (IntVarValue::Unknown, IntVarValue::Unknown) => Ok(IntVarValue::Unknown),
650 (
651 IntVarValue::Unknown,
652 known @ (IntVarValue::UintType(_) | IntVarValue::IntType(_)),
653 )
654 | (
655 known @ (IntVarValue::UintType(_) | IntVarValue::IntType(_)),
656 IntVarValue::Unknown,
657 ) => Ok(known),
658 _ => {
::core::panicking::panic_fmt(format_args!("differing ints should have been resolved first"));
}panic!("differing ints should have been resolved first"),
659 }
660 }
661}
662
663impl UnifyKey for IntVid {
664 type Value = IntVarValue;
665 #[inline] fn index(&self) -> u32 {
667 self.as_u32()
668 }
669 #[inline]
670 fn from_index(i: u32) -> IntVid {
671 IntVid::from_u32(i)
672 }
673 fn tag() -> &'static str {
674 "IntVid"
675 }
676}
677
678impl UnifyValue for FloatVarValue {
679 type Error = NoError;
680
681 fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
682 match (*value1, *value2) {
683 (FloatVarValue::Unknown, FloatVarValue::Unknown) => Ok(FloatVarValue::Unknown),
684 (FloatVarValue::Unknown, FloatVarValue::Known(known))
685 | (FloatVarValue::Known(known), FloatVarValue::Unknown) => {
686 Ok(FloatVarValue::Known(known))
687 }
688 (FloatVarValue::Known(_), FloatVarValue::Known(_)) => {
689 {
::core::panicking::panic_fmt(format_args!("differing floats should have been resolved first"));
}panic!("differing floats should have been resolved first")
690 }
691 }
692 }
693}
694
695impl UnifyKey for FloatVid {
696 type Value = FloatVarValue;
697 #[inline]
698 fn index(&self) -> u32 {
699 self.as_u32()
700 }
701 #[inline]
702 fn from_index(i: u32) -> FloatVid {
703 FloatVid::from_u32(i)
704 }
705 fn tag() -> &'static str {
706 "FloatVid"
707 }
708}
709
710#[cfg(feature = "nightly")]
711impl<Hcx> HashStable<Hcx> for InferTy {
712 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
713 use InferTy::*;
714 std::mem::discriminant(self).hash_stable(hcx, hasher);
715 match self {
716 TyVar(_) | IntVar(_) | FloatVar(_) => {
717 {
::core::panicking::panic_fmt(format_args!("type variables should not be hashed: {0:?}",
self));
}panic!("type variables should not be hashed: {self:?}")
718 }
719 FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.hash_stable(hcx, hasher),
720 }
721 }
722}
723
724impl fmt::Display for InferTy {
725 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
726 use InferTy::*;
727 match *self {
728 TyVar(_) => f.write_fmt(format_args!("_"))write!(f, "_"),
729 IntVar(_) => f.write_fmt(format_args!("{0}", "{integer}"))write!(f, "{}", "{integer}"),
730 FloatVar(_) => f.write_fmt(format_args!("{0}", "{float}"))write!(f, "{}", "{float}"),
731 FreshTy(v) => f.write_fmt(format_args!("FreshTy({0})", v))write!(f, "FreshTy({v})"),
732 FreshIntTy(v) => f.write_fmt(format_args!("FreshIntTy({0})", v))write!(f, "FreshIntTy({v})"),
733 FreshFloatTy(v) => f.write_fmt(format_args!("FreshFloatTy({0})", v))write!(f, "FreshFloatTy({v})"),
734 }
735 }
736}
737
738impl fmt::Debug for InferTy {
739 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
740 use InferTy::*;
741 match *self {
742 TyVar(ref v) => v.fmt(f),
743 IntVar(ref v) => v.fmt(f),
744 FloatVar(ref v) => v.fmt(f),
745 FreshTy(v) => f.write_fmt(format_args!("FreshTy({0:?})", v))write!(f, "FreshTy({v:?})"),
746 FreshIntTy(v) => f.write_fmt(format_args!("FreshIntTy({0:?})", v))write!(f, "FreshIntTy({v:?})"),
747 FreshFloatTy(v) => f.write_fmt(format_args!("FreshFloatTy({0:?})", v))write!(f, "FreshFloatTy({v:?})"),
748 }
749 }
750}
751
752#[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)]
753#[cfg_attr(
754 feature = "nightly",
755 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) {
match *self {
TypeAndMut { ty: ref __binding_0, mutbl: ref __binding_1 }
=> {
::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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
TypeAndMut<I> where
I::Ty: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TypeAndMut { ty: ref __binding_0, mutbl: ref __binding_1 }
=> {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_NoContext)
756)]
757#[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, 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)]
758pub struct TypeAndMut<I: Interner> {
759 pub ty: I::Ty,
760 pub mutbl: Mutability,
761}
762
763impl<I: Interner> Eq for TypeAndMut<I> {}
764
765#[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,
c_variadic: ref __field_c_variadic,
safety: ref __field_safety,
abi: ref __field_abi } => {
::core::hash::Hash::hash(__field_inputs_and_output, __state);
::core::hash::Hash::hash(__field_c_variadic, __state);
::core::hash::Hash::hash(__field_safety, __state);
::core::hash::Hash::hash(__field_abi, __state);
}
}
}
}#[derive_where(Clone, Copy, PartialEq, Hash; I: Interner)]
766#[cfg_attr(
767 feature = "nightly",
768 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for FnSig<I> where
I::Tys: ::rustc_serialize::Encodable<__E>,
I::Safety: ::rustc_serialize::Encodable<__E>,
I::Abi: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
FnSig {
inputs_and_output: ref __binding_0,
c_variadic: ref __binding_1,
safety: ref __binding_2,
abi: ref __binding_3 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_3,
__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>,
I::Safety: ::rustc_serialize::Decodable<__D>,
I::Abi: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
FnSig {
inputs_and_output: ::rustc_serialize::Decodable::decode(__decoder),
c_variadic: ::rustc_serialize::Decodable::decode(__decoder),
safety: ::rustc_serialize::Decodable::decode(__decoder),
abi: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FnSig<I> where
I::Tys: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::Safety: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::Abi: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FnSig {
inputs_and_output: ref __binding_0,
c_variadic: ref __binding_1,
safety: ref __binding_2,
abi: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_NoContext)
769)]
770#[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,
c_variadic: 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, 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,
c_variadic: __binding_1,
safety: __binding_2,
abi: __binding_3 } => {
FnSig {
inputs_and_output: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
c_variadic: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
safety: __binding_2,
abi: __binding_3,
}
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
FnSig {
inputs_and_output: __binding_0,
c_variadic: __binding_1,
safety: __binding_2,
abi: __binding_3 } => {
FnSig {
inputs_and_output: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
c_variadic: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
safety: __binding_2,
abi: __binding_3,
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for FnSig<I> where
I: Interner, J: Interner,
I::Tys: ::rustc_type_ir::lift::Lift<J, Lifted = J::Tys>,
bool: ::rustc_type_ir::lift::Lift<J, Lifted = bool>,
I::Safety: ::rustc_type_ir::lift::Lift<J, Lifted = J::Safety>,
I::Abi: ::rustc_type_ir::lift::Lift<J, Lifted = J::Abi> {
type Lifted = FnSig<J>;
fn lift_to_interner(self, interner: J) -> Option<Self::Lifted> {
Some(match self {
FnSig {
inputs_and_output: __binding_0,
c_variadic: __binding_1,
safety: __binding_2,
abi: __binding_3 } => {
FnSig {
inputs_and_output: __binding_0.lift_to_interner(interner)?,
c_variadic: __binding_1.lift_to_interner(interner)?,
safety: __binding_2.lift_to_interner(interner)?,
abi: __binding_3.lift_to_interner(interner)?,
}
}
})
}
}
};Lift_Generic)]
771pub struct FnSig<I: Interner> {
772 pub inputs_and_output: I::Tys,
773 pub c_variadic: bool,
774 #[type_visitable(ignore)]
775 #[type_foldable(identity)]
776 pub safety: I::Safety,
777 #[type_visitable(ignore)]
778 #[type_foldable(identity)]
779 pub abi: I::Abi,
780}
781
782impl<I: Interner> Eq for FnSig<I> {}
783
784impl<I: Interner> FnSig<I> {
785 pub fn inputs(self) -> I::FnInputTys {
786 self.inputs_and_output.inputs()
787 }
788
789 pub fn output(self) -> I::Ty {
790 self.inputs_and_output.output()
791 }
792
793 pub fn is_fn_trait_compatible(self) -> bool {
794 let FnSig { safety, abi, c_variadic, .. } = self;
795 !c_variadic && safety.is_safe() && abi.is_rust()
796 }
797}
798
799impl<I: Interner> ty::Binder<I, FnSig<I>> {
800 #[inline]
801 pub fn inputs(self) -> ty::Binder<I, I::FnInputTys> {
802 self.map_bound(|fn_sig| fn_sig.inputs())
803 }
804
805 #[inline]
806 #[track_caller]
807 pub fn input(self, index: usize) -> ty::Binder<I, I::Ty> {
808 self.map_bound(|fn_sig| fn_sig.inputs().get(index).unwrap())
809 }
810
811 pub fn inputs_and_output(self) -> ty::Binder<I, I::Tys> {
812 self.map_bound(|fn_sig| fn_sig.inputs_and_output)
813 }
814
815 #[inline]
816 pub fn output(self) -> ty::Binder<I, I::Ty> {
817 self.map_bound(|fn_sig| fn_sig.output())
818 }
819
820 pub fn c_variadic(self) -> bool {
821 self.skip_binder().c_variadic
822 }
823
824 pub fn safety(self) -> I::Safety {
825 self.skip_binder().safety
826 }
827
828 pub fn abi(self) -> I::Abi {
829 self.skip_binder().abi
830 }
831
832 pub fn is_fn_trait_compatible(&self) -> bool {
833 self.skip_binder().is_fn_trait_compatible()
834 }
835
836 pub fn split(self) -> (ty::Binder<I, FnSigTys<I>>, FnHeader<I>) {
838 let hdr =
839 FnHeader { c_variadic: self.c_variadic(), safety: self.safety(), abi: self.abi() };
840 (self.map_bound(|sig| FnSigTys { inputs_and_output: sig.inputs_and_output }), hdr)
841 }
842}
843
844impl<I: Interner> fmt::Debug for FnSig<I> {
845 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
846 let sig = self;
847 let FnSig { inputs_and_output: _, c_variadic, safety, abi } = sig;
848
849 f.write_fmt(format_args!("{0}", safety.prefix_str()))write!(f, "{}", safety.prefix_str())?;
850 if !abi.is_rust() {
851 f.write_fmt(format_args!("extern \"{0:?}\" ", abi))write!(f, "extern \"{abi:?}\" ")?;
852 }
853
854 f.write_fmt(format_args!("fn("))write!(f, "fn(")?;
855 let inputs = sig.inputs();
856 for (i, ty) in inputs.iter().enumerate() {
857 if i > 0 {
858 f.write_fmt(format_args!(", "))write!(f, ", ")?;
859 }
860 f.write_fmt(format_args!("{0:?}", ty))write!(f, "{ty:?}")?;
861 }
862 if *c_variadic {
863 if inputs.is_empty() {
864 f.write_fmt(format_args!("..."))write!(f, "...")?;
865 } else {
866 f.write_fmt(format_args!(", ..."))write!(f, ", ...")?;
867 }
868 }
869 f.write_fmt(format_args!(")"))write!(f, ")")?;
870
871 let output = sig.output();
872 match output.kind() {
873 Tuple(list) if list.is_empty() => Ok(()),
874 _ => f.write_fmt(format_args!(" -> {0:?}", sig.output()))write!(f, " -> {:?}", sig.output()),
875 }
876 }
877}
878
879#[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)]
882#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<I: Interner, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
UnsafeBinderInner<I> where
ty::Binder<I,
I::Ty>: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
UnsafeBinderInner(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_NoContext))]
883#[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, 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 I: Interner, J: Interner,
ty::Binder<I,
I::Ty>: ::rustc_type_ir::lift::Lift<J, Lifted =
ty::Binder<J, J::Ty>> {
type Lifted = UnsafeBinderInner<J>;
fn lift_to_interner(self, interner: J) -> Option<Self::Lifted> {
Some(match self {
UnsafeBinderInner(__binding_0) => {
UnsafeBinderInner(__binding_0.lift_to_interner(interner)?)
}
})
}
}
};Lift_Generic)]
884pub struct UnsafeBinderInner<I: Interner>(ty::Binder<I, I::Ty>);
885
886impl<I: Interner> Eq for UnsafeBinderInner<I> {}
887
888impl<I: Interner> From<ty::Binder<I, I::Ty>> for UnsafeBinderInner<I> {
889 fn from(value: ty::Binder<I, I::Ty>) -> Self {
890 UnsafeBinderInner(value)
891 }
892}
893
894impl<I: Interner> From<UnsafeBinderInner<I>> for ty::Binder<I, I::Ty> {
895 fn from(value: UnsafeBinderInner<I>) -> Self {
896 value.0
897 }
898}
899
900impl<I: Interner> fmt::Debug for UnsafeBinderInner<I> {
901 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
902 self.0.fmt(f)
903 }
904}
905
906impl<I: Interner> Deref for UnsafeBinderInner<I> {
907 type Target = ty::Binder<I, I::Ty>;
908
909 fn deref(&self) -> &Self::Target {
910 &self.0
911 }
912}
913
914#[cfg(feature = "nightly")]
915impl<I: Interner, E: rustc_serialize::Encoder> rustc_serialize::Encodable<E>
916 for UnsafeBinderInner<I>
917where
918 I::Ty: rustc_serialize::Encodable<E>,
919 I::BoundVarKinds: rustc_serialize::Encodable<E>,
920{
921 fn encode(&self, e: &mut E) {
922 self.bound_vars().encode(e);
923 self.as_ref().skip_binder().encode(e);
924 }
925}
926
927#[cfg(feature = "nightly")]
928impl<I: Interner, D: rustc_serialize::Decoder> rustc_serialize::Decodable<D>
929 for UnsafeBinderInner<I>
930where
931 I::Ty: TypeVisitable<I> + rustc_serialize::Decodable<D>,
932 I::BoundVarKinds: rustc_serialize::Decodable<D>,
933{
934 fn decode(decoder: &mut D) -> Self {
935 let bound_vars = rustc_serialize::Decodable::decode(decoder);
936 UnsafeBinderInner(ty::Binder::bind_with_vars(
937 rustc_serialize::Decodable::decode(decoder),
938 bound_vars,
939 ))
940 }
941}
942
943#[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)]
945#[cfg_attr(
946 feature = "nightly",
947 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) {
match *self {
FnSigTys { inputs_and_output: 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 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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FnSigTys<I> where
I::Tys: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FnSigTys { inputs_and_output: ref __binding_0 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_NoContext)
948)]
949#[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, 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 I: Interner, J: Interner,
I::Tys: ::rustc_type_ir::lift::Lift<J, Lifted = J::Tys> {
type Lifted = FnSigTys<J>;
fn lift_to_interner(self, interner: J) -> Option<Self::Lifted> {
Some(match self {
FnSigTys { inputs_and_output: __binding_0 } => {
FnSigTys {
inputs_and_output: __binding_0.lift_to_interner(interner)?,
}
}
})
}
}
};Lift_Generic)]
950pub struct FnSigTys<I: Interner> {
951 pub inputs_and_output: I::Tys,
952}
953
954impl<I: Interner> Eq for FnSigTys<I> {}
955
956impl<I: Interner> FnSigTys<I> {
957 pub fn inputs(self) -> I::FnInputTys {
958 self.inputs_and_output.inputs()
959 }
960
961 pub fn output(self) -> I::Ty {
962 self.inputs_and_output.output()
963 }
964}
965
966impl<I: Interner> ty::Binder<I, FnSigTys<I>> {
967 pub fn with(self, hdr: FnHeader<I>) -> ty::Binder<I, FnSig<I>> {
969 self.map_bound(|sig_tys| FnSig {
970 inputs_and_output: sig_tys.inputs_and_output,
971 c_variadic: hdr.c_variadic,
972 safety: hdr.safety,
973 abi: hdr.abi,
974 })
975 }
976
977 #[inline]
978 pub fn inputs(self) -> ty::Binder<I, I::FnInputTys> {
979 self.map_bound(|sig_tys| sig_tys.inputs())
980 }
981
982 #[inline]
983 #[track_caller]
984 pub fn input(self, index: usize) -> ty::Binder<I, I::Ty> {
985 self.map_bound(|sig_tys| sig_tys.inputs().get(index).unwrap())
986 }
987
988 pub fn inputs_and_output(self) -> ty::Binder<I, I::Tys> {
989 self.map_bound(|sig_tys| sig_tys.inputs_and_output)
990 }
991
992 #[inline]
993 pub fn output(self) -> ty::Binder<I, I::Ty> {
994 self.map_bound(|sig_tys| sig_tys.output())
995 }
996}
997
998#[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 {
c_variadic: ref __field_c_variadic,
safety: ref __field_safety,
abi: ref __field_abi } => {
::core::hash::Hash::hash(__field_c_variadic, __state);
::core::hash::Hash::hash(__field_safety, __state);
::core::hash::Hash::hash(__field_abi, __state);
}
}
}
}#[derive_where(Clone, Copy, Debug, PartialEq, Hash; I: Interner)]
999#[cfg_attr(
1000 feature = "nightly",
1001 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for FnHeader<I> where
I::Safety: ::rustc_serialize::Encodable<__E>,
I::Abi: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
FnHeader {
c_variadic: ref __binding_0,
safety: ref __binding_1,
abi: 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);
}
}
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for FnHeader<I> where
I::Safety: ::rustc_serialize::Decodable<__D>,
I::Abi: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
FnHeader {
c_variadic: ::rustc_serialize::Decodable::decode(__decoder),
safety: ::rustc_serialize::Decodable::decode(__decoder),
abi: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
FnHeader<I> where
I::Safety: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::Abi: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
FnHeader {
c_variadic: ref __binding_0,
safety: ref __binding_1,
abi: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_NoContext)
1002)]
1003#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for FnHeader<I>
where I: Interner, I::Safety: ::rustc_type_ir::TypeVisitable<I>,
I::Abi: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
FnHeader {
c_variadic: ref __binding_0,
safety: ref __binding_1,
abi: ref __binding_2 } => {
{
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);
}
}
}
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_2,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for FnHeader<I>
where I: Interner, I::Safety: ::rustc_type_ir::TypeFoldable<I>,
I::Abi: ::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 {
FnHeader {
c_variadic: __binding_0,
safety: __binding_1,
abi: __binding_2 } => {
FnHeader {
c_variadic: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
safety: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
abi: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
FnHeader {
c_variadic: __binding_0,
safety: __binding_1,
abi: __binding_2 } => {
FnHeader {
c_variadic: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
safety: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
abi: ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for FnHeader<I>
where I: Interner, J: Interner,
bool: ::rustc_type_ir::lift::Lift<J, Lifted = bool>,
I::Safety: ::rustc_type_ir::lift::Lift<J, Lifted = J::Safety>,
I::Abi: ::rustc_type_ir::lift::Lift<J, Lifted = J::Abi> {
type Lifted = FnHeader<J>;
fn lift_to_interner(self, interner: J) -> Option<Self::Lifted> {
Some(match self {
FnHeader {
c_variadic: __binding_0,
safety: __binding_1,
abi: __binding_2 } => {
FnHeader {
c_variadic: __binding_0.lift_to_interner(interner)?,
safety: __binding_1.lift_to_interner(interner)?,
abi: __binding_2.lift_to_interner(interner)?,
}
}
})
}
}
};Lift_Generic)]
1004pub struct FnHeader<I: Interner> {
1005 pub c_variadic: bool,
1006 pub safety: I::Safety,
1007 pub abi: I::Abi,
1008}
1009
1010impl<I: Interner> Eq for FnHeader<I> {}
1011
1012#[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)]
1013#[cfg_attr(
1014 feature = "nightly",
1015 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) {
match *self {
CoroutineWitnessTypes {
types: ref __binding_0, assumptions: ref __binding_1 } => {
::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, __CTX>
::rustc_data_structures::stable_hasher::HashStable<__CTX> for
CoroutineWitnessTypes<I> where
I::Tys: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
I::RegionAssumptions: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
{
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
CoroutineWitnessTypes {
types: ref __binding_0, assumptions: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_NoContext)
1016)]
1017#[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, 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 I: Interner, J: Interner,
I::Tys: ::rustc_type_ir::lift::Lift<J, Lifted = J::Tys>,
I::RegionAssumptions: ::rustc_type_ir::lift::Lift<J, Lifted =
J::RegionAssumptions> {
type Lifted = CoroutineWitnessTypes<J>;
fn lift_to_interner(self, interner: J) -> Option<Self::Lifted> {
Some(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)]
1018pub struct CoroutineWitnessTypes<I: Interner> {
1019 pub types: I::Tys,
1020 pub assumptions: I::RegionAssumptions,
1021}
1022
1023impl<I: Interner> Eq for CoroutineWitnessTypes<I> {}