1use std::hash::Hash;
2use std::{fmt, iter};
3
4use derive_where::derive_where;
5#[cfg(feature = "nightly")]
6use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash, StableHash_NoContext};
7use rustc_type_ir_macros::{
8 GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic,
9};
10
11use crate::inherent::*;
12use crate::lift::Lift;
13use crate::upcast::{Upcast, UpcastFrom};
14use crate::visit::TypeVisitableExt as _;
15use crate::{self as ty, AliasTyKind, Interner};
16
17#[automatically_derived]
impl<I: Interner, A> ::core::marker::Copy for OutlivesPredicate<I, A> where
I: Interner, A: Copy {
}#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, A)]
19#[derive_where(Copy; I: Interner, A: Copy)]
20#[derive(const _: () =
{
impl<I: Interner, A> ::rustc_type_ir::TypeVisitable<I> for
OutlivesPredicate<I, A> where I: Interner,
A: ::rustc_type_ir::TypeVisitable<I>,
I::Region: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
OutlivesPredicate(ref __binding_0, 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, A> ::rustc_type_ir::TypeFoldable<I> for
OutlivesPredicate<I, A> where I: Interner,
A: ::rustc_type_ir::TypeFoldable<I>,
I::Region: ::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 {
OutlivesPredicate(__binding_0, __binding_1) => {
OutlivesPredicate(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
::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 {
OutlivesPredicate(__binding_0, __binding_1) => {
OutlivesPredicate(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder))
}
}
}
}
};TypeFoldable_Generic)]
21#[cfg_attr(
22 feature = "nightly",
23 derive(const _: () =
{
impl<I: Interner, A, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for OutlivesPredicate<I, A>
where A: ::rustc_serialize::Decodable<__D>,
I::Region: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
OutlivesPredicate(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, A, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for OutlivesPredicate<I, A>
where A: ::rustc_serialize::Encodable<__E>,
I::Region: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
OutlivesPredicate(ref __binding_0, 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, A>
::rustc_data_structures::stable_hasher::StableHash for
OutlivesPredicate<I, A> where
A: ::rustc_data_structures::stable_hasher::StableHash,
I::Region: ::rustc_data_structures::stable_hasher::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
OutlivesPredicate(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
24)]
25pub struct OutlivesPredicate<I: Interner, A>(pub A, pub I::Region);
26
27impl<I: Interner, A: Eq> Eq for OutlivesPredicate<I, A> {}
28
29impl<I: Interner, U: Interner, A> Lift<U> for OutlivesPredicate<I, A>
32where
33 A: Lift<U>,
34 I::Region: Lift<U, Lifted = U::Region>,
35{
36 type Lifted = OutlivesPredicate<U, A::Lifted>;
37
38 fn lift_to_interner(self, cx: U) -> Self::Lifted {
39 OutlivesPredicate(self.0.lift_to_interner(cx), self.1.lift_to_interner(cx))
40 }
41}
42
43#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for RegionEqPredicate<I> where
I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
RegionEqPredicate(ref __field_0, ref __field_1) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f,
"RegionEqPredicate");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::field(&mut __builder, __field_1);
::core::fmt::DebugTuple::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
48#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
RegionEqPredicate<I> where I: Interner,
I::Region: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
RegionEqPredicate(ref __binding_0, 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
RegionEqPredicate<I> where I: Interner,
I::Region: ::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 {
RegionEqPredicate(__binding_0, __binding_1) => {
RegionEqPredicate(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
::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 {
RegionEqPredicate(__binding_0, __binding_1) => {
RegionEqPredicate(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder))
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
RegionEqPredicate<I> where I: Interner, J: Interner,
I::Region: ::rustc_type_ir::lift::Lift<J, Lifted = J::Region>,
I::Region: ::rustc_type_ir::lift::Lift<J, Lifted = J::Region> {
type Lifted = RegionEqPredicate<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
RegionEqPredicate(__binding_0, __binding_1) => {
RegionEqPredicate(__binding_0.lift_to_interner(interner),
__binding_1.lift_to_interner(interner))
}
}
}
}
};Lift_Generic)]
49#[cfg_attr(
50 feature = "nightly",
51 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for RegionEqPredicate<I> where
I::Region: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
RegionEqPredicate(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for RegionEqPredicate<I> where
I::Region: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
RegionEqPredicate(ref __binding_0, 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> ::rustc_data_structures::stable_hasher::StableHash
for RegionEqPredicate<I> where
I::Region: ::rustc_data_structures::stable_hasher::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
RegionEqPredicate(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
52)]
53pub struct RegionEqPredicate<I: Interner>(pub I::Region, pub I::Region);
54
55impl<I: Interner> RegionEqPredicate<I> {
56 pub fn into_bidirectional_outlives(self) -> [OutlivesPredicate<I, I::GenericArg>; 2] {
58 [OutlivesPredicate(self.0.into(), self.1), OutlivesPredicate(self.1.into(), self.0)]
59 }
60}
61
62#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for RegionConstraint<I> where I: Interner
{
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
RegionConstraint::Outlives(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "Outlives");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
RegionConstraint::Eq(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "Eq");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
63#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
RegionConstraint<I> where I: Interner,
OutlivesPredicate<I,
I::GenericArg>: ::rustc_type_ir::TypeVisitable<I>,
RegionEqPredicate<I>: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
RegionConstraint::Outlives(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);
}
}
}
}
RegionConstraint::Eq(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
RegionConstraint<I> where I: Interner,
OutlivesPredicate<I,
I::GenericArg>: ::rustc_type_ir::TypeFoldable<I>,
RegionEqPredicate<I>: ::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 {
RegionConstraint::Outlives(__binding_0) => {
RegionConstraint::Outlives(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
RegionConstraint::Eq(__binding_0) => {
RegionConstraint::Eq(::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 {
RegionConstraint::Outlives(__binding_0) => {
RegionConstraint::Outlives(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder))
}
RegionConstraint::Eq(__binding_0) => {
RegionConstraint::Eq(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder))
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
RegionConstraint<I> where I: Interner, J: Interner,
OutlivesPredicate<I,
I::GenericArg>: ::rustc_type_ir::lift::Lift<J, Lifted =
OutlivesPredicate<J, J::GenericArg>>,
RegionEqPredicate<I>: ::rustc_type_ir::lift::Lift<J, Lifted =
RegionEqPredicate<J>> {
type Lifted = RegionConstraint<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
RegionConstraint::Outlives(__binding_0) => {
RegionConstraint::Outlives(__binding_0.lift_to_interner(interner))
}
RegionConstraint::Eq(__binding_0) => {
RegionConstraint::Eq(__binding_0.lift_to_interner(interner))
}
}
}
}
};Lift_Generic)]
64#[cfg_attr(
65 feature = "nightly",
66 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for RegionConstraint<I> where
OutlivesPredicate<I,
I::GenericArg>: ::rustc_serialize::Decodable<__D>,
RegionEqPredicate<I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
RegionConstraint::Outlives(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
RegionConstraint::Eq(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `RegionConstraint`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for RegionConstraint<I> where
OutlivesPredicate<I,
I::GenericArg>: ::rustc_serialize::Encodable<__E>,
RegionEqPredicate<I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
RegionConstraint::Outlives(ref __binding_0) => { 0usize }
RegionConstraint::Eq(ref __binding_0) => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
RegionConstraint::Outlives(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
RegionConstraint::Eq(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hasher::StableHash
for RegionConstraint<I> where
OutlivesPredicate<I,
I::GenericArg>: ::rustc_data_structures::stable_hasher::StableHash,
RegionEqPredicate<I>: ::rustc_data_structures::stable_hasher::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
RegionConstraint::Outlives(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
RegionConstraint::Eq(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
67)]
68pub enum RegionConstraint<I: Interner> {
69 Outlives(OutlivesPredicate<I, I::GenericArg>),
70 Eq(RegionEqPredicate<I>),
71}
72
73impl<I: Interner> From<OutlivesPredicate<I, I::GenericArg>> for RegionConstraint<I> {
74 fn from(value: OutlivesPredicate<I, I::GenericArg>) -> Self {
75 RegionConstraint::Outlives(value)
76 }
77}
78
79impl<I: Interner> From<RegionEqPredicate<I>> for RegionConstraint<I> {
80 fn from(value: RegionEqPredicate<I>) -> Self {
81 RegionConstraint::Eq(value)
82 }
83}
84
85impl<I: Interner> RegionConstraint<I> {
86 pub fn is_trivial(self) -> bool {
88 match self {
89 RegionConstraint::Outlives(outlives) => {
90 outlives.0.as_region().is_some_and(|re| re == outlives.1)
91 }
92 RegionConstraint::Eq(eq) => eq.0 == eq.1,
93 }
94 }
95
96 pub fn iter_outlives(self) -> impl Iterator<Item = OutlivesPredicate<I, I::GenericArg>> {
99 match self {
100 RegionConstraint::Outlives(outlives) => iter::once(outlives).chain(None),
101 RegionConstraint::Eq(eq) => {
102 let [outlives1, outlives2] = eq.into_bidirectional_outlives();
103 iter::once(outlives1).chain(Some(outlives2))
104 }
105 }
106 }
107}
108
109#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for TraitRef<I> where I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(TraitRef {
def_id: ref __field_def_id,
args: ref __field_args,
_use_trait_ref_new_instead: ref __field__use_trait_ref_new_instead
}, TraitRef {
def_id: ref __other_field_def_id,
args: ref __other_field_args,
_use_trait_ref_new_instead: ref __other_field__use_trait_ref_new_instead
}) =>
true &&
::core::cmp::PartialEq::eq(__field_def_id,
__other_field_def_id) &&
::core::cmp::PartialEq::eq(__field_args, __other_field_args)
&&
::core::cmp::PartialEq::eq(__field__use_trait_ref_new_instead,
__other_field__use_trait_ref_new_instead),
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
123#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for TraitRef<I>
where I: Interner, I::TraitId: ::rustc_type_ir::TypeVisitable<I>,
I::GenericArgs: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
TraitRef {
def_id: ref __binding_0,
args: ref __binding_1,
_use_trait_ref_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_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 TraitRef<I>
where I: Interner, I::TraitId: ::rustc_type_ir::TypeFoldable<I>,
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 {
TraitRef {
def_id: __binding_0,
args: __binding_1,
_use_trait_ref_new_instead: __binding_2 } => {
TraitRef {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
args: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
_use_trait_ref_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 {
TraitRef {
def_id: __binding_0,
args: __binding_1,
_use_trait_ref_new_instead: __binding_2 } => {
TraitRef {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
args: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
_use_trait_ref_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 TraitRef<I>
where I: Interner, J: Interner,
I::TraitId: ::rustc_type_ir::lift::Lift<J, Lifted = J::TraitId>,
I::GenericArgs: ::rustc_type_ir::lift::Lift<J, Lifted =
J::GenericArgs>, (): ::rustc_type_ir::lift::Lift<J, Lifted = ()> {
type Lifted = TraitRef<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
TraitRef {
def_id: __binding_0,
args: __binding_1,
_use_trait_ref_new_instead: __binding_2 } => {
TraitRef {
def_id: __binding_0.lift_to_interner(interner),
args: __binding_1.lift_to_interner(interner),
_use_trait_ref_new_instead: __binding_2.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
124#[cfg_attr(
125 feature = "nightly",
126 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for TraitRef<I> where
I::TraitId: ::rustc_serialize::Decodable<__D>,
I::GenericArgs: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
TraitRef {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
args: ::rustc_serialize::Decodable::decode(__decoder),
_use_trait_ref_new_instead: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for TraitRef<I> where
I::TraitId: ::rustc_serialize::Encodable<__E>,
I::GenericArgs: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
TraitRef {
def_id: ref __binding_0,
args: ref __binding_1,
_use_trait_ref_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_hasher::StableHash
for TraitRef<I> where
I::TraitId: ::rustc_data_structures::stable_hasher::StableHash,
I::GenericArgs: ::rustc_data_structures::stable_hasher::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitRef {
def_id: ref __binding_0,
args: ref __binding_1,
_use_trait_ref_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)
127)]
128pub struct TraitRef<I: Interner> {
129 pub def_id: I::TraitId,
130 pub args: I::GenericArgs,
131 _use_trait_ref_new_instead: (),
134}
135
136impl<I: Interner> Eq for TraitRef<I> {}
137
138impl<I: Interner> TraitRef<I> {
139 pub fn new_from_args(interner: I, trait_def_id: I::TraitId, args: I::GenericArgs) -> Self {
140 interner.debug_assert_args_compatible(trait_def_id.into(), args);
141 Self { def_id: trait_def_id, args, _use_trait_ref_new_instead: () }
142 }
143
144 pub fn new(
145 interner: I,
146 trait_def_id: I::TraitId,
147 args: impl IntoIterator<Item: Into<I::GenericArg>>,
148 ) -> Self {
149 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
150 Self::new_from_args(interner, trait_def_id, args)
151 }
152
153 pub fn from_assoc(interner: I, trait_id: I::TraitId, args: I::GenericArgs) -> TraitRef<I> {
154 let generics = interner.generics_of(trait_id.into());
155 TraitRef::new(interner, trait_id, args.iter().take(generics.count()))
156 }
157
158 pub fn identity(interner: I, def_id: I::TraitId) -> TraitRef<I> {
161 TraitRef::new_from_args(
162 interner,
163 def_id,
164 I::GenericArgs::identity_for_item(interner, def_id.into()),
165 )
166 }
167
168 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
169 TraitRef::new(
170 interner,
171 self.def_id,
172 [self_ty.into()].into_iter().chain(self.args.iter().skip(1)),
173 )
174 }
175
176 #[inline]
177 pub fn self_ty(&self) -> I::Ty {
178 self.args.type_at(0)
179 }
180}
181
182impl<I: Interner> ty::Binder<I, TraitRef<I>> {
183 pub fn self_ty(&self) -> ty::Binder<I, I::Ty> {
184 self.map_bound_ref(|tr| tr.self_ty())
185 }
186
187 pub fn def_id(&self) -> I::TraitId {
188 self.skip_binder().def_id
189 }
190
191 pub fn to_host_effect_clause(self, cx: I, constness: BoundConstness) -> I::Clause {
192 self.map_bound(|trait_ref| {
193 ty::ClauseKind::HostEffect(HostEffectPredicate { trait_ref, constness })
194 })
195 .upcast(cx)
196 }
197}
198
199#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for TraitPredicate<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(TraitPredicate {
trait_ref: ref __field_trait_ref,
polarity: ref __field_polarity }, TraitPredicate {
trait_ref: ref __other_field_trait_ref,
polarity: ref __other_field_polarity }) =>
true &&
::core::cmp::PartialEq::eq(__field_trait_ref,
__other_field_trait_ref) &&
::core::cmp::PartialEq::eq(__field_polarity,
__other_field_polarity),
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
200#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
TraitPredicate<I> where I: Interner,
TraitRef<I>: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
TraitPredicate {
trait_ref: ref __binding_0, polarity: 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
TraitPredicate<I> where I: Interner,
TraitRef<I>: ::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 {
TraitPredicate {
trait_ref: __binding_0, polarity: __binding_1 } => {
TraitPredicate {
trait_ref: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
polarity: ::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 {
TraitPredicate {
trait_ref: __binding_0, polarity: __binding_1 } => {
TraitPredicate {
trait_ref: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
polarity: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
TraitPredicate<I> where I: Interner, J: Interner,
TraitRef<I>: ::rustc_type_ir::lift::Lift<J, Lifted = TraitRef<J>>,
PredicatePolarity: ::rustc_type_ir::lift::Lift<J, Lifted =
PredicatePolarity> {
type Lifted = TraitPredicate<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
TraitPredicate {
trait_ref: __binding_0, polarity: __binding_1 } => {
TraitPredicate {
trait_ref: __binding_0.lift_to_interner(interner),
polarity: __binding_1.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
201#[cfg_attr(
202 feature = "nightly",
203 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for TraitPredicate<I> where
TraitRef<I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
TraitPredicate {
trait_ref: ::rustc_serialize::Decodable::decode(__decoder),
polarity: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for TraitPredicate<I> where
TraitRef<I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
TraitPredicate {
trait_ref: ref __binding_0, polarity: 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> ::rustc_data_structures::stable_hasher::StableHash
for TraitPredicate<I> where
TraitRef<I>: ::rustc_data_structures::stable_hasher::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
TraitPredicate {
trait_ref: ref __binding_0, polarity: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
204)]
205pub struct TraitPredicate<I: Interner> {
206 pub trait_ref: TraitRef<I>,
207
208 pub polarity: PredicatePolarity,
214}
215
216impl<I: Interner> Eq for TraitPredicate<I> {}
217
218impl<I: Interner> TraitPredicate<I> {
219 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
220 Self {
221 trait_ref: self.trait_ref.with_replaced_self_ty(interner, self_ty),
222 polarity: self.polarity,
223 }
224 }
225
226 pub fn def_id(self) -> I::TraitId {
227 self.trait_ref.def_id
228 }
229
230 pub fn self_ty(self) -> I::Ty {
231 self.trait_ref.self_ty()
232 }
233}
234
235impl<I: Interner> ty::Binder<I, TraitPredicate<I>> {
236 pub fn def_id(self) -> I::TraitId {
237 self.skip_binder().def_id()
239 }
240
241 pub fn self_ty(self) -> ty::Binder<I, I::Ty> {
242 self.map_bound(|trait_ref| trait_ref.self_ty())
243 }
244
245 #[inline]
246 pub fn polarity(self) -> PredicatePolarity {
247 self.skip_binder().polarity
248 }
249}
250
251impl<I: Interner> UpcastFrom<I, TraitRef<I>> for TraitPredicate<I> {
252 fn upcast_from(from: TraitRef<I>, _tcx: I) -> Self {
253 TraitPredicate { trait_ref: from, polarity: PredicatePolarity::Positive }
254 }
255}
256
257impl<I: Interner> UpcastFrom<I, ty::Binder<I, TraitRef<I>>> for ty::Binder<I, TraitPredicate<I>> {
258 fn upcast_from(from: ty::Binder<I, TraitRef<I>>, _tcx: I) -> Self {
259 from.map_bound(|trait_ref| TraitPredicate {
260 trait_ref,
261 polarity: PredicatePolarity::Positive,
262 })
263 }
264}
265
266impl<I: Interner> fmt::Debug for TraitPredicate<I> {
267 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
268 f.write_fmt(format_args!("TraitPredicate({0:?}, polarity:{1:?})",
self.trait_ref, self.polarity))write!(f, "TraitPredicate({:?}, polarity:{:?})", self.trait_ref, self.polarity)
269 }
270}
271
272#[derive(#[automatically_derived]
impl ::core::clone::Clone for ImplPolarity {
#[inline]
fn clone(&self) -> ImplPolarity { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ImplPolarity { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for ImplPolarity {
#[inline]
fn eq(&self, other: &ImplPolarity) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ImplPolarity {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for ImplPolarity {
#[inline]
fn partial_cmp(&self, other: &ImplPolarity)
-> ::core::option::Option<::core::cmp::Ordering> {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for ImplPolarity {
#[inline]
fn cmp(&self, other: &ImplPolarity) -> ::core::cmp::Ordering {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for ImplPolarity {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for ImplPolarity {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
ImplPolarity::Positive => "Positive",
ImplPolarity::Negative => "Negative",
ImplPolarity::Reservation => "Reservation",
})
}
}Debug)]
273#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for ImplPolarity {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { ImplPolarity::Positive }
1usize => { ImplPolarity::Negative }
2usize => { ImplPolarity::Reservation }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ImplPolarity`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for ImplPolarity {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
ImplPolarity::Positive => { 0usize }
ImplPolarity::Negative => { 1usize }
ImplPolarity::Reservation => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
ImplPolarity::Positive => {}
ImplPolarity::Negative => {}
ImplPolarity::Reservation => {}
}
}
}
};Encodable_NoContext, const _: () =
{
impl ::rustc_data_structures::stable_hasher::StableHash for
ImplPolarity {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ImplPolarity::Positive => {}
ImplPolarity::Negative => {}
ImplPolarity::Reservation => {}
}
}
}
};StableHash))]
274pub enum ImplPolarity {
275 Positive,
277 Negative,
279 Reservation,
284}
285
286impl fmt::Display for ImplPolarity {
287 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
288 match self {
289 Self::Positive => f.write_str("positive"),
290 Self::Negative => f.write_str("negative"),
291 Self::Reservation => f.write_str("reservation"),
292 }
293 }
294}
295
296impl ImplPolarity {
297 pub fn as_str(self) -> &'static str {
299 match self {
300 Self::Positive => "",
301 Self::Negative => "!",
302 Self::Reservation => "",
303 }
304 }
305}
306
307#[derive(#[automatically_derived]
impl ::core::clone::Clone for PredicatePolarity {
#[inline]
fn clone(&self) -> PredicatePolarity { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for PredicatePolarity { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for PredicatePolarity {
#[inline]
fn eq(&self, other: &PredicatePolarity) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for PredicatePolarity {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for PredicatePolarity {
#[inline]
fn partial_cmp(&self, other: &PredicatePolarity)
-> ::core::option::Option<::core::cmp::Ordering> {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for PredicatePolarity {
#[inline]
fn cmp(&self, other: &PredicatePolarity) -> ::core::cmp::Ordering {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for PredicatePolarity {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for PredicatePolarity {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
PredicatePolarity::Positive => "Positive",
PredicatePolarity::Negative => "Negative",
})
}
}Debug)]
313#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for PredicatePolarity {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { PredicatePolarity::Positive }
1usize => { PredicatePolarity::Negative }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `PredicatePolarity`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for PredicatePolarity {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
PredicatePolarity::Positive => { 0usize }
PredicatePolarity::Negative => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
PredicatePolarity::Positive => {}
PredicatePolarity::Negative => {}
}
}
}
};Encodable_NoContext, const _: () =
{
impl ::rustc_data_structures::stable_hasher::StableHash for
PredicatePolarity {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
PredicatePolarity::Positive => {}
PredicatePolarity::Negative => {}
}
}
}
};StableHash))]
314pub enum PredicatePolarity {
315 Positive,
317 Negative,
319}
320
321impl PredicatePolarity {
322 pub fn flip(&self) -> PredicatePolarity {
324 match self {
325 PredicatePolarity::Positive => PredicatePolarity::Negative,
326 PredicatePolarity::Negative => PredicatePolarity::Positive,
327 }
328 }
329}
330
331impl fmt::Display for PredicatePolarity {
332 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
333 match self {
334 Self::Positive => f.write_str("positive"),
335 Self::Negative => f.write_str("negative"),
336 }
337 }
338}
339
340#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for ExistentialPredicate<I> where
I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
ExistentialPredicate::Trait(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "Trait");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
ExistentialPredicate::Projection(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "Projection");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
ExistentialPredicate::AutoTrait(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "AutoTrait");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
341#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
ExistentialPredicate<I> where I: Interner,
ExistentialTraitRef<I>: ::rustc_type_ir::TypeVisitable<I>,
ExistentialProjection<I>: ::rustc_type_ir::TypeVisitable<I>,
I::TraitId: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
ExistentialPredicate::Trait(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);
}
}
}
}
ExistentialPredicate::Projection(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);
}
}
}
}
ExistentialPredicate::AutoTrait(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
ExistentialPredicate<I> where I: Interner,
ExistentialTraitRef<I>: ::rustc_type_ir::TypeFoldable<I>,
ExistentialProjection<I>: ::rustc_type_ir::TypeFoldable<I>,
I::TraitId: ::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 {
ExistentialPredicate::Trait(__binding_0) => {
ExistentialPredicate::Trait(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
ExistentialPredicate::Projection(__binding_0) => {
ExistentialPredicate::Projection(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
ExistentialPredicate::AutoTrait(__binding_0) => {
ExistentialPredicate::AutoTrait(::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 {
ExistentialPredicate::Trait(__binding_0) => {
ExistentialPredicate::Trait(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder))
}
ExistentialPredicate::Projection(__binding_0) => {
ExistentialPredicate::Projection(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder))
}
ExistentialPredicate::AutoTrait(__binding_0) => {
ExistentialPredicate::AutoTrait(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder))
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
ExistentialPredicate<I> where I: Interner, J: Interner,
ExistentialTraitRef<I>: ::rustc_type_ir::lift::Lift<J, Lifted =
ExistentialTraitRef<J>>,
ExistentialProjection<I>: ::rustc_type_ir::lift::Lift<J, Lifted =
ExistentialProjection<J>>,
I::TraitId: ::rustc_type_ir::lift::Lift<J, Lifted = J::TraitId> {
type Lifted = ExistentialPredicate<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
ExistentialPredicate::Trait(__binding_0) => {
ExistentialPredicate::Trait(__binding_0.lift_to_interner(interner))
}
ExistentialPredicate::Projection(__binding_0) => {
ExistentialPredicate::Projection(__binding_0.lift_to_interner(interner))
}
ExistentialPredicate::AutoTrait(__binding_0) => {
ExistentialPredicate::AutoTrait(__binding_0.lift_to_interner(interner))
}
}
}
}
};Lift_Generic)]
342#[cfg_attr(
343 feature = "nightly",
344 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for ExistentialPredicate<I>
where ExistentialTraitRef<I>: ::rustc_serialize::Decodable<__D>,
ExistentialProjection<I>: ::rustc_serialize::Decodable<__D>,
I::TraitId: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
ExistentialPredicate::Trait(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
ExistentialPredicate::Projection(::rustc_serialize::Decodable::decode(__decoder))
}
2usize => {
ExistentialPredicate::AutoTrait(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ExistentialPredicate`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for ExistentialPredicate<I>
where ExistentialTraitRef<I>: ::rustc_serialize::Encodable<__E>,
ExistentialProjection<I>: ::rustc_serialize::Encodable<__E>,
I::TraitId: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
ExistentialPredicate::Trait(ref __binding_0) => { 0usize }
ExistentialPredicate::Projection(ref __binding_0) => {
1usize
}
ExistentialPredicate::AutoTrait(ref __binding_0) => {
2usize
}
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
ExistentialPredicate::Trait(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
ExistentialPredicate::Projection(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
ExistentialPredicate::AutoTrait(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hasher::StableHash
for ExistentialPredicate<I> where
ExistentialTraitRef<I>: ::rustc_data_structures::stable_hasher::StableHash,
ExistentialProjection<I>: ::rustc_data_structures::stable_hasher::StableHash,
I::TraitId: ::rustc_data_structures::stable_hasher::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ExistentialPredicate::Trait(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExistentialPredicate::Projection(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
ExistentialPredicate::AutoTrait(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
345)]
346pub enum ExistentialPredicate<I: Interner> {
347 Trait(ExistentialTraitRef<I>),
349 Projection(ExistentialProjection<I>),
351 AutoTrait(I::TraitId),
353}
354
355impl<I: Interner> Eq for ExistentialPredicate<I> {}
356
357impl<I: Interner> ty::Binder<I, ExistentialPredicate<I>> {
358 pub fn def_id(&self) -> I::DefId {
359 match self.skip_binder() {
360 ExistentialPredicate::Trait(tr) => tr.def_id.into(),
361 ExistentialPredicate::Projection(p) => p.def_id.into(),
362 ExistentialPredicate::AutoTrait(did) => did.into(),
363 }
364 }
365 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> I::Clause {
369 match self.skip_binder() {
370 ExistentialPredicate::Trait(tr) => self.rebind(tr).with_self_ty(cx, self_ty).upcast(cx),
371 ExistentialPredicate::Projection(p) => {
372 self.rebind(p.with_self_ty(cx, self_ty)).upcast(cx)
373 }
374 ExistentialPredicate::AutoTrait(did) => {
375 let generics = cx.generics_of(did.into());
376 let trait_ref = if generics.count() == 1 {
377 ty::TraitRef::new(cx, did, [self_ty])
378 } else {
379 let err_args =
382 GenericArgs::extend_with_error(cx, did.into(), &[self_ty.into()]);
383 ty::TraitRef::new_from_args(cx, did, err_args)
384 };
385 self.rebind(trait_ref).upcast(cx)
386 }
387 }
388 }
389}
390
391#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ExistentialTraitRef<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(ExistentialTraitRef {
def_id: ref __field_def_id,
args: ref __field_args,
_use_existential_trait_ref_new_instead: ref __field__use_existential_trait_ref_new_instead
}, ExistentialTraitRef {
def_id: ref __other_field_def_id,
args: ref __other_field_args,
_use_existential_trait_ref_new_instead: ref __other_field__use_existential_trait_ref_new_instead
}) =>
true &&
::core::cmp::PartialEq::eq(__field_def_id,
__other_field_def_id) &&
::core::cmp::PartialEq::eq(__field_args, __other_field_args)
&&
::core::cmp::PartialEq::eq(__field__use_existential_trait_ref_new_instead,
__other_field__use_existential_trait_ref_new_instead),
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
400#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
ExistentialTraitRef<I> where I: Interner,
I::TraitId: ::rustc_type_ir::TypeVisitable<I>,
I::GenericArgs: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
ExistentialTraitRef {
def_id: ref __binding_0,
args: ref __binding_1,
_use_existential_trait_ref_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_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
ExistentialTraitRef<I> where I: Interner,
I::TraitId: ::rustc_type_ir::TypeFoldable<I>,
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 {
ExistentialTraitRef {
def_id: __binding_0,
args: __binding_1,
_use_existential_trait_ref_new_instead: __binding_2 } => {
ExistentialTraitRef {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
args: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
_use_existential_trait_ref_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 {
ExistentialTraitRef {
def_id: __binding_0,
args: __binding_1,
_use_existential_trait_ref_new_instead: __binding_2 } => {
ExistentialTraitRef {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
args: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
_use_existential_trait_ref_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
ExistentialTraitRef<I> where I: Interner, J: Interner,
I::TraitId: ::rustc_type_ir::lift::Lift<J, Lifted = J::TraitId>,
I::GenericArgs: ::rustc_type_ir::lift::Lift<J, Lifted =
J::GenericArgs>, (): ::rustc_type_ir::lift::Lift<J, Lifted = ()> {
type Lifted = ExistentialTraitRef<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
ExistentialTraitRef {
def_id: __binding_0,
args: __binding_1,
_use_existential_trait_ref_new_instead: __binding_2 } => {
ExistentialTraitRef {
def_id: __binding_0.lift_to_interner(interner),
args: __binding_1.lift_to_interner(interner),
_use_existential_trait_ref_new_instead: __binding_2.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
401#[cfg_attr(
402 feature = "nightly",
403 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for ExistentialTraitRef<I> where
I::TraitId: ::rustc_serialize::Decodable<__D>,
I::GenericArgs: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
ExistentialTraitRef {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
args: ::rustc_serialize::Decodable::decode(__decoder),
_use_existential_trait_ref_new_instead: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for ExistentialTraitRef<I> where
I::TraitId: ::rustc_serialize::Encodable<__E>,
I::GenericArgs: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
ExistentialTraitRef {
def_id: ref __binding_0,
args: ref __binding_1,
_use_existential_trait_ref_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_hasher::StableHash
for ExistentialTraitRef<I> where
I::TraitId: ::rustc_data_structures::stable_hasher::StableHash,
I::GenericArgs: ::rustc_data_structures::stable_hasher::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ExistentialTraitRef {
def_id: ref __binding_0,
args: ref __binding_1,
_use_existential_trait_ref_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)
404)]
405pub struct ExistentialTraitRef<I: Interner> {
406 pub def_id: I::TraitId,
407 pub args: I::GenericArgs,
408 _use_existential_trait_ref_new_instead: (),
411}
412
413impl<I: Interner> Eq for ExistentialTraitRef<I> {}
414
415impl<I: Interner> ExistentialTraitRef<I> {
416 pub fn new_from_args(interner: I, trait_def_id: I::TraitId, args: I::GenericArgs) -> Self {
417 interner.debug_assert_existential_args_compatible(trait_def_id.into(), args);
418 Self { def_id: trait_def_id, args, _use_existential_trait_ref_new_instead: () }
419 }
420
421 pub fn new(
422 interner: I,
423 trait_def_id: I::TraitId,
424 args: impl IntoIterator<Item: Into<I::GenericArg>>,
425 ) -> Self {
426 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
427 Self::new_from_args(interner, trait_def_id, args)
428 }
429
430 pub fn erase_self_ty(interner: I, trait_ref: TraitRef<I>) -> ExistentialTraitRef<I> {
431 trait_ref.args.type_at(0);
433
434 ExistentialTraitRef {
435 def_id: trait_ref.def_id,
436 args: interner.mk_args(&trait_ref.args.as_slice()[1..]),
437 _use_existential_trait_ref_new_instead: (),
438 }
439 }
440
441 pub fn with_self_ty(self, interner: I, self_ty: I::Ty) -> TraitRef<I> {
446 TraitRef::new(interner, self.def_id, [self_ty.into()].into_iter().chain(self.args.iter()))
450 }
451}
452
453impl<I: Interner> ty::Binder<I, ExistentialTraitRef<I>> {
454 pub fn def_id(&self) -> I::TraitId {
455 self.skip_binder().def_id
456 }
457
458 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, TraitRef<I>> {
463 self.map_bound(|trait_ref| trait_ref.with_self_ty(cx, self_ty))
464 }
465}
466
467#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for ExistentialProjection<I> where
I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
ExistentialProjection {
def_id: ref __field_def_id,
args: ref __field_args,
term: ref __field_term,
use_existential_projection_new_instead: ref __field_use_existential_projection_new_instead
} => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f,
"ExistentialProjection");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::field(&mut __builder, "args",
__field_args);
::core::fmt::DebugStruct::field(&mut __builder, "term",
__field_term);
::core::fmt::DebugStruct::finish_non_exhaustive(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
469#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
ExistentialProjection<I> where I: Interner,
I::TraitAssocTermId: ::rustc_type_ir::TypeVisitable<I>,
I::GenericArgs: ::rustc_type_ir::TypeVisitable<I>,
I::Term: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
ExistentialProjection {
def_id: ref __binding_0,
args: ref __binding_1,
term: ref __binding_2,
use_existential_projection_new_instead: ref __binding_3 } =>
{
{
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);
}
}
}
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_3,
__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
ExistentialProjection<I> where I: Interner,
I::TraitAssocTermId: ::rustc_type_ir::TypeFoldable<I>,
I::GenericArgs: ::rustc_type_ir::TypeFoldable<I>,
I::Term: ::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 {
ExistentialProjection {
def_id: __binding_0,
args: __binding_1,
term: __binding_2,
use_existential_projection_new_instead: __binding_3 } => {
ExistentialProjection {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
args: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
term: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
__folder)?,
use_existential_projection_new_instead: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_3,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
ExistentialProjection {
def_id: __binding_0,
args: __binding_1,
term: __binding_2,
use_existential_projection_new_instead: __binding_3 } => {
ExistentialProjection {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
args: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
term: ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
__folder),
use_existential_projection_new_instead: ::rustc_type_ir::TypeFoldable::fold_with(__binding_3,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
ExistentialProjection<I> where I: Interner, J: Interner,
I::TraitAssocTermId: ::rustc_type_ir::lift::Lift<J, Lifted =
J::TraitAssocTermId>,
I::GenericArgs: ::rustc_type_ir::lift::Lift<J, Lifted =
J::GenericArgs>,
I::Term: ::rustc_type_ir::lift::Lift<J, Lifted = J::Term>,
(): ::rustc_type_ir::lift::Lift<J, Lifted = ()> {
type Lifted = ExistentialProjection<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
ExistentialProjection {
def_id: __binding_0,
args: __binding_1,
term: __binding_2,
use_existential_projection_new_instead: __binding_3 } => {
ExistentialProjection {
def_id: __binding_0.lift_to_interner(interner),
args: __binding_1.lift_to_interner(interner),
term: __binding_2.lift_to_interner(interner),
use_existential_projection_new_instead: __binding_3.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
470#[cfg_attr(
471 feature = "nightly",
472 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for ExistentialProjection<I>
where I::TraitAssocTermId: ::rustc_serialize::Decodable<__D>,
I::GenericArgs: ::rustc_serialize::Decodable<__D>,
I::Term: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
ExistentialProjection {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
args: ::rustc_serialize::Decodable::decode(__decoder),
term: ::rustc_serialize::Decodable::decode(__decoder),
use_existential_projection_new_instead: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for ExistentialProjection<I>
where I::TraitAssocTermId: ::rustc_serialize::Encodable<__E>,
I::GenericArgs: ::rustc_serialize::Encodable<__E>,
I::Term: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
ExistentialProjection {
def_id: ref __binding_0,
args: ref __binding_1,
term: ref __binding_2,
use_existential_projection_new_instead: 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> ::rustc_data_structures::stable_hasher::StableHash
for ExistentialProjection<I> where
I::TraitAssocTermId: ::rustc_data_structures::stable_hasher::StableHash,
I::GenericArgs: ::rustc_data_structures::stable_hasher::StableHash,
I::Term: ::rustc_data_structures::stable_hasher::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ExistentialProjection {
def_id: ref __binding_0,
args: ref __binding_1,
term: ref __binding_2,
use_existential_projection_new_instead: ref __binding_3 } =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
473)]
474pub struct ExistentialProjection<I: Interner> {
475 pub def_id: I::TraitAssocTermId,
476 pub args: I::GenericArgs,
477 pub term: I::Term,
478
479 #[derive_where(skip(Debug))]
482 use_existential_projection_new_instead: (),
483}
484
485impl<I: Interner> Eq for ExistentialProjection<I> {}
486
487impl<I: Interner> ExistentialProjection<I> {
488 pub fn new_from_args(
489 interner: I,
490 def_id: I::TraitAssocTermId,
491 args: I::GenericArgs,
492 term: I::Term,
493 ) -> ExistentialProjection<I> {
494 interner.debug_assert_existential_args_compatible(def_id.into(), args);
495 Self { def_id, args, term, use_existential_projection_new_instead: () }
496 }
497
498 pub fn new(
499 interner: I,
500 def_id: I::TraitAssocTermId,
501 args: impl IntoIterator<Item: Into<I::GenericArg>>,
502 term: I::Term,
503 ) -> ExistentialProjection<I> {
504 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
505 Self::new_from_args(interner, def_id, args, term)
506 }
507
508 pub fn trait_ref(&self, interner: I) -> ExistentialTraitRef<I> {
514 let def_id = interner.projection_parent(self.def_id);
515 let args_count = interner.generics_of(def_id.into()).count() - 1;
516 let args = interner.mk_args(&self.args.as_slice()[..args_count]);
517 ExistentialTraitRef::new_from_args(interner, def_id, args)
518 }
519
520 pub fn with_self_ty(&self, interner: I, self_ty: I::Ty) -> ProjectionPredicate<I> {
521 if true {
if !!self_ty.has_escaping_bound_vars() {
::core::panicking::panic("assertion failed: !self_ty.has_escaping_bound_vars()")
};
};debug_assert!(!self_ty.has_escaping_bound_vars());
523
524 ProjectionPredicate {
525 projection_term: AliasTerm::new(
526 interner,
527 interner.alias_term_kind_from_def_id(self.def_id.into()),
528 [self_ty.into()].iter().chain(self.args.iter()),
529 ),
530 term: self.term,
531 }
532 }
533
534 pub fn erase_self_ty(interner: I, projection_predicate: ProjectionPredicate<I>) -> Self {
535 projection_predicate.projection_term.args.type_at(0);
537
538 Self {
539 def_id: projection_predicate.def_id(),
540 args: interner.mk_args(&projection_predicate.projection_term.args.as_slice()[1..]),
541 term: projection_predicate.term,
542 use_existential_projection_new_instead: (),
543 }
544 }
545}
546
547impl<I: Interner> ty::Binder<I, ExistentialProjection<I>> {
548 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, ProjectionPredicate<I>> {
549 self.map_bound(|p| p.with_self_ty(cx, self_ty))
550 }
551
552 pub fn item_def_id(&self) -> I::TraitAssocTermId {
553 self.skip_binder().def_id
554 }
555}
556
557#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for AliasTermKind<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
AliasTermKind::ProjectionTy { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "ProjectionTy");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
AliasTermKind::InherentTy { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "InherentTy");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
AliasTermKind::OpaqueTy { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "OpaqueTy");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
AliasTermKind::FreeTy { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "FreeTy");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
AliasTermKind::UnevaluatedConst { def_id: ref __field_def_id } =>
{
let mut __builder =
::core::fmt::Formatter::debug_struct(__f,
"UnevaluatedConst");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
AliasTermKind::ProjectionConst { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f,
"ProjectionConst");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
AliasTermKind::FreeConst { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "FreeConst");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
AliasTermKind::InherentConst { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "InherentConst");
::core::fmt::DebugStruct::field(&mut __builder, "def_id",
__field_def_id);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, PartialEq, Eq, Hash, Debug; I: Interner)]
558#[derive(const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
AliasTermKind<I> where I: Interner, J: Interner,
I::TraitAssocTyId: ::rustc_type_ir::lift::Lift<J, Lifted =
J::TraitAssocTyId>,
I::InherentAssocTyId: ::rustc_type_ir::lift::Lift<J, Lifted =
J::InherentAssocTyId>,
I::OpaqueTyId: ::rustc_type_ir::lift::Lift<J, Lifted =
J::OpaqueTyId>,
I::FreeTyAliasId: ::rustc_type_ir::lift::Lift<J, Lifted =
J::FreeTyAliasId>,
I::UnevaluatedConstId: ::rustc_type_ir::lift::Lift<J, Lifted =
J::UnevaluatedConstId>,
I::TraitAssocConstId: ::rustc_type_ir::lift::Lift<J, Lifted =
J::TraitAssocConstId>,
I::FreeConstAliasId: ::rustc_type_ir::lift::Lift<J, Lifted =
J::FreeConstAliasId>,
I::InherentAssocConstId: ::rustc_type_ir::lift::Lift<J, Lifted =
J::InherentAssocConstId> {
type Lifted = AliasTermKind<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
AliasTermKind::ProjectionTy { def_id: __binding_0 } => {
AliasTermKind::ProjectionTy {
def_id: __binding_0.lift_to_interner(interner),
}
}
AliasTermKind::InherentTy { def_id: __binding_0 } => {
AliasTermKind::InherentTy {
def_id: __binding_0.lift_to_interner(interner),
}
}
AliasTermKind::OpaqueTy { def_id: __binding_0 } => {
AliasTermKind::OpaqueTy {
def_id: __binding_0.lift_to_interner(interner),
}
}
AliasTermKind::FreeTy { def_id: __binding_0 } => {
AliasTermKind::FreeTy {
def_id: __binding_0.lift_to_interner(interner),
}
}
AliasTermKind::UnevaluatedConst { def_id: __binding_0 } => {
AliasTermKind::UnevaluatedConst {
def_id: __binding_0.lift_to_interner(interner),
}
}
AliasTermKind::ProjectionConst { def_id: __binding_0 } => {
AliasTermKind::ProjectionConst {
def_id: __binding_0.lift_to_interner(interner),
}
}
AliasTermKind::FreeConst { def_id: __binding_0 } => {
AliasTermKind::FreeConst {
def_id: __binding_0.lift_to_interner(interner),
}
}
AliasTermKind::InherentConst { def_id: __binding_0 } => {
AliasTermKind::InherentConst {
def_id: __binding_0.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic, GenericTypeVisitable)]
559#[cfg_attr(
560 feature = "nightly",
561 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for AliasTermKind<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>,
I::UnevaluatedConstId: ::rustc_serialize::Encodable<__E>,
I::TraitAssocConstId: ::rustc_serialize::Encodable<__E>,
I::FreeConstAliasId: ::rustc_serialize::Encodable<__E>,
I::InherentAssocConstId: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
AliasTermKind::ProjectionTy { def_id: ref __binding_0 } => {
0usize
}
AliasTermKind::InherentTy { def_id: ref __binding_0 } => {
1usize
}
AliasTermKind::OpaqueTy { def_id: ref __binding_0 } => {
2usize
}
AliasTermKind::FreeTy { def_id: ref __binding_0 } => {
3usize
}
AliasTermKind::UnevaluatedConst { def_id: ref __binding_0 }
=> {
4usize
}
AliasTermKind::ProjectionConst { def_id: ref __binding_0 }
=> {
5usize
}
AliasTermKind::FreeConst { def_id: ref __binding_0 } => {
6usize
}
AliasTermKind::InherentConst { def_id: ref __binding_0 } =>
{
7usize
}
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
AliasTermKind::ProjectionTy { def_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AliasTermKind::InherentTy { def_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AliasTermKind::OpaqueTy { def_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AliasTermKind::FreeTy { def_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AliasTermKind::UnevaluatedConst { def_id: ref __binding_0 }
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AliasTermKind::ProjectionConst { def_id: ref __binding_0 }
=> {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AliasTermKind::FreeConst { def_id: ref __binding_0 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AliasTermKind::InherentConst { 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 AliasTermKind<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>,
I::UnevaluatedConstId: ::rustc_serialize::Decodable<__D>,
I::TraitAssocConstId: ::rustc_serialize::Decodable<__D>,
I::FreeConstAliasId: ::rustc_serialize::Decodable<__D>,
I::InherentAssocConstId: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
AliasTermKind::ProjectionTy {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
1usize => {
AliasTermKind::InherentTy {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
2usize => {
AliasTermKind::OpaqueTy {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
3usize => {
AliasTermKind::FreeTy {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
4usize => {
AliasTermKind::UnevaluatedConst {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
5usize => {
AliasTermKind::ProjectionConst {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
6usize => {
AliasTermKind::FreeConst {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
7usize => {
AliasTermKind::InherentConst {
def_id: ::rustc_serialize::Decodable::decode(__decoder),
}
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `AliasTermKind`, expected 0..8, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hasher::StableHash
for AliasTermKind<I> where
I::TraitAssocTyId: ::rustc_data_structures::stable_hasher::StableHash,
I::InherentAssocTyId: ::rustc_data_structures::stable_hasher::StableHash,
I::OpaqueTyId: ::rustc_data_structures::stable_hasher::StableHash,
I::FreeTyAliasId: ::rustc_data_structures::stable_hasher::StableHash,
I::UnevaluatedConstId: ::rustc_data_structures::stable_hasher::StableHash,
I::TraitAssocConstId: ::rustc_data_structures::stable_hasher::StableHash,
I::FreeConstAliasId: ::rustc_data_structures::stable_hasher::StableHash,
I::InherentAssocConstId: ::rustc_data_structures::stable_hasher::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
AliasTermKind::ProjectionTy { def_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AliasTermKind::InherentTy { def_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AliasTermKind::OpaqueTy { def_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AliasTermKind::FreeTy { def_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AliasTermKind::UnevaluatedConst { def_id: ref __binding_0 }
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AliasTermKind::ProjectionConst { def_id: ref __binding_0 }
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AliasTermKind::FreeConst { def_id: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
AliasTermKind::InherentConst { def_id: ref __binding_0 } =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
562)]
563pub enum AliasTermKind<I: Interner> {
564 ProjectionTy { def_id: I::TraitAssocTyId },
574
575 InherentTy { def_id: I::InherentAssocTyId },
579
580 OpaqueTy { def_id: I::OpaqueTyId },
589
590 FreeTy { def_id: I::FreeTyAliasId },
595
596 UnevaluatedConst { def_id: I::UnevaluatedConstId },
598 ProjectionConst { def_id: I::TraitAssocConstId },
600 FreeConst { def_id: I::FreeConstAliasId },
602 InherentConst { def_id: I::InherentAssocConstId },
604}
605
606impl<I: Interner> AliasTermKind<I> {
607 pub fn descr(self) -> &'static str {
608 match self {
609 AliasTermKind::ProjectionTy { .. } => "associated type",
610 AliasTermKind::ProjectionConst { .. } => "associated const",
611 AliasTermKind::InherentTy { .. } => "inherent associated type",
612 AliasTermKind::InherentConst { .. } => "inherent associated const",
613 AliasTermKind::OpaqueTy { .. } => "opaque type",
614 AliasTermKind::FreeTy { .. } => "type alias",
615 AliasTermKind::FreeConst { .. } => "unevaluated constant",
616 AliasTermKind::UnevaluatedConst { .. } => "unevaluated constant",
617 }
618 }
619
620 pub fn is_type(self) -> bool {
621 match self {
622 AliasTermKind::ProjectionTy { .. }
623 | AliasTermKind::InherentTy { .. }
624 | AliasTermKind::OpaqueTy { .. }
625 | AliasTermKind::FreeTy { .. } => true,
626
627 AliasTermKind::UnevaluatedConst { .. }
628 | AliasTermKind::ProjectionConst { .. }
629 | AliasTermKind::InherentConst { .. }
630 | AliasTermKind::FreeConst { .. } => false,
631 }
632 }
633
634 pub fn def_id(self) -> I::DefId {
636 match self {
637 AliasTermKind::ProjectionTy { def_id } => def_id.into(),
638 AliasTermKind::InherentTy { def_id } => def_id.into(),
639 AliasTermKind::OpaqueTy { def_id } => def_id.into(),
640 AliasTermKind::FreeTy { def_id } => def_id.into(),
641 AliasTermKind::UnevaluatedConst { def_id } => def_id.into(),
642 AliasTermKind::ProjectionConst { def_id } => def_id.into(),
643 AliasTermKind::FreeConst { def_id } => def_id.into(),
644 AliasTermKind::InherentConst { def_id } => def_id.into(),
645 }
646 }
647}
648
649impl<I: Interner> From<ty::AliasTyKind<I>> for AliasTermKind<I> {
650 fn from(value: ty::AliasTyKind<I>) -> Self {
651 match value {
652 ty::Projection { def_id } => AliasTermKind::ProjectionTy { def_id },
653 ty::Opaque { def_id } => AliasTermKind::OpaqueTy { def_id },
654 ty::Free { def_id } => AliasTermKind::FreeTy { def_id },
655 ty::Inherent { def_id } => AliasTermKind::InherentTy { def_id },
656 }
657 }
658}
659
660#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for AliasTerm<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
AliasTerm {
args: ref __field_args,
kind: ref __field_kind,
_use_alias_term_new_instead: ref __field__use_alias_term_new_instead
} => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "AliasTerm");
::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)]
666#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for AliasTerm<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 {
AliasTerm {
args: ref __binding_0,
_use_alias_term_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 AliasTerm<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 {
AliasTerm {
args: __binding_0,
kind: __binding_1,
_use_alias_term_new_instead: __binding_2 } => {
AliasTerm {
args: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
kind: __binding_1,
_use_alias_term_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 {
AliasTerm {
args: __binding_0,
kind: __binding_1,
_use_alias_term_new_instead: __binding_2 } => {
AliasTerm {
args: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
kind: __binding_1,
_use_alias_term_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 AliasTerm<I>
where I: Interner, J: Interner,
I::GenericArgs: ::rustc_type_ir::lift::Lift<J, Lifted =
J::GenericArgs>,
AliasTermKind<I>: ::rustc_type_ir::lift::Lift<J, Lifted =
AliasTermKind<J>>, (): ::rustc_type_ir::lift::Lift<J, Lifted = ()>
{
type Lifted = AliasTerm<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
AliasTerm {
args: __binding_0,
kind: __binding_1,
_use_alias_term_new_instead: __binding_2 } => {
AliasTerm {
args: __binding_0.lift_to_interner(interner),
kind: __binding_1.lift_to_interner(interner),
_use_alias_term_new_instead: __binding_2.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
667#[cfg_attr(
668 feature = "nightly",
669 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for AliasTerm<I> where
I::GenericArgs: ::rustc_serialize::Decodable<__D>,
AliasTermKind<I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
AliasTerm {
args: ::rustc_serialize::Decodable::decode(__decoder),
kind: ::rustc_serialize::Decodable::decode(__decoder),
_use_alias_term_new_instead: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for AliasTerm<I> where
I::GenericArgs: ::rustc_serialize::Encodable<__E>,
AliasTermKind<I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
AliasTerm {
args: ref __binding_0,
kind: ref __binding_1,
_use_alias_term_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_hasher::StableHash
for AliasTerm<I> where
I::GenericArgs: ::rustc_data_structures::stable_hasher::StableHash,
AliasTermKind<I>: ::rustc_data_structures::stable_hasher::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
AliasTerm {
args: ref __binding_0,
kind: ref __binding_1,
_use_alias_term_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)
670)]
671pub struct AliasTerm<I: Interner> {
672 pub args: I::GenericArgs,
683
684 #[type_foldable(identity)]
685 #[type_visitable(ignore)]
686 pub kind: AliasTermKind<I>,
687
688 #[derive_where(skip(Debug))]
690 _use_alias_term_new_instead: (),
691}
692
693impl<I: Interner> Eq for AliasTerm<I> {}
694
695impl<I: Interner> AliasTerm<I> {
696 pub fn new_from_args(
697 interner: I,
698 kind: AliasTermKind<I>,
699 args: I::GenericArgs,
700 ) -> AliasTerm<I> {
701 interner.debug_assert_args_compatible(kind.def_id(), args);
702 AliasTerm { kind, args, _use_alias_term_new_instead: () }
703 }
704
705 pub fn new(
706 interner: I,
707 kind: AliasTermKind<I>,
708 args: impl IntoIterator<Item: Into<I::GenericArg>>,
709 ) -> AliasTerm<I> {
710 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
711 Self::new_from_args(interner, kind, args)
712 }
713
714 pub fn new_from_def_id(interner: I, def_id: I::DefId, args: I::GenericArgs) -> AliasTerm<I> {
715 let kind = interner.alias_term_kind_from_def_id(def_id);
716 Self::new_from_args(interner, kind, args)
717 }
718
719 pub fn from_unevaluated_const(interner: I, ct: ty::UnevaluatedConst<I>) -> Self {
720 let kind = interner.alias_term_kind_from_def_id(ct.def.into());
721 AliasTerm::new_from_args(interner, kind, ct.args)
722 }
723
724 pub fn expect_ty(self, interner: I) -> ty::AliasTy<I> {
725 let kind = match self.kind(interner) {
726 AliasTermKind::ProjectionTy { def_id } => AliasTyKind::Projection { def_id },
727 AliasTermKind::InherentTy { def_id } => AliasTyKind::Inherent { def_id },
728 AliasTermKind::OpaqueTy { def_id } => AliasTyKind::Opaque { def_id },
729 AliasTermKind::FreeTy { def_id } => AliasTyKind::Free { def_id },
730 kind @ (AliasTermKind::InherentConst { .. }
731 | AliasTermKind::FreeConst { .. }
732 | AliasTermKind::UnevaluatedConst { .. }
733 | AliasTermKind::ProjectionConst { .. }) => {
734 {
::core::panicking::panic_fmt(format_args!("Cannot turn `{0}` into `AliasTy`",
kind.descr()));
}panic!("Cannot turn `{}` into `AliasTy`", kind.descr())
735 }
736 };
737 ty::AliasTy { kind, args: self.args, _use_alias_ty_new_instead: () }
738 }
739
740 pub fn expect_ct(self, interner: I) -> ty::UnevaluatedConst<I> {
741 let def = match self.kind(interner) {
742 AliasTermKind::InherentConst { def_id } => def_id.into(),
743 AliasTermKind::FreeConst { def_id } => def_id.into(),
744 AliasTermKind::UnevaluatedConst { def_id } => def_id,
745 AliasTermKind::ProjectionConst { def_id } => def_id.into(),
746 kind @ (AliasTermKind::ProjectionTy { .. }
747 | AliasTermKind::InherentTy { .. }
748 | AliasTermKind::OpaqueTy { .. }
749 | AliasTermKind::FreeTy { .. }) => {
750 {
::core::panicking::panic_fmt(format_args!("Cannot turn `{0}` into `UnevaluatedConst`",
kind.descr()));
}panic!("Cannot turn `{}` into `UnevaluatedConst`", kind.descr())
751 }
752 };
753 ty::UnevaluatedConst { def, args: self.args }
754 }
755
756 pub fn kind(self, _interner: I) -> AliasTermKind<I> {
758 self.kind
759 }
760
761 pub fn def_id(self) -> I::DefId {
763 self.kind.def_id()
764 }
765
766 pub fn to_term(self, interner: I) -> I::Term {
767 let unevaluated_const = |def_id| {
768 I::Const::new_unevaluated(interner, ty::UnevaluatedConst::new(def_id, self.args)).into()
769 };
770 let alias_ty_kind = match self.kind(interner) {
771 AliasTermKind::FreeConst { def_id } => return unevaluated_const(def_id.into()),
772 AliasTermKind::InherentConst { def_id } => return unevaluated_const(def_id.into()),
773 AliasTermKind::UnevaluatedConst { def_id } => return unevaluated_const(def_id),
774 AliasTermKind::ProjectionConst { def_id } => return unevaluated_const(def_id.into()),
775
776 AliasTermKind::ProjectionTy { def_id } => ty::Projection { def_id },
777 AliasTermKind::InherentTy { def_id } => ty::Inherent { def_id },
778 AliasTermKind::OpaqueTy { def_id } => ty::Opaque { def_id },
779 AliasTermKind::FreeTy { def_id } => ty::Free { def_id },
780 };
781
782 Ty::new_alias(interner, ty::AliasTy::new_from_args(interner, alias_ty_kind, self.args))
783 .into()
784 }
785
786 pub fn with_args(self, interner: I, args: I::GenericArgs) -> Self {
787 Self::new_from_args(interner, self.kind, args)
788 }
789}
790
791impl<I: Interner> AliasTerm<I> {
793 pub fn self_ty(self) -> I::Ty {
794 self.args.type_at(0)
795 }
796
797 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
798 AliasTerm::new(
799 interner,
800 self.kind,
801 [self_ty.into()].into_iter().chain(self.args.iter().skip(1)),
802 )
803 }
804
805 fn projection_def_id(self) -> Option<I::TraitAssocTermId> {
806 match self.kind {
807 AliasTermKind::ProjectionTy { def_id } => Some(def_id.into()),
808 AliasTermKind::ProjectionConst { def_id } => Some(def_id.into()),
809 AliasTermKind::InherentTy { .. }
810 | AliasTermKind::OpaqueTy { .. }
811 | AliasTermKind::FreeTy { .. }
812 | AliasTermKind::UnevaluatedConst { .. }
813 | AliasTermKind::FreeConst { .. }
814 | AliasTermKind::InherentConst { .. } => None,
815 }
816 }
817
818 fn expect_projection_def_id(self) -> I::TraitAssocTermId {
819 self.projection_def_id().expect("expected a projection")
820 }
821
822 pub fn trait_def_id(self, interner: I) -> I::TraitId {
823 interner.projection_parent(self.expect_projection_def_id())
824 }
825
826 pub fn trait_ref_and_own_args(self, interner: I) -> (TraitRef<I>, I::GenericArgsSlice) {
831 interner.trait_ref_and_own_args_for_alias(self.expect_projection_def_id(), self.args)
832 }
833
834 pub fn trait_ref(self, interner: I) -> TraitRef<I> {
842 self.trait_ref_and_own_args(interner).0
843 }
844
845 pub fn own_args(self, interner: I) -> I::GenericArgsSlice {
849 self.trait_ref_and_own_args(interner).1
850 }
851}
852
853impl<I: Interner> AliasTerm<I> {
855 pub fn rebase_inherent_args_onto_impl(
866 self,
867 impl_args: I::GenericArgs,
868 interner: I,
869 ) -> I::GenericArgs {
870 if true {
if !#[allow(non_exhaustive_omitted_patterns)] match self.kind(interner) {
AliasTermKind::InherentTy { .. } |
AliasTermKind::InherentConst { .. } => true,
_ => false,
} {
::core::panicking::panic("assertion failed: matches!(self.kind(interner), AliasTermKind::InherentTy { .. } |\n AliasTermKind::InherentConst { .. })")
};
};debug_assert!(matches!(
871 self.kind(interner),
872 AliasTermKind::InherentTy { .. } | AliasTermKind::InherentConst { .. }
873 ));
874 interner.mk_args_from_iter(impl_args.iter().chain(self.args.iter().skip(1)))
875 }
876}
877
878impl<I: Interner> From<ty::AliasTy<I>> for AliasTerm<I> {
879 fn from(ty: ty::AliasTy<I>) -> Self {
880 AliasTerm {
881 args: ty.args,
882 kind: AliasTermKind::from(ty.kind),
883 _use_alias_term_new_instead: (),
884 }
885 }
886}
887
888#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ProjectionPredicate<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(ProjectionPredicate {
projection_term: ref __field_projection_term,
term: ref __field_term }, ProjectionPredicate {
projection_term: ref __other_field_projection_term,
term: ref __other_field_term }) =>
true &&
::core::cmp::PartialEq::eq(__field_projection_term,
__other_field_projection_term) &&
::core::cmp::PartialEq::eq(__field_term,
__other_field_term),
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
901#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
ProjectionPredicate<I> where I: Interner,
AliasTerm<I>: ::rustc_type_ir::TypeVisitable<I>,
I::Term: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
ProjectionPredicate {
projection_term: ref __binding_0, term: 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
ProjectionPredicate<I> where I: Interner,
AliasTerm<I>: ::rustc_type_ir::TypeFoldable<I>,
I::Term: ::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 {
ProjectionPredicate {
projection_term: __binding_0, term: __binding_1 } => {
ProjectionPredicate {
projection_term: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
term: ::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 {
ProjectionPredicate {
projection_term: __binding_0, term: __binding_1 } => {
ProjectionPredicate {
projection_term: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
term: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
ProjectionPredicate<I> where I: Interner, J: Interner,
AliasTerm<I>: ::rustc_type_ir::lift::Lift<J, Lifted =
AliasTerm<J>>,
I::Term: ::rustc_type_ir::lift::Lift<J, Lifted = J::Term> {
type Lifted = ProjectionPredicate<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
ProjectionPredicate {
projection_term: __binding_0, term: __binding_1 } => {
ProjectionPredicate {
projection_term: __binding_0.lift_to_interner(interner),
term: __binding_1.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
902#[cfg_attr(
903 feature = "nightly",
904 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for ProjectionPredicate<I> where
AliasTerm<I>: ::rustc_serialize::Decodable<__D>,
I::Term: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
ProjectionPredicate {
projection_term: ::rustc_serialize::Decodable::decode(__decoder),
term: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for ProjectionPredicate<I> where
AliasTerm<I>: ::rustc_serialize::Encodable<__E>,
I::Term: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
ProjectionPredicate {
projection_term: ref __binding_0, term: 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> ::rustc_data_structures::stable_hasher::StableHash
for ProjectionPredicate<I> where
AliasTerm<I>: ::rustc_data_structures::stable_hasher::StableHash,
I::Term: ::rustc_data_structures::stable_hasher::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ProjectionPredicate {
projection_term: ref __binding_0, term: ref __binding_1 } =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
905)]
906pub struct ProjectionPredicate<I: Interner> {
907 pub projection_term: AliasTerm<I>,
908 pub term: I::Term,
909}
910
911impl<I: Interner> Eq for ProjectionPredicate<I> {}
912
913impl<I: Interner> ProjectionPredicate<I> {
914 pub fn self_ty(self) -> I::Ty {
915 self.projection_term.self_ty()
916 }
917
918 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> ProjectionPredicate<I> {
919 Self {
920 projection_term: self.projection_term.with_replaced_self_ty(interner, self_ty),
921 ..self
922 }
923 }
924
925 pub fn trait_def_id(self, interner: I) -> I::TraitId {
926 self.projection_term.trait_def_id(interner)
927 }
928
929 pub fn def_id(self) -> I::TraitAssocTermId {
930 self.projection_term.expect_projection_def_id()
931 }
932}
933
934impl<I: Interner> ty::Binder<I, ProjectionPredicate<I>> {
935 #[inline]
937 pub fn trait_def_id(&self, cx: I) -> I::TraitId {
938 self.skip_binder().projection_term.trait_def_id(cx)
939 }
940
941 pub fn term(&self) -> ty::Binder<I, I::Term> {
942 self.map_bound(|predicate| predicate.term)
943 }
944
945 pub fn item_def_id(&self) -> I::DefId {
950 self.skip_binder().projection_term.def_id()
952 }
953}
954
955impl<I: Interner> fmt::Debug for ProjectionPredicate<I> {
956 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
957 f.write_fmt(format_args!("ProjectionPredicate({0:?}, {1:?})",
self.projection_term, self.term))write!(f, "ProjectionPredicate({:?}, {:?})", self.projection_term, self.term)
958 }
959}
960
961#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for NormalizesTo<I> where I: Interner
{
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(NormalizesTo { alias: ref __field_alias, term: ref __field_term
}, NormalizesTo {
alias: ref __other_field_alias, term: ref __other_field_term
}) =>
true &&
::core::cmp::PartialEq::eq(__field_alias,
__other_field_alias) &&
::core::cmp::PartialEq::eq(__field_term,
__other_field_term),
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq; I: Interner)]
964#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
NormalizesTo<I> where I: Interner,
AliasTerm<I>: ::rustc_type_ir::TypeVisitable<I>,
I::Term: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
NormalizesTo { alias: ref __binding_0, term: 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 NormalizesTo<I>
where I: Interner, AliasTerm<I>: ::rustc_type_ir::TypeFoldable<I>,
I::Term: ::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 {
NormalizesTo { alias: __binding_0, term: __binding_1 } => {
NormalizesTo {
alias: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
term: ::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 {
NormalizesTo { alias: __binding_0, term: __binding_1 } => {
NormalizesTo {
alias: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
term: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
NormalizesTo<I> where I: Interner, J: Interner,
AliasTerm<I>: ::rustc_type_ir::lift::Lift<J, Lifted =
AliasTerm<J>>,
I::Term: ::rustc_type_ir::lift::Lift<J, Lifted = J::Term> {
type Lifted = NormalizesTo<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
NormalizesTo { alias: __binding_0, term: __binding_1 } => {
NormalizesTo {
alias: __binding_0.lift_to_interner(interner),
term: __binding_1.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
965#[cfg_attr(
966 feature = "nightly",
967 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for NormalizesTo<I> where
AliasTerm<I>: ::rustc_serialize::Decodable<__D>,
I::Term: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
NormalizesTo {
alias: ::rustc_serialize::Decodable::decode(__decoder),
term: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for NormalizesTo<I> where
AliasTerm<I>: ::rustc_serialize::Encodable<__E>,
I::Term: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
NormalizesTo { alias: ref __binding_0, term: 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> ::rustc_data_structures::stable_hasher::StableHash
for NormalizesTo<I> where
AliasTerm<I>: ::rustc_data_structures::stable_hasher::StableHash,
I::Term: ::rustc_data_structures::stable_hasher::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
NormalizesTo { alias: ref __binding_0, term: ref __binding_1
} => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
968)]
969pub struct NormalizesTo<I: Interner> {
970 pub alias: AliasTerm<I>,
971 pub term: I::Term,
972}
973
974impl<I: Interner> Eq for NormalizesTo<I> {}
975
976impl<I: Interner> NormalizesTo<I> {
977 pub fn self_ty(self) -> I::Ty {
978 self.alias.self_ty()
979 }
980
981 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> NormalizesTo<I> {
982 Self { alias: self.alias.with_replaced_self_ty(interner, self_ty), ..self }
983 }
984
985 pub fn trait_def_id(self, interner: I) -> I::TraitId {
986 self.alias.trait_def_id(interner)
987 }
988
989 pub fn def_id(self) -> I::DefId {
990 self.alias.def_id()
991 }
992}
993
994impl<I: Interner> fmt::Debug for NormalizesTo<I> {
995 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
996 f.write_fmt(format_args!("NormalizesTo({0:?}, {1:?})", self.alias, self.term))write!(f, "NormalizesTo({:?}, {:?})", self.alias, self.term)
997 }
998}
999
1000#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for HostEffectPredicate<I> where
I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
HostEffectPredicate {
trait_ref: ref __field_trait_ref,
constness: ref __field_constness } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f,
"HostEffectPredicate");
::core::fmt::DebugStruct::field(&mut __builder, "trait_ref",
__field_trait_ref);
::core::fmt::DebugStruct::field(&mut __builder, "constness",
__field_constness);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
1001#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
HostEffectPredicate<I> where I: Interner,
ty::TraitRef<I>: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
HostEffectPredicate {
trait_ref: ref __binding_0, constness: 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
HostEffectPredicate<I> where I: Interner,
ty::TraitRef<I>: ::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 {
HostEffectPredicate {
trait_ref: __binding_0, constness: __binding_1 } => {
HostEffectPredicate {
trait_ref: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
constness: ::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 {
HostEffectPredicate {
trait_ref: __binding_0, constness: __binding_1 } => {
HostEffectPredicate {
trait_ref: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
constness: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
HostEffectPredicate<I> where I: Interner, J: Interner,
ty::TraitRef<I>: ::rustc_type_ir::lift::Lift<J, Lifted =
ty::TraitRef<J>>,
BoundConstness: ::rustc_type_ir::lift::Lift<J, Lifted =
BoundConstness> {
type Lifted = HostEffectPredicate<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
HostEffectPredicate {
trait_ref: __binding_0, constness: __binding_1 } => {
HostEffectPredicate {
trait_ref: __binding_0.lift_to_interner(interner),
constness: __binding_1.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
1002#[cfg_attr(
1003 feature = "nightly",
1004 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for HostEffectPredicate<I> where
ty::TraitRef<I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
HostEffectPredicate {
trait_ref: ref __binding_0, constness: 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 HostEffectPredicate<I> where
ty::TraitRef<I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
HostEffectPredicate {
trait_ref: ::rustc_serialize::Decodable::decode(__decoder),
constness: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hasher::StableHash
for HostEffectPredicate<I> where
ty::TraitRef<I>: ::rustc_data_structures::stable_hasher::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
HostEffectPredicate {
trait_ref: ref __binding_0, constness: ref __binding_1 } =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
1005)]
1006pub struct HostEffectPredicate<I: Interner> {
1007 pub trait_ref: ty::TraitRef<I>,
1008 pub constness: BoundConstness,
1009}
1010
1011impl<I: Interner> Eq for HostEffectPredicate<I> {}
1012
1013impl<I: Interner> HostEffectPredicate<I> {
1014 pub fn self_ty(self) -> I::Ty {
1015 self.trait_ref.self_ty()
1016 }
1017
1018 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
1019 Self { trait_ref: self.trait_ref.with_replaced_self_ty(interner, self_ty), ..self }
1020 }
1021
1022 pub fn def_id(self) -> I::TraitId {
1023 self.trait_ref.def_id
1024 }
1025}
1026
1027impl<I: Interner> ty::Binder<I, HostEffectPredicate<I>> {
1028 pub fn def_id(self) -> I::TraitId {
1029 self.skip_binder().def_id()
1031 }
1032
1033 pub fn self_ty(self) -> ty::Binder<I, I::Ty> {
1034 self.map_bound(|trait_ref| trait_ref.self_ty())
1035 }
1036
1037 #[inline]
1038 pub fn constness(self) -> BoundConstness {
1039 self.skip_binder().constness
1040 }
1041}
1042
1043#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for SubtypePredicate<I> where I: Interner
{
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
SubtypePredicate {
a_is_expected: ref __field_a_is_expected,
a: ref __field_a,
b: ref __field_b } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f,
"SubtypePredicate");
::core::fmt::DebugStruct::field(&mut __builder,
"a_is_expected", __field_a_is_expected);
::core::fmt::DebugStruct::field(&mut __builder, "a",
__field_a);
::core::fmt::DebugStruct::field(&mut __builder, "b",
__field_b);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
1047#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
SubtypePredicate<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 {
SubtypePredicate {
a_is_expected: ref __binding_0,
a: ref __binding_1,
b: 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
SubtypePredicate<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 {
SubtypePredicate {
a_is_expected: __binding_0, a: __binding_1, b: __binding_2 }
=> {
SubtypePredicate {
a_is_expected: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
a: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
b: ::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 {
SubtypePredicate {
a_is_expected: __binding_0, a: __binding_1, b: __binding_2 }
=> {
SubtypePredicate {
a_is_expected: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
a: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
b: ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
SubtypePredicate<I> where I: Interner, J: Interner,
bool: ::rustc_type_ir::lift::Lift<J, Lifted = bool>,
I::Ty: ::rustc_type_ir::lift::Lift<J, Lifted = J::Ty>,
I::Ty: ::rustc_type_ir::lift::Lift<J, Lifted = J::Ty> {
type Lifted = SubtypePredicate<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
SubtypePredicate {
a_is_expected: __binding_0, a: __binding_1, b: __binding_2 }
=> {
SubtypePredicate {
a_is_expected: __binding_0.lift_to_interner(interner),
a: __binding_1.lift_to_interner(interner),
b: __binding_2.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
1048#[cfg_attr(
1049 feature = "nightly",
1050 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for SubtypePredicate<I> where
I::Ty: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
SubtypePredicate {
a_is_expected: ::rustc_serialize::Decodable::decode(__decoder),
a: ::rustc_serialize::Decodable::decode(__decoder),
b: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for SubtypePredicate<I> where
I::Ty: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
SubtypePredicate {
a_is_expected: ref __binding_0,
a: ref __binding_1,
b: 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_hasher::StableHash
for SubtypePredicate<I> where
I::Ty: ::rustc_data_structures::stable_hasher::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
SubtypePredicate {
a_is_expected: ref __binding_0,
a: ref __binding_1,
b: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
1051)]
1052pub struct SubtypePredicate<I: Interner> {
1053 pub a_is_expected: bool,
1054 pub a: I::Ty,
1055 pub b: I::Ty,
1056}
1057
1058impl<I: Interner> Eq for SubtypePredicate<I> {}
1059
1060#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for CoercePredicate<I> where I: Interner
{
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
CoercePredicate { a: ref __field_a, b: ref __field_b } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f,
"CoercePredicate");
::core::fmt::DebugStruct::field(&mut __builder, "a",
__field_a);
::core::fmt::DebugStruct::field(&mut __builder, "b",
__field_b);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Copy, Hash, PartialEq, Debug; I: Interner)]
1062#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
CoercePredicate<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 {
CoercePredicate { a: ref __binding_0, b: 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
CoercePredicate<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 {
CoercePredicate { a: __binding_0, b: __binding_1 } => {
CoercePredicate {
a: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
b: ::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 {
CoercePredicate { a: __binding_0, b: __binding_1 } => {
CoercePredicate {
a: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
b: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
CoercePredicate<I> where I: Interner, J: Interner,
I::Ty: ::rustc_type_ir::lift::Lift<J, Lifted = J::Ty>,
I::Ty: ::rustc_type_ir::lift::Lift<J, Lifted = J::Ty> {
type Lifted = CoercePredicate<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
CoercePredicate { a: __binding_0, b: __binding_1 } => {
CoercePredicate {
a: __binding_0.lift_to_interner(interner),
b: __binding_1.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
1063#[cfg_attr(
1064 feature = "nightly",
1065 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for CoercePredicate<I> where
I::Ty: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
CoercePredicate {
a: ::rustc_serialize::Decodable::decode(__decoder),
b: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable_NoContext, const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for CoercePredicate<I> where
I::Ty: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
match *self {
CoercePredicate { a: ref __binding_0, b: 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> ::rustc_data_structures::stable_hasher::StableHash
for CoercePredicate<I> where
I::Ty: ::rustc_data_structures::stable_hasher::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
CoercePredicate { a: ref __binding_0, b: ref __binding_1 }
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
1066)]
1067pub struct CoercePredicate<I: Interner> {
1068 pub a: I::Ty,
1069 pub b: I::Ty,
1070}
1071
1072impl<I: Interner> Eq for CoercePredicate<I> {}
1073
1074#[derive(#[automatically_derived]
impl ::core::clone::Clone for BoundConstness {
#[inline]
fn clone(&self) -> BoundConstness { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for BoundConstness { }Copy, #[automatically_derived]
impl ::core::hash::Hash for BoundConstness {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::cmp::PartialEq for BoundConstness {
#[inline]
fn eq(&self, other: &BoundConstness) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for BoundConstness {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for BoundConstness {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
BoundConstness::Const => "Const",
BoundConstness::Maybe => "Maybe",
})
}
}Debug)]
1075#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for BoundConstness {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
BoundConstness::Const => { 0usize }
BoundConstness::Maybe => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
BoundConstness::Const => {}
BoundConstness::Maybe => {}
}
}
}
};Encodable_NoContext, const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for BoundConstness {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { BoundConstness::Const }
1usize => { BoundConstness::Maybe }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `BoundConstness`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl ::rustc_data_structures::stable_hasher::StableHash for
BoundConstness {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
BoundConstness::Const => {}
BoundConstness::Maybe => {}
}
}
}
};StableHash))]
1076pub enum BoundConstness {
1077 Const,
1081 Maybe,
1085}
1086
1087impl BoundConstness {
1088 pub fn satisfies(self, goal: BoundConstness) -> bool {
1089 match (self, goal) {
1090 (BoundConstness::Const, BoundConstness::Const | BoundConstness::Maybe) => true,
1091 (BoundConstness::Maybe, BoundConstness::Maybe) => true,
1092 (BoundConstness::Maybe, BoundConstness::Const) => false,
1093 }
1094 }
1095
1096 pub fn as_str(self) -> &'static str {
1097 match self {
1098 Self::Const => "const",
1099 Self::Maybe => "[const]",
1100 }
1101 }
1102}
1103
1104impl fmt::Display for BoundConstness {
1105 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1106 match self {
1107 Self::Const => f.write_str("const"),
1108 Self::Maybe => f.write_str("[const]"),
1109 }
1110 }
1111}