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::*;
20#[cfg(feature = "nightly")]
21use crate::visit::TypeVisitable;
22use crate::{self as ty, BoundVarIndexKind, FloatTy, IntTy, Interner, UintTy};
23
24mod closure;
25
26#[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)]
27#[derive(GenericTypeVisitable, 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)]
28#[cfg_attr(
29 feature = "nightly",
30 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)
31)]
32pub enum AliasTyKind<I: Interner> {
33 Projection { def_id: I::TraitAssocTyId },
43
44 Inherent { def_id: I::InherentAssocTyId },
48
49 Opaque { def_id: I::OpaqueTyId },
59
60 Free { def_id: I::FreeTyAliasId },
65}
66
67impl<I: Interner> AliasTyKind<I> {
68 pub fn descr(self) -> &'static str {
69 match self {
70 AliasTyKind::Projection { .. } => "associated type",
71 AliasTyKind::Inherent { .. } => "inherent associated type",
72 AliasTyKind::Opaque { .. } => "opaque type",
73 AliasTyKind::Free { .. } => "type alias",
74 }
75 }
76
77 pub fn def_id(self) -> I::DefId {
78 match self {
79 AliasTyKind::Projection { def_id } => def_id.into(),
80 AliasTyKind::Inherent { def_id } => def_id.into(),
81 AliasTyKind::Opaque { def_id } => def_id.into(),
82 AliasTyKind::Free { def_id } => def_id.into(),
83 }
84 }
85}
86
87#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "IrTyKind")]
92#[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)]
93#[derive(GenericTypeVisitable)]
94#[cfg_attr(
95 feature = "nightly",
96 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> ::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,
I::Region: ::rustc_data_structures::stable_hash::StableHash,
I::FunctionId: ::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) => {
{ __binding_0.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)
97)]
98pub enum TyKind<I: Interner> {
99 Bool,
101
102 Char,
105
106 Int(IntTy),
108
109 Uint(UintTy),
111
112 Float(FloatTy),
114
115 Adt(I::AdtDef, I::GenericArgs),
123
124 Foreign(I::ForeignId),
126
127 Str,
129
130 Array(I::Ty, I::Const),
132
133 Pat(I::Ty, I::Pat),
141
142 Slice(I::Ty),
144
145 RawPtr(I::Ty, Mutability),
147
148 Ref(I::Region, I::Ty, Mutability),
151
152 FnDef(I::FunctionId, I::GenericArgs),
165
166 FnPtr(ty::Binder<I, FnSigTys<I>>, FnHeader<I>),
185
186 UnsafeBinder(UnsafeBinderInner<I>),
192
193 Dynamic(I::BoundExistentialPredicates, I::Region),
195
196 Closure(I::ClosureId, I::GenericArgs),
202
203 CoroutineClosure(I::CoroutineClosureId, I::GenericArgs),
209
210 Coroutine(I::CoroutineId, I::GenericArgs),
216
217 CoroutineWitness(I::CoroutineId, I::GenericArgs),
242
243 Never,
245
246 Tuple(I::Tys),
248
249 Alias(AliasTy<I>),
254
255 Param(I::ParamTy),
257
258 Bound(BoundVarIndexKind, ty::BoundTy<I>),
275
276 Placeholder(ty::PlaceholderType<I>),
285
286 Infer(InferTy),
293
294 Error(I::ErrorGuaranteed),
298}
299
300impl<I: Interner> Eq for TyKind<I> {}
301
302impl<I: Interner> TyKind<I> {
303 pub fn fn_sig(self, interner: I) -> ty::Binder<I, ty::FnSig<I>> {
304 match self {
305 ty::FnPtr(sig_tys, hdr) => sig_tys.with(hdr),
306 ty::FnDef(def_id, args) => {
307 interner.fn_sig(def_id).instantiate(interner, args).skip_norm_wip()
308 }
309 ty::Error(_) => {
310 ty::Binder::dummy(ty::FnSig::dummy())
312 }
313 ty::Closure(..) => {
::core::panicking::panic_fmt(format_args!("to get the signature of a closure, use `args.as_closure().sig()` not `fn_sig()`"));
}panic!(
314 "to get the signature of a closure, use `args.as_closure().sig()` not `fn_sig()`",
315 ),
316 _ => {
::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),
317 }
318 }
319
320 pub fn is_known_rigid(self) -> bool {
328 match self {
329 ty::Bool
330 | ty::Char
331 | ty::Int(_)
332 | ty::Uint(_)
333 | ty::Float(_)
334 | ty::Adt(_, _)
335 | ty::Foreign(_)
336 | ty::Str
337 | ty::Array(_, _)
338 | ty::Pat(_, _)
339 | ty::Slice(_)
340 | ty::RawPtr(_, _)
341 | ty::Ref(_, _, _)
342 | ty::FnDef(_, _)
343 | ty::FnPtr(..)
344 | ty::UnsafeBinder(_)
345 | ty::Dynamic(_, _)
346 | ty::Closure(_, _)
347 | ty::CoroutineClosure(_, _)
348 | ty::Coroutine(_, _)
349 | ty::CoroutineWitness(..)
350 | ty::Never
351 | ty::Tuple(_) => true,
352
353 ty::Error(_)
354 | ty::Infer(_)
355 | ty::Alias(_)
356 | ty::Param(_)
357 | ty::Bound(_, _)
358 | ty::Placeholder(_) => false,
359 }
360 }
361}
362
363impl<I: Interner> fmt::Debug for TyKind<I> {
365 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
366 match self {
367 Bool => f.write_fmt(format_args!("bool"))write!(f, "bool"),
368 Char => f.write_fmt(format_args!("char"))write!(f, "char"),
369 Int(i) => f.write_fmt(format_args!("{0:?}", i))write!(f, "{i:?}"),
370 Uint(u) => f.write_fmt(format_args!("{0:?}", u))write!(f, "{u:?}"),
371 Float(float) => f.write_fmt(format_args!("{0:?}", float))write!(f, "{float:?}"),
372 Adt(d, s) => {
373 f.write_fmt(format_args!("{0:?}", d))write!(f, "{d:?}")?;
374 let mut s = s.iter();
375 let first = s.next();
376 match first {
377 Some(first) => f.write_fmt(format_args!("<{0:?}", first))write!(f, "<{:?}", first)?,
378 None => return Ok(()),
379 };
380
381 for arg in s {
382 f.write_fmt(format_args!(", {0:?}", arg))write!(f, ", {:?}", arg)?;
383 }
384
385 f.write_fmt(format_args!(">"))write!(f, ">")
386 }
387 Foreign(d) => f.debug_tuple("Foreign").field(d).finish(),
388 Str => f.write_fmt(format_args!("str"))write!(f, "str"),
389 Array(t, c) => f.write_fmt(format_args!("[{0:?}; {1:?}]", t, c))write!(f, "[{t:?}; {c:?}]"),
390 Pat(t, p) => f.write_fmt(format_args!("pattern_type!({0:?} is {1:?})", t, p))write!(f, "pattern_type!({t:?} is {p:?})"),
391 Slice(t) => f.write_fmt(format_args!("[{0:?}]", &t))write!(f, "[{:?}]", &t),
392 RawPtr(ty, mutbl) => f.write_fmt(format_args!("*{0} {1:?}", mutbl.ptr_str(), ty))write!(f, "*{} {:?}", mutbl.ptr_str(), ty),
393 Ref(r, t, m) => f.write_fmt(format_args!("&{0:?} {1}{2:?}", r, m.prefix_str(), t))write!(f, "&{:?} {}{:?}", r, m.prefix_str(), t),
394 FnDef(d, s) => f.debug_tuple("FnDef").field(d).field(&s).finish(),
395 FnPtr(sig_tys, hdr) => f.write_fmt(format_args!("{0:?}", sig_tys.with(*hdr)))write!(f, "{:?}", sig_tys.with(*hdr)),
396 UnsafeBinder(binder) => f.write_fmt(format_args!("{0:?}", binder))write!(f, "{:?}", binder),
398 Dynamic(p, r) => f.write_fmt(format_args!("dyn {0:?} + {1:?}", p, r))write!(f, "dyn {p:?} + {r:?}"),
399 Closure(d, s) => f.debug_tuple("Closure").field(d).field(&s).finish(),
400 CoroutineClosure(d, s) => f.debug_tuple("CoroutineClosure").field(d).field(&s).finish(),
401 Coroutine(d, s) => f.debug_tuple("Coroutine").field(d).field(&s).finish(),
402 CoroutineWitness(d, s) => f.debug_tuple("CoroutineWitness").field(d).field(&s).finish(),
403 Never => f.write_fmt(format_args!("!"))write!(f, "!"),
404 Tuple(t) => {
405 f.write_fmt(format_args!("("))write!(f, "(")?;
406 let mut count = 0;
407 for ty in t.iter() {
408 if count > 0 {
409 f.write_fmt(format_args!(", "))write!(f, ", ")?;
410 }
411 f.write_fmt(format_args!("{0:?}", ty))write!(f, "{ty:?}")?;
412 count += 1;
413 }
414 if count == 1 {
416 f.write_fmt(format_args!(","))write!(f, ",")?;
417 }
418 f.write_fmt(format_args!(")"))write!(f, ")")
419 }
420 Alias(a) => f.debug_tuple("Alias").field(&a).finish(),
421 Param(p) => f.write_fmt(format_args!("{0:?}", p))write!(f, "{p:?}"),
422 Bound(d, b) => crate::debug_bound_var(f, *d, b),
423 Placeholder(p) => f.write_fmt(format_args!("{0:?}", p))write!(f, "{p:?}"),
424 Infer(t) => f.write_fmt(format_args!("{0:?}", t))write!(f, "{:?}", t),
425 TyKind::Error(_) => f.write_fmt(format_args!("{{type error}}"))write!(f, "{{type error}}"),
426 }
427 }
428}
429
430#[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)]
436#[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 J: Interner, I: ::rustc_type_ir::LiftInto<J> {
type Lifted = AliasTy<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
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)]
437#[cfg_attr(
438 feature = "nightly",
439 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> ::rustc_data_structures::stable_hash::StableHash for
AliasTy<I> where
I::GenericArgs: ::rustc_data_structures::stable_hash::StableHash,
AliasTyKind<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 {
AliasTy {
args: ref __binding_0,
kind: ref __binding_1,
_use_alias_ty_new_instead: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
440)]
441pub struct AliasTy<I: Interner> {
442 pub args: I::GenericArgs,
453
454 #[type_foldable(identity)]
455 #[type_visitable(ignore)]
456 pub kind: AliasTyKind<I>,
457
458 #[derive_where(skip(Debug))]
460 pub(crate) _use_alias_ty_new_instead: (),
461}
462
463impl<I: Interner> Eq for AliasTy<I> {}
464
465impl<I: Interner> AliasTy<I> {
466 pub fn new_from_args(interner: I, kind: AliasTyKind<I>, args: I::GenericArgs) -> AliasTy<I> {
467 interner.debug_assert_args_compatible(kind.def_id(), args);
468 AliasTy { kind, args, _use_alias_ty_new_instead: () }
469 }
470
471 pub fn new(
472 interner: I,
473 kind: AliasTyKind<I>,
474 args: impl IntoIterator<Item: Into<I::GenericArg>>,
475 ) -> AliasTy<I> {
476 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
477 Self::new_from_args(interner, kind, args)
478 }
479
480 pub fn is_opaque(self) -> bool {
482 #[allow(non_exhaustive_omitted_patterns)] match self.kind {
AliasTyKind::Opaque { .. } => true,
_ => false,
}matches!(self.kind, AliasTyKind::Opaque { .. })
483 }
484
485 pub fn to_ty(self, interner: I) -> I::Ty {
486 Ty::new_alias(interner, self)
487 }
488}
489
490impl<I: Interner> AliasTy<I> {
492 #[track_caller]
493 pub fn self_ty(self) -> I::Ty {
494 self.args.type_at(0)
495 }
496
497 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
498 AliasTy::new(
499 interner,
500 self.kind,
501 [self_ty.into()].into_iter().chain(self.args.iter().skip(1)),
502 )
503 }
504
505 pub fn trait_def_id(self, interner: I) -> I::TraitId {
506 let AliasTyKind::Projection { def_id } = self.kind else { { ::core::panicking::panic_fmt(format_args!("expected a projection")); }panic!("expected a projection") };
507
508 interner.projection_parent(def_id.into())
509 }
510
511 pub fn trait_ref_and_own_args(self, interner: I) -> (ty::TraitRef<I>, I::GenericArgsSlice) {
517 let AliasTyKind::Projection { def_id } = self.kind else { { ::core::panicking::panic_fmt(format_args!("expected a projection")); }panic!("expected a projection") };
518
519 interner.trait_ref_and_own_args_for_alias(def_id.into(), self.args)
520 }
521
522 pub fn trait_ref(self, interner: I) -> ty::TraitRef<I> {
531 self.trait_ref_and_own_args(interner).0
532 }
533}
534
535#[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)]
536pub enum IntVarValue {
537 Unknown,
538 IntType(IntTy),
539 UintType(UintTy),
540}
541
542impl IntVarValue {
543 pub fn is_known(self) -> bool {
544 match self {
545 IntVarValue::IntType(_) | IntVarValue::UintType(_) => true,
546 IntVarValue::Unknown => false,
547 }
548 }
549
550 pub fn is_unknown(self) -> bool {
551 !self.is_known()
552 }
553}
554
555#[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)]
556pub enum FloatVarValue {
557 Unknown,
558 Known(FloatTy),
559}
560
561impl FloatVarValue {
562 pub fn is_known(self) -> bool {
563 match self {
564 FloatVarValue::Known(_) => true,
565 FloatVarValue::Unknown => false,
566 }
567 }
568
569 pub fn is_unknown(self) -> bool {
570 !self.is_known()
571 }
572}
573
574impl ::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! {
575 #[encodable]
577 #[orderable]
578 #[debug_format = "?{}t"]
579 #[gate_rustc_only]
580 pub struct TyVid {}
581}
582
583impl ::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! {
584 #[encodable]
586 #[orderable]
587 #[debug_format = "?{}i"]
588 #[gate_rustc_only]
589 pub struct IntVid {}
590}
591
592impl ::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! {
593 #[encodable]
595 #[orderable]
596 #[debug_format = "?{}f"]
597 #[gate_rustc_only]
598 pub struct FloatVid {}
599}
600
601#[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> {
::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)]
607#[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))]
608pub enum InferTy {
609 TyVar(TyVid),
611 IntVar(IntVid),
618 FloatVar(FloatVid),
625
626 FreshTy(u32),
633 FreshIntTy(u32),
635 FreshFloatTy(u32),
637}
638
639impl UnifyValue for IntVarValue {
640 type Error = NoError;
641
642 fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
643 match (*value1, *value2) {
644 (IntVarValue::Unknown, IntVarValue::Unknown) => Ok(IntVarValue::Unknown),
645 (
646 IntVarValue::Unknown,
647 known @ (IntVarValue::UintType(_) | IntVarValue::IntType(_)),
648 )
649 | (
650 known @ (IntVarValue::UintType(_) | IntVarValue::IntType(_)),
651 IntVarValue::Unknown,
652 ) => Ok(known),
653 _ => {
::core::panicking::panic_fmt(format_args!("differing ints should have been resolved first"));
}panic!("differing ints should have been resolved first"),
654 }
655 }
656}
657
658impl UnifyKey for IntVid {
659 type Value = IntVarValue;
660 #[inline] fn index(&self) -> u32 {
662 self.as_u32()
663 }
664 #[inline]
665 fn from_index(i: u32) -> IntVid {
666 IntVid::from_u32(i)
667 }
668 fn tag() -> &'static str {
669 "IntVid"
670 }
671}
672
673impl UnifyValue for FloatVarValue {
674 type Error = NoError;
675
676 fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
677 match (*value1, *value2) {
678 (FloatVarValue::Unknown, FloatVarValue::Unknown) => Ok(FloatVarValue::Unknown),
679 (FloatVarValue::Unknown, FloatVarValue::Known(known))
680 | (FloatVarValue::Known(known), FloatVarValue::Unknown) => {
681 Ok(FloatVarValue::Known(known))
682 }
683 (FloatVarValue::Known(_), FloatVarValue::Known(_)) => {
684 {
::core::panicking::panic_fmt(format_args!("differing floats should have been resolved first"));
}panic!("differing floats should have been resolved first")
685 }
686 }
687 }
688}
689
690impl UnifyKey for FloatVid {
691 type Value = FloatVarValue;
692 #[inline]
693 fn index(&self) -> u32 {
694 self.as_u32()
695 }
696 #[inline]
697 fn from_index(i: u32) -> FloatVid {
698 FloatVid::from_u32(i)
699 }
700 fn tag() -> &'static str {
701 "FloatVid"
702 }
703}
704
705#[cfg(feature = "nightly")]
706impl StableHash for InferTy {
707 fn stable_hash<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
708 use InferTy::*;
709 std::mem::discriminant(self).stable_hash(hcx, hasher);
710 match self {
711 TyVar(_) | IntVar(_) | FloatVar(_) => {
712 {
::core::panicking::panic_fmt(format_args!("type variables should not be hashed: {0:?}",
self));
}panic!("type variables should not be hashed: {self:?}")
713 }
714 FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.stable_hash(hcx, hasher),
715 }
716 }
717}
718
719impl fmt::Display for InferTy {
720 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
721 use InferTy::*;
722 match *self {
723 TyVar(_) => f.write_fmt(format_args!("_"))write!(f, "_"),
724 IntVar(_) => f.write_fmt(format_args!("{0}", "{integer}"))write!(f, "{}", "{integer}"),
725 FloatVar(_) => f.write_fmt(format_args!("{0}", "{float}"))write!(f, "{}", "{float}"),
726 FreshTy(v) => f.write_fmt(format_args!("FreshTy({0})", v))write!(f, "FreshTy({v})"),
727 FreshIntTy(v) => f.write_fmt(format_args!("FreshIntTy({0})", v))write!(f, "FreshIntTy({v})"),
728 FreshFloatTy(v) => f.write_fmt(format_args!("FreshFloatTy({0})", v))write!(f, "FreshFloatTy({v})"),
729 }
730 }
731}
732
733impl fmt::Debug for InferTy {
734 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
735 use InferTy::*;
736 match *self {
737 TyVar(ref v) => v.fmt(f),
738 IntVar(ref v) => v.fmt(f),
739 FloatVar(ref v) => v.fmt(f),
740 FreshTy(v) => f.write_fmt(format_args!("FreshTy({0:?})", v))write!(f, "FreshTy({v:?})"),
741 FreshIntTy(v) => f.write_fmt(format_args!("FreshIntTy({0:?})", v))write!(f, "FreshIntTy({v:?})"),
742 FreshFloatTy(v) => f.write_fmt(format_args!("FreshFloatTy({0:?})", v))write!(f, "FreshFloatTy({v:?})"),
743 }
744 }
745}
746
747#[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)]
748#[cfg_attr(
749 feature = "nightly",
750 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> ::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)
751)]
752#[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)]
753pub struct TypeAndMut<I: Interner> {
754 pub ty: I::Ty,
755 pub mutbl: Mutability,
756}
757
758impl<I: Interner> Eq for TypeAndMut<I> {}
759
760#[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, _marker: ref __field__marker
} => {
::core::hash::Hash::hash(__field_flags, __state);
::core::hash::Hash::hash(__field__marker, __state);
}
}
}
}#[derive_where(Copy, Clone, PartialEq, Eq, Hash; I: Interner)]
763#[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, _marker: __binding_1 } => {
FnSigKind { flags: __binding_0, _marker: __binding_1 }
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
FnSigKind { flags: __binding_0, _marker: __binding_1 } => {
FnSigKind { flags: __binding_0, _marker: __binding_1 }
}
}
}
}
};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, _marker: __binding_1 } => {
FnSigKind { flags: __binding_0, _marker: PhantomData }
}
}
}
}
};Lift_Generic)]
764#[cfg_attr(
765 feature = "nightly",
766 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) {
match *self {
FnSigKind { flags: ref __binding_0, _marker: 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 FnSigKind<I> where
PhantomData<fn() -> I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
FnSigKind {
flags: ::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, _marker: ref __binding_1
} => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
767)]
768pub struct FnSigKind<I: Interner> {
769 #[lift(identity)]
772 #[type_visitable(ignore)]
773 #[type_foldable(identity)]
774 flags: u8,
775 #[type_visitable(ignore)]
776 #[type_foldable(identity)]
777 _marker: PhantomData<fn() -> I>,
778}
779
780impl<I: Interner> fmt::Debug for FnSigKind<I> {
781 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
782 let mut f = f.debug_tuple("FnSigKind");
783
784 if self.is_safe() {
785 f.field(&"Safe");
786 } else {
787 f.field(&"Unsafe");
788 }
789
790 f.field(&self.abi());
791
792 if self.c_variadic() {
793 f.field(&"CVariadic");
794 };
795
796 f.finish()
797 }
798}
799
800impl<I: Interner> FnSigKind<I> {
801 const EXTERN_ABI_MASK: u8 = 0b111111;
803
804 const SAFE_FLAG: u8 = 1 << 6;
806
807 const C_VARIADIC_FLAG: u8 = 1 << 7;
809
810 pub fn default() -> Self {
814 Self { flags: 0, _marker: PhantomData }
815 .set_abi(ExternAbi::Rust)
816 .set_safety(I::Safety::unsafe_mode())
817 .set_c_variadic(false)
818 }
819
820 pub fn new(abi: ExternAbi, safety: I::Safety, c_variadic: bool) -> Self {
822 Self::default().set_abi(abi).set_safety(safety).set_c_variadic(c_variadic)
823 }
824
825 #[must_use = "this method does not modify the receiver"]
827 pub fn set_abi(mut self, abi: ExternAbi) -> Self {
828 let abi_index = abi.as_packed();
829 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);
830
831 self.flags &= !Self::EXTERN_ABI_MASK;
832 self.flags |= abi_index;
833
834 self
835 }
836
837 #[must_use = "this method does not modify the receiver"]
839 pub fn set_safety(mut self, safety: I::Safety) -> Self {
840 if safety.is_safe() {
841 self.flags |= Self::SAFE_FLAG;
842 } else {
843 self.flags &= !Self::SAFE_FLAG;
844 }
845
846 self
847 }
848
849 #[must_use = "this method does not modify the receiver"]
851 pub fn set_c_variadic(mut self, c_variadic: bool) -> Self {
852 if c_variadic {
853 self.flags |= Self::C_VARIADIC_FLAG;
854 } else {
855 self.flags &= !Self::C_VARIADIC_FLAG;
856 }
857
858 self
859 }
860
861 pub fn abi(self) -> ExternAbi {
863 let abi_index = self.flags & Self::EXTERN_ABI_MASK;
864 ExternAbi::from_packed(abi_index)
865 }
866
867 pub fn is_safe(self) -> bool {
869 self.flags & Self::SAFE_FLAG != 0
870 }
871
872 pub fn safety(self) -> I::Safety {
874 if self.is_safe() { I::Safety::safe() } else { I::Safety::unsafe_mode() }
875 }
876
877 pub fn c_variadic(self) -> bool {
879 self.flags & Self::C_VARIADIC_FLAG != 0
880 }
881}
882
883#[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)]
884#[cfg_attr(
885 feature = "nightly",
886 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) {
match *self {
FnSig {
inputs_and_output: ref __binding_0,
fn_sig_kind: 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 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)
887)]
888#[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, 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)]
889pub struct FnSig<I: Interner> {
890 pub inputs_and_output: I::Tys,
891 #[type_visitable(ignore)]
892 #[type_foldable(identity)]
893 pub fn_sig_kind: FnSigKind<I>,
894}
895
896impl<I: Interner> Eq for FnSig<I> {}
897
898impl<I: Interner> FnSig<I> {
899 pub fn inputs(self) -> I::FnInputTys {
900 self.inputs_and_output.inputs()
901 }
902
903 pub fn output(self) -> I::Ty {
904 self.inputs_and_output.output()
905 }
906
907 pub fn is_fn_trait_compatible(self) -> bool {
908 !self.c_variadic() && self.safety().is_safe() && self.abi() == ExternAbi::Rust
909 }
910
911 pub fn set_safety(self, safety: I::Safety) -> Self {
912 Self { fn_sig_kind: FnSigKind::new(self.abi(), safety, self.c_variadic()), ..self }
913 }
914
915 pub fn safety(self) -> I::Safety {
916 self.fn_sig_kind.safety()
917 }
918
919 pub fn abi(self) -> ExternAbi {
920 self.fn_sig_kind.abi()
921 }
922
923 pub fn c_variadic(self) -> bool {
924 self.fn_sig_kind.c_variadic()
925 }
926
927 pub fn dummy() -> Self {
928 Self {
929 inputs_and_output: Default::default(),
930 fn_sig_kind: FnSigKind::new(ExternAbi::Rust, I::Safety::safe(), false),
931 }
932 }
933}
934
935impl<I: Interner> ty::Binder<I, FnSig<I>> {
936 #[inline]
937 pub fn inputs(self) -> ty::Binder<I, I::FnInputTys> {
938 self.map_bound(|fn_sig| fn_sig.inputs())
939 }
940
941 #[inline]
942 #[track_caller]
943 pub fn input(self, index: usize) -> ty::Binder<I, I::Ty> {
944 self.map_bound(|fn_sig| fn_sig.inputs().get(index).unwrap())
945 }
946
947 pub fn inputs_and_output(self) -> ty::Binder<I, I::Tys> {
948 self.map_bound(|fn_sig| fn_sig.inputs_and_output)
949 }
950
951 #[inline]
952 pub fn output(self) -> ty::Binder<I, I::Ty> {
953 self.map_bound(|fn_sig| fn_sig.output())
954 }
955
956 pub fn fn_sig_kind(self) -> FnSigKind<I> {
957 self.skip_binder().fn_sig_kind
958 }
959
960 pub fn c_variadic(self) -> bool {
961 self.skip_binder().c_variadic()
962 }
963
964 pub fn safety(self) -> I::Safety {
965 self.skip_binder().safety()
966 }
967
968 pub fn abi(self) -> ExternAbi {
969 self.skip_binder().abi()
970 }
971
972 pub fn is_fn_trait_compatible(&self) -> bool {
973 self.skip_binder().is_fn_trait_compatible()
974 }
975
976 pub fn split(self) -> (ty::Binder<I, FnSigTys<I>>, FnHeader<I>) {
978 let hdr = FnHeader { fn_sig_kind: self.fn_sig_kind() };
979 (self.map_bound(|sig| FnSigTys { inputs_and_output: sig.inputs_and_output }), hdr)
980 }
981}
982
983impl<I: Interner> fmt::Debug for FnSig<I> {
984 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
985 let sig = self;
986 let FnSig { inputs_and_output: _, fn_sig_kind } = sig;
987
988 f.write_fmt(format_args!("{0}", fn_sig_kind.safety().prefix_str()))write!(f, "{}", fn_sig_kind.safety().prefix_str())?;
989 if fn_sig_kind.abi() != ExternAbi::Rust {
990 f.write_fmt(format_args!("extern \"{0:?}\" ", fn_sig_kind.abi()))write!(f, "extern \"{:?}\" ", fn_sig_kind.abi())?;
991 }
992
993 f.write_fmt(format_args!("fn("))write!(f, "fn(")?;
994 let inputs = sig.inputs();
995 for (i, ty) in inputs.iter().enumerate() {
996 if i > 0 {
997 f.write_fmt(format_args!(", "))write!(f, ", ")?;
998 }
999 f.write_fmt(format_args!("{0:?}", ty))write!(f, "{ty:?}")?;
1000 }
1001 if fn_sig_kind.c_variadic() {
1002 if inputs.is_empty() {
1003 f.write_fmt(format_args!("..."))write!(f, "...")?;
1004 } else {
1005 f.write_fmt(format_args!(", ..."))write!(f, ", ...")?;
1006 }
1007 }
1008 f.write_fmt(format_args!(")"))write!(f, ")")?;
1009
1010 let output = sig.output();
1011 match output.kind() {
1012 Tuple(list) if list.is_empty() => Ok(()),
1013 _ => f.write_fmt(format_args!(" -> {0:?}", sig.output()))write!(f, " -> {:?}", sig.output()),
1014 }
1015 }
1016}
1017
1018#[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)]
1021#[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))]
1022#[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 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)]
1023pub struct UnsafeBinderInner<I: Interner>(ty::Binder<I, I::Ty>);
1024
1025impl<I: Interner> Eq for UnsafeBinderInner<I> {}
1026
1027impl<I: Interner> From<ty::Binder<I, I::Ty>> for UnsafeBinderInner<I> {
1028 fn from(value: ty::Binder<I, I::Ty>) -> Self {
1029 UnsafeBinderInner(value)
1030 }
1031}
1032
1033impl<I: Interner> From<UnsafeBinderInner<I>> for ty::Binder<I, I::Ty> {
1034 fn from(value: UnsafeBinderInner<I>) -> Self {
1035 value.0
1036 }
1037}
1038
1039impl<I: Interner> fmt::Debug for UnsafeBinderInner<I> {
1040 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1041 self.0.fmt(f)
1042 }
1043}
1044
1045impl<I: Interner> Deref for UnsafeBinderInner<I> {
1046 type Target = ty::Binder<I, I::Ty>;
1047
1048 fn deref(&self) -> &Self::Target {
1049 &self.0
1050 }
1051}
1052
1053#[cfg(feature = "nightly")]
1054impl<I: Interner, E: rustc_serialize::Encoder> rustc_serialize::Encodable<E>
1055 for UnsafeBinderInner<I>
1056where
1057 I::Ty: rustc_serialize::Encodable<E>,
1058 I::BoundVarKinds: rustc_serialize::Encodable<E>,
1059{
1060 fn encode(&self, e: &mut E) {
1061 self.bound_vars().encode(e);
1062 self.as_ref().skip_binder().encode(e);
1063 }
1064}
1065
1066#[cfg(feature = "nightly")]
1067impl<I: Interner, D: rustc_serialize::Decoder> rustc_serialize::Decodable<D>
1068 for UnsafeBinderInner<I>
1069where
1070 I::Ty: TypeVisitable<I> + rustc_serialize::Decodable<D>,
1071 I::BoundVarKinds: rustc_serialize::Decodable<D>,
1072{
1073 fn decode(decoder: &mut D) -> Self {
1074 let bound_vars = rustc_serialize::Decodable::decode(decoder);
1075 UnsafeBinderInner(ty::Binder::bind_with_vars(
1076 rustc_serialize::Decodable::decode(decoder),
1077 bound_vars,
1078 ))
1079 }
1080}
1081
1082#[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)]
1084#[cfg_attr(
1085 feature = "nightly",
1086 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> ::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)
1087)]
1088#[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 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)]
1089pub struct FnSigTys<I: Interner> {
1090 pub inputs_and_output: I::Tys,
1091}
1092
1093impl<I: Interner> Eq for FnSigTys<I> {}
1094
1095impl<I: Interner> FnSigTys<I> {
1096 pub fn inputs(self) -> I::FnInputTys {
1097 self.inputs_and_output.inputs()
1098 }
1099
1100 pub fn output(self) -> I::Ty {
1101 self.inputs_and_output.output()
1102 }
1103}
1104
1105impl<I: Interner> ty::Binder<I, FnSigTys<I>> {
1106 pub fn with(self, hdr: FnHeader<I>) -> ty::Binder<I, FnSig<I>> {
1108 self.map_bound(|sig_tys| FnSig {
1109 inputs_and_output: sig_tys.inputs_and_output,
1110 fn_sig_kind: hdr.fn_sig_kind,
1111 })
1112 }
1113
1114 #[inline]
1115 pub fn inputs(self) -> ty::Binder<I, I::FnInputTys> {
1116 self.map_bound(|sig_tys| sig_tys.inputs())
1117 }
1118
1119 #[inline]
1120 #[track_caller]
1121 pub fn input(self, index: usize) -> ty::Binder<I, I::Ty> {
1122 self.map_bound(|sig_tys| sig_tys.inputs().get(index).unwrap())
1123 }
1124
1125 pub fn inputs_and_output(self) -> ty::Binder<I, I::Tys> {
1126 self.map_bound(|sig_tys| sig_tys.inputs_and_output)
1127 }
1128
1129 #[inline]
1130 pub fn output(self) -> ty::Binder<I, I::Ty> {
1131 self.map_bound(|sig_tys| sig_tys.output())
1132 }
1133}
1134
1135#[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)]
1136#[cfg_attr(
1137 feature = "nightly",
1138 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) {
match *self {
FnHeader { fn_sig_kind: 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 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)
1139)]
1140#[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, 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)]
1141pub struct FnHeader<I: Interner> {
1142 #[type_visitable(ignore)]
1143 #[type_foldable(identity)]
1144 pub fn_sig_kind: FnSigKind<I>,
1145}
1146
1147impl<I: Interner> FnHeader<I> {
1148 pub fn c_variadic(self) -> bool {
1149 self.fn_sig_kind.c_variadic()
1150 }
1151
1152 pub fn safety(self) -> I::Safety {
1153 self.fn_sig_kind.safety()
1154 }
1155
1156 pub fn abi(self) -> ExternAbi {
1157 self.fn_sig_kind.abi()
1158 }
1159
1160 pub fn dummy() -> Self {
1161 Self { fn_sig_kind: FnSigKind::new(ExternAbi::Rust, I::Safety::safe(), false) }
1162 }
1163}
1164
1165impl<I: Interner> Eq for FnHeader<I> {}
1166
1167#[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)]
1168#[cfg_attr(
1169 feature = "nightly",
1170 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> ::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)
1171)]
1172#[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 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)]
1173pub struct CoroutineWitnessTypes<I: Interner> {
1174 pub types: I::Tys,
1175 pub assumptions: I::RegionAssumptions,
1176}
1177
1178impl<I: Interner> Eq for CoroutineWitnessTypes<I> {}