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::ty::AliasTerm;
13use crate::upcast::{Upcast, UpcastFrom};
14use crate::visit::TypeVisitableExt as _;
15use crate::{self as ty, Alias, AliasTyKind, Interner, UnevaluatedConstKind};
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>,
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, const _: () =
{
impl<I: Interner, A, J> ::rustc_type_ir::lift::Lift<J> for
OutlivesPredicate<I, A> where J: Interner,
I: ::rustc_type_ir::LiftInto<J>, A: ::rustc_type_ir::lift::Lift<J>
{
type Lifted =
OutlivesPredicate<J,
<A as ::rustc_type_ir::lift::Lift<J>>::Lifted>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
OutlivesPredicate(__binding_0, __binding_1) => {
OutlivesPredicate(__binding_0.lift_to_interner(interner),
__binding_1.lift_to_interner(interner))
}
}
}
}
};Lift_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_hash::StableHash
for OutlivesPredicate<I, A> where
A: ::rustc_data_structures::stable_hash::StableHash,
I::Region: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
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
29#[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)]
34#[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 J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
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)]
35#[cfg_attr(
36 feature = "nightly",
37 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_hash::StableHash for
RegionEqPredicate<I> where
I::Region: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
RegionEqPredicate(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
38)]
39pub struct RegionEqPredicate<I: Interner>(pub I::Region, pub I::Region);
40
41impl<I: Interner> RegionEqPredicate<I> {
42 pub fn into_bidirectional_outlives(self) -> [OutlivesPredicate<I, I::GenericArg>; 2] {
44 [OutlivesPredicate(self.0.into(), self.1), OutlivesPredicate(self.1.into(), self.0)]
45 }
46}
47
48#[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)]
49#[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 J: Interner,
I: ::rustc_type_ir::LiftInto<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)]
50#[cfg_attr(
51 feature = "nightly",
52 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_hash::StableHash for
RegionConstraint<I> where
OutlivesPredicate<I,
I::GenericArg>: ::rustc_data_structures::stable_hash::StableHash,
RegionEqPredicate<I>: ::rustc_data_structures::stable_hash::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::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)
53)]
54pub enum RegionConstraint<I: Interner> {
55 Outlives(OutlivesPredicate<I, I::GenericArg>),
56 Eq(RegionEqPredicate<I>),
57}
58
59impl<I: Interner> From<OutlivesPredicate<I, I::GenericArg>> for RegionConstraint<I> {
60 fn from(value: OutlivesPredicate<I, I::GenericArg>) -> Self {
61 RegionConstraint::Outlives(value)
62 }
63}
64
65impl<I: Interner> From<RegionEqPredicate<I>> for RegionConstraint<I> {
66 fn from(value: RegionEqPredicate<I>) -> Self {
67 RegionConstraint::Eq(value)
68 }
69}
70
71impl<I: Interner> RegionConstraint<I> {
72 pub fn is_trivial(self) -> bool {
74 match self {
75 RegionConstraint::Outlives(outlives) => {
76 outlives.0.as_region().is_some_and(|re| re == outlives.1)
77 }
78 RegionConstraint::Eq(eq) => eq.0 == eq.1,
79 }
80 }
81
82 pub fn iter_outlives(self) -> impl Iterator<Item = OutlivesPredicate<I, I::GenericArg>> {
85 match self {
86 RegionConstraint::Outlives(outlives) => iter::once(outlives).chain(None),
87 RegionConstraint::Eq(eq) => {
88 let [outlives1, outlives2] = eq.into_bidirectional_outlives();
89 iter::once(outlives1).chain(Some(outlives2))
90 }
91 }
92 }
93}
94
95#[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)]
109#[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 J: Interner, I: ::rustc_type_ir::LiftInto<J> {
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)]
110#[cfg_attr(
111 feature = "nightly",
112 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_hash::StableHash for
TraitRef<I> where
I::TraitId: ::rustc_data_structures::stable_hash::StableHash,
I::GenericArgs: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
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)
113)]
114pub struct TraitRef<I: Interner> {
115 pub def_id: I::TraitId,
116 pub args: I::GenericArgs,
117 _use_trait_ref_new_instead: (),
120}
121
122impl<I: Interner> Eq for TraitRef<I> {}
123
124impl<I: Interner> TraitRef<I> {
125 pub fn new_from_args(interner: I, trait_def_id: I::TraitId, args: I::GenericArgs) -> Self {
126 interner.debug_assert_args_compatible(trait_def_id.into(), args);
127 Self { def_id: trait_def_id, args, _use_trait_ref_new_instead: () }
128 }
129
130 pub fn new(
131 interner: I,
132 trait_def_id: I::TraitId,
133 args: impl IntoIterator<Item: Into<I::GenericArg>>,
134 ) -> Self {
135 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
136 Self::new_from_args(interner, trait_def_id, args)
137 }
138
139 pub fn from_assoc(interner: I, trait_id: I::TraitId, args: I::GenericArgs) -> TraitRef<I> {
140 let generics = interner.generics_of(trait_id.into());
141 TraitRef::new(interner, trait_id, args.iter().take(generics.count()))
142 }
143
144 pub fn identity(interner: I, def_id: I::TraitId) -> TraitRef<I> {
147 TraitRef::new_from_args(
148 interner,
149 def_id,
150 I::GenericArgs::identity_for_item(interner, def_id.into()),
151 )
152 }
153
154 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
155 TraitRef::new(
156 interner,
157 self.def_id,
158 [self_ty.into()].into_iter().chain(self.args.iter().skip(1)),
159 )
160 }
161
162 #[inline]
163 pub fn self_ty(&self) -> I::Ty {
164 self.args.type_at(0)
165 }
166}
167
168impl<I: Interner> ty::Binder<I, TraitRef<I>> {
169 pub fn self_ty(&self) -> ty::Binder<I, I::Ty> {
170 self.map_bound_ref(|tr| tr.self_ty())
171 }
172
173 pub fn def_id(&self) -> I::TraitId {
174 self.skip_binder().def_id
175 }
176
177 pub fn to_host_effect_clause(self, cx: I, constness: BoundConstness) -> I::Clause {
178 self.map_bound(|trait_ref| {
179 ty::ClauseKind::HostEffect(HostEffectPredicate { trait_ref, constness })
180 })
181 .upcast(cx)
182 }
183}
184
185#[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)]
186#[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 J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
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_Generic)]
187#[cfg_attr(
188 feature = "nightly",
189 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_hash::StableHash for
TraitPredicate<I> where
TraitRef<I>: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TraitPredicate {
trait_ref: ref __binding_0, polarity: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
190)]
191pub struct TraitPredicate<I: Interner> {
192 pub trait_ref: TraitRef<I>,
193
194 #[lift(identity)]
200 pub polarity: PredicatePolarity,
201}
202
203impl<I: Interner> Eq for TraitPredicate<I> {}
204
205impl<I: Interner> TraitPredicate<I> {
206 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
207 Self {
208 trait_ref: self.trait_ref.with_replaced_self_ty(interner, self_ty),
209 polarity: self.polarity,
210 }
211 }
212
213 pub fn def_id(self) -> I::TraitId {
214 self.trait_ref.def_id
215 }
216
217 pub fn self_ty(self) -> I::Ty {
218 self.trait_ref.self_ty()
219 }
220}
221
222impl<I: Interner> ty::Binder<I, TraitPredicate<I>> {
223 pub fn def_id(self) -> I::TraitId {
224 self.skip_binder().def_id()
226 }
227
228 pub fn self_ty(self) -> ty::Binder<I, I::Ty> {
229 self.map_bound(|trait_ref| trait_ref.self_ty())
230 }
231
232 #[inline]
233 pub fn polarity(self) -> PredicatePolarity {
234 self.skip_binder().polarity
235 }
236}
237
238impl<I: Interner> UpcastFrom<I, TraitRef<I>> for TraitPredicate<I> {
239 fn upcast_from(from: TraitRef<I>, _tcx: I) -> Self {
240 TraitPredicate { trait_ref: from, polarity: PredicatePolarity::Positive }
241 }
242}
243
244impl<I: Interner> UpcastFrom<I, ty::Binder<I, TraitRef<I>>> for ty::Binder<I, TraitPredicate<I>> {
245 fn upcast_from(from: ty::Binder<I, TraitRef<I>>, _tcx: I) -> Self {
246 from.map_bound(|trait_ref| TraitPredicate {
247 trait_ref,
248 polarity: PredicatePolarity::Positive,
249 })
250 }
251}
252
253impl<I: Interner> fmt::Debug for TraitPredicate<I> {
254 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
255 f.write_fmt(format_args!("TraitPredicate({0:?}, polarity:{1:?})",
self.trait_ref, self.polarity))write!(f, "TraitPredicate({:?}, polarity:{:?})", self.trait_ref, self.polarity)
256 }
257}
258
259#[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> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}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)]
260#[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_hash::StableHash for ImplPolarity
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
ImplPolarity::Positive => {}
ImplPolarity::Negative => {}
ImplPolarity::Reservation => {}
}
}
}
};StableHash))]
261pub enum ImplPolarity {
262 Positive,
264 Negative,
266 Reservation,
271}
272
273impl fmt::Display for ImplPolarity {
274 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
275 match self {
276 Self::Positive => f.write_str("positive"),
277 Self::Negative => f.write_str("negative"),
278 Self::Reservation => f.write_str("reservation"),
279 }
280 }
281}
282
283impl ImplPolarity {
284 pub fn as_str(self) -> &'static str {
286 match self {
287 Self::Positive => "",
288 Self::Negative => "!",
289 Self::Reservation => "",
290 }
291 }
292}
293
294#[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> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}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)]
300#[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_hash::StableHash for
PredicatePolarity {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
PredicatePolarity::Positive => {}
PredicatePolarity::Negative => {}
}
}
}
};StableHash))]
301pub enum PredicatePolarity {
302 Positive,
304 Negative,
306}
307
308impl PredicatePolarity {
309 pub fn flip(&self) -> PredicatePolarity {
311 match self {
312 PredicatePolarity::Positive => PredicatePolarity::Negative,
313 PredicatePolarity::Negative => PredicatePolarity::Positive,
314 }
315 }
316}
317
318impl fmt::Display for PredicatePolarity {
319 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
320 match self {
321 Self::Positive => f.write_str("positive"),
322 Self::Negative => f.write_str("negative"),
323 }
324 }
325}
326
327#[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)]
328#[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 J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
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)]
329#[cfg_attr(
330 feature = "nightly",
331 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_hash::StableHash for
ExistentialPredicate<I> where
ExistentialTraitRef<I>: ::rustc_data_structures::stable_hash::StableHash,
ExistentialProjection<I>: ::rustc_data_structures::stable_hash::StableHash,
I::TraitId: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
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)
332)]
333pub enum ExistentialPredicate<I: Interner> {
334 Trait(ExistentialTraitRef<I>),
336 Projection(ExistentialProjection<I>),
338 AutoTrait(I::TraitId),
340}
341
342impl<I: Interner> Eq for ExistentialPredicate<I> {}
343
344impl<I: Interner> ty::Binder<I, ExistentialPredicate<I>> {
345 pub fn def_id(&self) -> I::DefId {
346 match self.skip_binder() {
347 ExistentialPredicate::Trait(tr) => tr.def_id.into(),
348 ExistentialPredicate::Projection(p) => p.def_id.into(),
349 ExistentialPredicate::AutoTrait(did) => did.into(),
350 }
351 }
352 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> I::Clause {
356 match self.skip_binder() {
357 ExistentialPredicate::Trait(tr) => self.rebind(tr).with_self_ty(cx, self_ty).upcast(cx),
358 ExistentialPredicate::Projection(p) => {
359 self.rebind(p.with_self_ty(cx, self_ty)).upcast(cx)
360 }
361 ExistentialPredicate::AutoTrait(did) => {
362 let generics = cx.generics_of(did.into());
363 let trait_ref = if generics.count() == 1 {
364 ty::TraitRef::new(cx, did, [self_ty])
365 } else {
366 let err_args =
369 GenericArgs::extend_with_error(cx, did.into(), &[self_ty.into()]);
370 ty::TraitRef::new_from_args(cx, did, err_args)
371 };
372 self.rebind(trait_ref).upcast(cx)
373 }
374 }
375 }
376}
377
378#[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)]
386#[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 J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
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)]
387#[cfg_attr(
388 feature = "nightly",
389 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_hash::StableHash for
ExistentialTraitRef<I> where
I::TraitId: ::rustc_data_structures::stable_hash::StableHash,
I::GenericArgs: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
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)
390)]
391pub struct ExistentialTraitRef<I: Interner> {
392 pub def_id: I::TraitId,
393 pub args: I::GenericArgs,
394 _use_existential_trait_ref_new_instead: (),
397}
398
399impl<I: Interner> Eq for ExistentialTraitRef<I> {}
400
401impl<I: Interner> ExistentialTraitRef<I> {
402 pub fn new_from_args(interner: I, trait_def_id: I::TraitId, args: I::GenericArgs) -> Self {
403 interner.debug_assert_existential_args_compatible(trait_def_id.into(), args);
404 Self { def_id: trait_def_id, args, _use_existential_trait_ref_new_instead: () }
405 }
406
407 pub fn new(
408 interner: I,
409 trait_def_id: I::TraitId,
410 args: impl IntoIterator<Item: Into<I::GenericArg>>,
411 ) -> Self {
412 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
413 Self::new_from_args(interner, trait_def_id, args)
414 }
415
416 pub fn erase_self_ty(interner: I, trait_ref: TraitRef<I>) -> ExistentialTraitRef<I> {
417 trait_ref.args.type_at(0);
419
420 ExistentialTraitRef {
421 def_id: trait_ref.def_id,
422 args: interner.mk_args(&trait_ref.args.as_slice()[1..]),
423 _use_existential_trait_ref_new_instead: (),
424 }
425 }
426
427 pub fn with_self_ty(self, interner: I, self_ty: I::Ty) -> TraitRef<I> {
433 TraitRef::new(interner, self.def_id, [self_ty.into()].into_iter().chain(self.args.iter()))
434 }
435}
436
437impl<I: Interner> ty::Binder<I, ExistentialTraitRef<I>> {
438 pub fn def_id(&self) -> I::TraitId {
439 self.skip_binder().def_id
440 }
441
442 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, TraitRef<I>> {
446 self.map_bound(|trait_ref| trait_ref.with_self_ty(cx, self_ty))
447 }
448}
449
450#[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)]
452#[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 J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
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)]
453#[cfg_attr(
454 feature = "nightly",
455 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_hash::StableHash for
ExistentialProjection<I> where
I::TraitAssocTermId: ::rustc_data_structures::stable_hash::StableHash,
I::GenericArgs: ::rustc_data_structures::stable_hash::StableHash,
I::Term: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
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)
456)]
457pub struct ExistentialProjection<I: Interner> {
458 pub def_id: I::TraitAssocTermId,
459 pub args: I::GenericArgs,
460 pub term: I::Term,
461
462 #[derive_where(skip(Debug))]
465 use_existential_projection_new_instead: (),
466}
467
468impl<I: Interner> Eq for ExistentialProjection<I> {}
469
470impl<I: Interner> ExistentialProjection<I> {
471 pub fn new_from_args(
472 interner: I,
473 def_id: I::TraitAssocTermId,
474 args: I::GenericArgs,
475 term: I::Term,
476 ) -> ExistentialProjection<I> {
477 interner.debug_assert_existential_args_compatible(def_id.into(), args);
478 Self { def_id, args, term, use_existential_projection_new_instead: () }
479 }
480
481 pub fn new(
482 interner: I,
483 def_id: I::TraitAssocTermId,
484 args: impl IntoIterator<Item: Into<I::GenericArg>>,
485 term: I::Term,
486 ) -> ExistentialProjection<I> {
487 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
488 Self::new_from_args(interner, def_id, args, term)
489 }
490
491 pub fn trait_ref(&self, interner: I) -> ExistentialTraitRef<I> {
497 let def_id = interner.projection_parent(self.def_id);
498 let args_count = interner.generics_of(def_id.into()).count() - 1;
499 let args = interner.mk_args(&self.args.as_slice()[..args_count]);
500 ExistentialTraitRef::new_from_args(interner, def_id, args)
501 }
502
503 pub fn with_self_ty(&self, interner: I, self_ty: I::Ty) -> ProjectionPredicate<I> {
504 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());
506
507 ProjectionPredicate {
508 projection_term: AliasTerm::new(
509 interner,
510 interner.alias_term_kind_from_def_id(self.def_id.into()),
511 [self_ty.into()].iter().chain(self.args.iter()),
512 ),
513 term: self.term,
514 }
515 }
516
517 pub fn erase_self_ty(interner: I, projection_predicate: ProjectionPredicate<I>) -> Self {
518 projection_predicate.projection_term.args.type_at(0);
520
521 Self {
522 def_id: projection_predicate.def_id(),
523 args: interner.mk_args(&projection_predicate.projection_term.args.as_slice()[1..]),
524 term: projection_predicate.term,
525 use_existential_projection_new_instead: (),
526 }
527 }
528}
529
530impl<I: Interner> ty::Binder<I, ExistentialProjection<I>> {
531 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, ProjectionPredicate<I>> {
532 self.map_bound(|p| p.with_self_ty(cx, self_ty))
533 }
534
535 pub fn item_def_id(&self) -> I::TraitAssocTermId {
536 self.skip_binder().def_id
537 }
538}
539
540#[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::AnonConst { def_id: ref __field_def_id } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "AnonConst");
::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)]
541#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
AliasTermKind<I> where I: Interner,
I::TraitAssocTyId: ::rustc_type_ir::TypeVisitable<I>,
I::InherentAssocTyId: ::rustc_type_ir::TypeVisitable<I>,
I::OpaqueTyId: ::rustc_type_ir::TypeVisitable<I>,
I::FreeTyAliasId: ::rustc_type_ir::TypeVisitable<I>,
I::UnevaluatedConstId: ::rustc_type_ir::TypeVisitable<I>,
I::TraitAssocConstId: ::rustc_type_ir::TypeVisitable<I>,
I::FreeConstAliasId: ::rustc_type_ir::TypeVisitable<I>,
I::InherentAssocConstId: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
AliasTermKind::ProjectionTy { def_id: ref __binding_0 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
AliasTermKind::InherentTy { def_id: ref __binding_0 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
AliasTermKind::OpaqueTy { def_id: ref __binding_0 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
AliasTermKind::FreeTy { def_id: ref __binding_0 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
AliasTermKind::AnonConst { def_id: ref __binding_0 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
AliasTermKind::ProjectionConst { def_id: ref __binding_0 }
=> {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
AliasTermKind::FreeConst { def_id: ref __binding_0 } => {
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
AliasTermKind::InherentConst { def_id: ref __binding_0 } =>
{
{
match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_type_ir::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_type_ir::VisitorResult>::output()
}
}
};TypeVisitable_Generic, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
AliasTermKind<I> where I: Interner,
I::TraitAssocTyId: ::rustc_type_ir::TypeFoldable<I>,
I::InherentAssocTyId: ::rustc_type_ir::TypeFoldable<I>,
I::OpaqueTyId: ::rustc_type_ir::TypeFoldable<I>,
I::FreeTyAliasId: ::rustc_type_ir::TypeFoldable<I>,
I::UnevaluatedConstId: ::rustc_type_ir::TypeFoldable<I>,
I::TraitAssocConstId: ::rustc_type_ir::TypeFoldable<I>,
I::FreeConstAliasId: ::rustc_type_ir::TypeFoldable<I>,
I::InherentAssocConstId: ::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 {
AliasTermKind::ProjectionTy { def_id: __binding_0 } => {
AliasTermKind::ProjectionTy {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
AliasTermKind::InherentTy { def_id: __binding_0 } => {
AliasTermKind::InherentTy {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
AliasTermKind::OpaqueTy { def_id: __binding_0 } => {
AliasTermKind::OpaqueTy {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
AliasTermKind::FreeTy { def_id: __binding_0 } => {
AliasTermKind::FreeTy {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
AliasTermKind::AnonConst { def_id: __binding_0 } => {
AliasTermKind::AnonConst {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
AliasTermKind::ProjectionConst { def_id: __binding_0 } => {
AliasTermKind::ProjectionConst {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
AliasTermKind::FreeConst { def_id: __binding_0 } => {
AliasTermKind::FreeConst {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
AliasTermKind::InherentConst { def_id: __binding_0 } => {
AliasTermKind::InherentConst {
def_id: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
__folder: &mut __F) -> Self {
match self {
AliasTermKind::ProjectionTy { def_id: __binding_0 } => {
AliasTermKind::ProjectionTy {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
AliasTermKind::InherentTy { def_id: __binding_0 } => {
AliasTermKind::InherentTy {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
AliasTermKind::OpaqueTy { def_id: __binding_0 } => {
AliasTermKind::OpaqueTy {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
AliasTermKind::FreeTy { def_id: __binding_0 } => {
AliasTermKind::FreeTy {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
AliasTermKind::AnonConst { def_id: __binding_0 } => {
AliasTermKind::AnonConst {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
AliasTermKind::ProjectionConst { def_id: __binding_0 } => {
AliasTermKind::ProjectionConst {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
AliasTermKind::FreeConst { def_id: __binding_0 } => {
AliasTermKind::FreeConst {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
AliasTermKind::InherentConst { def_id: __binding_0 } => {
AliasTermKind::InherentConst {
def_id: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
}
}
}
}
}
};TypeFoldable_Generic, const _: () =
{
impl<I: Interner, J> ::rustc_type_ir::lift::Lift<J> for
AliasTermKind<I> where J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
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::AnonConst { def_id: __binding_0 } => {
AliasTermKind::AnonConst {
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)]
542#[cfg_attr(
543 feature = "nightly",
544 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::AnonConst { 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::AnonConst { 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::AnonConst {
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_hash::StableHash for
AliasTermKind<I> where
I::TraitAssocTyId: ::rustc_data_structures::stable_hash::StableHash,
I::InherentAssocTyId: ::rustc_data_structures::stable_hash::StableHash,
I::OpaqueTyId: ::rustc_data_structures::stable_hash::StableHash,
I::FreeTyAliasId: ::rustc_data_structures::stable_hash::StableHash,
I::UnevaluatedConstId: ::rustc_data_structures::stable_hash::StableHash,
I::TraitAssocConstId: ::rustc_data_structures::stable_hash::StableHash,
I::FreeConstAliasId: ::rustc_data_structures::stable_hash::StableHash,
I::InherentAssocConstId: ::rustc_data_structures::stable_hash::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
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::AnonConst { 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)
545)]
546pub enum AliasTermKind<I: Interner> {
547 ProjectionTy { def_id: I::TraitAssocTyId },
557
558 InherentTy { def_id: I::InherentAssocTyId },
562
563 OpaqueTy { def_id: I::OpaqueTyId },
572
573 FreeTy { def_id: I::FreeTyAliasId },
578
579 AnonConst { def_id: I::UnevaluatedConstId },
581 ProjectionConst { def_id: I::TraitAssocConstId },
583 FreeConst { def_id: I::FreeConstAliasId },
585 InherentConst { def_id: I::InherentAssocConstId },
587}
588
589impl<I: Interner> AliasTermKind<I> {
590 pub fn descr(self) -> &'static str {
591 match self {
592 AliasTermKind::ProjectionTy { .. } => "associated type",
593 AliasTermKind::ProjectionConst { .. } => "associated const",
594 AliasTermKind::InherentTy { .. } => "inherent associated type",
595 AliasTermKind::InherentConst { .. } => "inherent associated const",
596 AliasTermKind::OpaqueTy { .. } => "opaque type",
597 AliasTermKind::FreeTy { .. } => "type alias",
598 AliasTermKind::FreeConst { .. } => "unevaluated constant",
599 AliasTermKind::AnonConst { .. } => "unevaluated constant",
600 }
601 }
602
603 pub fn is_type(self) -> bool {
604 match self {
605 AliasTermKind::ProjectionTy { .. }
606 | AliasTermKind::InherentTy { .. }
607 | AliasTermKind::OpaqueTy { .. }
608 | AliasTermKind::FreeTy { .. } => true,
609
610 AliasTermKind::AnonConst { .. }
611 | AliasTermKind::ProjectionConst { .. }
612 | AliasTermKind::InherentConst { .. }
613 | AliasTermKind::FreeConst { .. } => false,
614 }
615 }
616
617 pub fn is_trait_projection(self) -> bool {
618 match self {
619 AliasTermKind::ProjectionTy { .. } | AliasTermKind::ProjectionConst { .. } => true,
620 AliasTermKind::InherentTy { .. }
621 | AliasTermKind::OpaqueTy { .. }
622 | AliasTermKind::FreeTy { .. }
623 | AliasTermKind::AnonConst { .. }
624 | AliasTermKind::FreeConst { .. }
625 | AliasTermKind::InherentConst { .. } => false,
626 }
627 }
628}
629
630impl<I: Interner> From<ty::AliasTyKind<I>> for AliasTermKind<I> {
631 fn from(value: ty::AliasTyKind<I>) -> Self {
632 match value {
633 ty::Projection { def_id } => AliasTermKind::ProjectionTy { def_id },
634 ty::Opaque { def_id } => AliasTermKind::OpaqueTy { def_id },
635 ty::Free { def_id } => AliasTermKind::FreeTy { def_id },
636 ty::Inherent { def_id } => AliasTermKind::InherentTy { def_id },
637 }
638 }
639}
640
641impl<I: Interner> From<ty::UnevaluatedConstKind<I>> for AliasTermKind<I> {
642 fn from(value: ty::UnevaluatedConstKind<I>) -> Self {
643 match value {
644 ty::UnevaluatedConstKind::Projection { def_id } => {
645 AliasTermKind::ProjectionConst { def_id }
646 }
647 ty::UnevaluatedConstKind::Inherent { def_id } => {
648 AliasTermKind::InherentConst { def_id }
649 }
650 ty::UnevaluatedConstKind::Free { def_id } => AliasTermKind::FreeConst { def_id },
651 ty::UnevaluatedConstKind::Anon { def_id } => AliasTermKind::AnonConst { def_id },
652 }
653 }
654}
655
656impl<I: Interner> AliasTerm<I> {
657 pub fn new_from_args(
658 interner: I,
659 kind: AliasTermKind<I>,
660 args: I::GenericArgs,
661 ) -> AliasTerm<I> {
662 if truecfg!(debug_assertions) {
663 let def_id = match kind {
664 AliasTermKind::ProjectionTy { def_id } => def_id.into(),
665 AliasTermKind::InherentTy { def_id } => def_id.into(),
666 AliasTermKind::OpaqueTy { def_id } => def_id.into(),
667 AliasTermKind::FreeTy { def_id } => def_id.into(),
668 AliasTermKind::AnonConst { def_id } => def_id.into(),
669 AliasTermKind::ProjectionConst { def_id } => def_id.into(),
670 AliasTermKind::FreeConst { def_id } => def_id.into(),
671 AliasTermKind::InherentConst { def_id } => def_id.into(),
672 };
673 interner.debug_assert_args_compatible(def_id, args);
674 }
675 AliasTerm { kind, args, _use_alias_new_instead: () }
676 }
677
678 pub fn new(
679 interner: I,
680 kind: AliasTermKind<I>,
681 args: impl IntoIterator<Item: Into<I::GenericArg>>,
682 ) -> AliasTerm<I> {
683 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
684 Self::new_from_args(interner, kind, args)
685 }
686
687 pub fn new_from_def_id(interner: I, def_id: I::DefId, args: I::GenericArgs) -> AliasTerm<I> {
688 let kind = interner.alias_term_kind_from_def_id(def_id);
689 Self::new_from_args(interner, kind, args)
690 }
691
692 pub fn expect_ty(self) -> ty::AliasTy<I> {
693 let kind = match self.kind {
694 AliasTermKind::ProjectionTy { def_id } => AliasTyKind::Projection { def_id },
695 AliasTermKind::InherentTy { def_id } => AliasTyKind::Inherent { def_id },
696 AliasTermKind::OpaqueTy { def_id } => AliasTyKind::Opaque { def_id },
697 AliasTermKind::FreeTy { def_id } => AliasTyKind::Free { def_id },
698 kind @ (AliasTermKind::InherentConst { .. }
699 | AliasTermKind::FreeConst { .. }
700 | AliasTermKind::AnonConst { .. }
701 | AliasTermKind::ProjectionConst { .. }) => {
702 {
::core::panicking::panic_fmt(format_args!("Cannot turn `{0}` into `AliasTy`",
kind.descr()));
}panic!("Cannot turn `{}` into `AliasTy`", kind.descr())
703 }
704 };
705 ty::AliasTy { kind, args: self.args, _use_alias_new_instead: () }
706 }
707
708 pub fn expect_ct(self) -> ty::UnevaluatedConst<I> {
709 let kind = match self.kind {
710 AliasTermKind::InherentConst { def_id } => UnevaluatedConstKind::Inherent { def_id },
711 AliasTermKind::FreeConst { def_id } => UnevaluatedConstKind::Free { def_id },
712 AliasTermKind::AnonConst { def_id } => UnevaluatedConstKind::Anon { def_id },
713 AliasTermKind::ProjectionConst { def_id } => {
714 UnevaluatedConstKind::Projection { def_id }
715 }
716 kind @ (AliasTermKind::ProjectionTy { .. }
717 | AliasTermKind::InherentTy { .. }
718 | AliasTermKind::OpaqueTy { .. }
719 | AliasTermKind::FreeTy { .. }) => {
720 {
::core::panicking::panic_fmt(format_args!("Cannot turn `{0}` into `UnevaluatedConst`",
kind.descr()));
}panic!("Cannot turn `{}` into `UnevaluatedConst`", kind.descr())
721 }
722 };
723 ty::UnevaluatedConst { kind, args: self.args, _use_alias_new_instead: () }
724 }
725
726 pub fn to_term(self, interner: I) -> I::Term {
727 let alias_ty = |kind| {
728 Ty::new_alias(interner, ty::AliasTy::new_from_args(interner, kind, self.args)).into()
729 };
730 let unevaluated_const = |kind| {
731 I::Const::new_unevaluated(
732 interner,
733 ty::UnevaluatedConst::new(interner, kind, self.args),
734 )
735 .into()
736 };
737 match self.kind {
738 AliasTermKind::FreeConst { def_id } => {
739 unevaluated_const(UnevaluatedConstKind::Free { def_id })
740 }
741 AliasTermKind::InherentConst { def_id } => {
742 unevaluated_const(UnevaluatedConstKind::Inherent { def_id })
743 }
744 AliasTermKind::AnonConst { def_id } => {
745 unevaluated_const(UnevaluatedConstKind::Anon { def_id })
746 }
747 AliasTermKind::ProjectionConst { def_id } => {
748 unevaluated_const(UnevaluatedConstKind::Projection { def_id })
749 }
750 AliasTermKind::ProjectionTy { def_id } => alias_ty(ty::Projection { def_id }),
751 AliasTermKind::InherentTy { def_id } => alias_ty(ty::Inherent { def_id }),
752 AliasTermKind::OpaqueTy { def_id } => alias_ty(ty::Opaque { def_id }),
753 AliasTermKind::FreeTy { def_id } => alias_ty(ty::Free { def_id }),
754 }
755 }
756
757 pub fn with_args(self, interner: I, args: I::GenericArgs) -> Self {
758 Self::new_from_args(interner, self.kind, args)
759 }
760
761 pub fn expect_projection_ty_def_id(self) -> I::TraitAssocTyId {
762 match self.kind {
763 AliasTermKind::ProjectionTy { def_id } => def_id,
764 kind => {
::core::panicking::panic_fmt(format_args!("expected projection ty, found {0:?}",
kind));
}panic!("expected projection ty, found {kind:?}"),
765 }
766 }
767
768 pub fn expect_opaque_ty_def_id(self) -> I::OpaqueTyId {
769 match self.kind {
770 AliasTermKind::OpaqueTy { def_id } => def_id,
771 kind => {
::core::panicking::panic_fmt(format_args!("expected opaque ty, found {0:?}",
kind));
}panic!("expected opaque ty, found {kind:?}"),
772 }
773 }
774}
775
776impl<I: Interner> AliasTerm<I> {
779 pub fn self_ty(self) -> I::Ty {
780 self.args.type_at(0)
781 }
782
783 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
784 AliasTerm::new(
785 interner,
786 self.kind,
787 [self_ty.into()].into_iter().chain(self.args.iter().skip(1)),
788 )
789 }
790
791 pub fn expect_projection_def_id(self) -> I::TraitAssocTermId {
792 match self.kind {
793 AliasTermKind::ProjectionTy { def_id } => def_id.into(),
794 AliasTermKind::ProjectionConst { def_id } => def_id.into(),
795 kind => {
::core::panicking::panic_fmt(format_args!("expected projection alias, found {0:?}",
kind));
}panic!("expected projection alias, found {kind:?}"),
796 }
797 }
798
799 pub fn trait_def_id(self, interner: I) -> I::TraitId {
800 interner.projection_parent(self.expect_projection_def_id())
801 }
802
803 pub fn trait_ref_and_own_args(self, interner: I) -> (TraitRef<I>, I::GenericArgsSlice) {
808 interner.trait_ref_and_own_args_for_alias(self.expect_projection_def_id(), self.args)
809 }
810
811 pub fn trait_ref(self, interner: I) -> TraitRef<I> {
819 self.trait_ref_and_own_args(interner).0
820 }
821
822 pub fn own_args(self, interner: I) -> I::GenericArgsSlice {
826 self.trait_ref_and_own_args(interner).1
827 }
828}
829
830impl<I: Interner> AliasTerm<I> {
833 pub fn expect_inherent_def_id(self) -> I::InherentAssocTermId {
834 match self.kind {
835 AliasTermKind::InherentTy { def_id } => def_id.into(),
836 AliasTermKind::InherentConst { def_id } => def_id.into(),
837 kind => {
::core::panicking::panic_fmt(format_args!("expected inherent alias, found {0:?}",
kind));
}panic!("expected inherent alias, found {kind:?}"),
838 }
839 }
840
841 pub fn rebase_inherent_args_onto_impl(
852 self,
853 impl_args: I::GenericArgs,
854 interner: I,
855 ) -> I::GenericArgs {
856 if true {
if !#[allow(non_exhaustive_omitted_patterns)] match self.kind {
AliasTermKind::InherentTy { .. } |
AliasTermKind::InherentConst { .. } => true,
_ => false,
} {
::core::panicking::panic("assertion failed: matches!(self.kind, AliasTermKind::InherentTy { .. } |\n AliasTermKind::InherentConst { .. })")
};
};debug_assert!(matches!(
857 self.kind,
858 AliasTermKind::InherentTy { .. } | AliasTermKind::InherentConst { .. }
859 ));
860 interner.mk_args_from_iter(impl_args.iter().chain(self.args.iter().skip(1)))
861 }
862}
863
864impl<I: Interner> AliasTerm<I> {
867 pub fn expect_free_def_id(self) -> I::FreeTermAliasId {
868 match self.kind {
869 AliasTermKind::FreeTy { def_id } => def_id.into(),
870 AliasTermKind::FreeConst { def_id } => def_id.into(),
871 kind => {
::core::panicking::panic_fmt(format_args!("expected free alias, found {0:?}",
kind));
}panic!("expected free alias, found {kind:?}"),
872 }
873 }
874}
875
876impl<I: Interner> From<ty::AliasTy<I>> for AliasTerm<I> {
877 fn from(ty: ty::AliasTy<I>) -> Self {
878 AliasTerm { args: ty.args, kind: AliasTermKind::from(ty.kind), _use_alias_new_instead: () }
879 }
880}
881
882impl<I: Interner> From<ty::UnevaluatedConst<I>> for AliasTerm<I> {
883 fn from(ty: ty::UnevaluatedConst<I>) -> Self {
884 AliasTerm { args: ty.args, kind: AliasTermKind::from(ty.kind), _use_alias_new_instead: () }
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 J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
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_hash::StableHash for
ProjectionPredicate<I> where
AliasTerm<I>: ::rustc_data_structures::stable_hash::StableHash,
I::Term: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
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::TraitAssocTermId {
950 self.skip_binder().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, K> ::core::cmp::PartialEq for NormalizesTo<I, K> where
I: Interner, K: ::core::cmp::PartialEq {
#[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, Eq, PartialEq; I: Interner, K)]
964#[derive(const _: () =
{
impl<I: Interner, K> ::rustc_type_ir::TypeVisitable<I> for
NormalizesTo<I, K> where I: Interner,
Alias<I, K>: ::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, K> ::rustc_type_ir::TypeFoldable<I> for
NormalizesTo<I, K> where I: Interner,
K: ::rustc_type_ir::TypeFoldable<I>,
Alias<I, K>: ::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, K, J> ::rustc_type_ir::lift::Lift<J> for
NormalizesTo<I, K> where J: Interner,
I: ::rustc_type_ir::LiftInto<J>, K: ::rustc_type_ir::lift::Lift<J>
{
type Lifted =
NormalizesTo<J,
<K as ::rustc_type_ir::lift::Lift<J>>::Lifted>;
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, K, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for NormalizesTo<I, K> where
Alias<I, K>: ::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, K, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for NormalizesTo<I, K> where
Alias<I, K>: ::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, K> ::rustc_data_structures::stable_hash::StableHash
for NormalizesTo<I, K> where
Alias<I, K>: ::rustc_data_structures::stable_hash::StableHash,
I::Term: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
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, K = AliasTermKind<I>> {
970 pub alias: Alias<I, K>,
971 pub term: I::Term,
972}
973
974impl<I: Interner> NormalizesTo<I> {
975 pub fn self_ty(self) -> I::Ty {
976 self.alias.self_ty()
977 }
978
979 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> NormalizesTo<I> {
980 Self { alias: self.alias.with_replaced_self_ty(interner, self_ty), ..self }
981 }
982
983 pub fn trait_def_id(self, interner: I) -> I::TraitId {
984 self.alias.trait_def_id(interner)
985 }
986}
987
988impl<I: Interner, K> fmt::Debug for NormalizesTo<I, K>
989where
990 Alias<I, K>: fmt::Debug,
994{
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 J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
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_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_hash::StableHash for
HostEffectPredicate<I> where
ty::TraitRef<I>: ::rustc_data_structures::stable_hash::StableHash
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
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 #[lift(identity)]
1009 pub constness: BoundConstness,
1010}
1011
1012impl<I: Interner> Eq for HostEffectPredicate<I> {}
1013
1014impl<I: Interner> HostEffectPredicate<I> {
1015 pub fn self_ty(self) -> I::Ty {
1016 self.trait_ref.self_ty()
1017 }
1018
1019 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
1020 Self { trait_ref: self.trait_ref.with_replaced_self_ty(interner, self_ty), ..self }
1021 }
1022
1023 pub fn def_id(self) -> I::TraitId {
1024 self.trait_ref.def_id
1025 }
1026}
1027
1028impl<I: Interner> ty::Binder<I, HostEffectPredicate<I>> {
1029 pub fn def_id(self) -> I::TraitId {
1030 self.skip_binder().def_id()
1032 }
1033
1034 pub fn self_ty(self) -> ty::Binder<I, I::Ty> {
1035 self.map_bound(|trait_ref| trait_ref.self_ty())
1036 }
1037
1038 #[inline]
1039 pub fn constness(self) -> BoundConstness {
1040 self.skip_binder().constness
1041 }
1042}
1043
1044#[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)]
1048#[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 J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
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,
a: __binding_1.lift_to_interner(interner),
b: __binding_2.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
1049#[cfg_attr(
1050 feature = "nightly",
1051 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_hash::StableHash for
SubtypePredicate<I> where
I::Ty: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
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)
1052)]
1053pub struct SubtypePredicate<I: Interner> {
1054 #[lift(identity)]
1055 pub a_is_expected: bool,
1056 pub a: I::Ty,
1057 pub b: I::Ty,
1058}
1059
1060impl<I: Interner> Eq for SubtypePredicate<I> {}
1061
1062#[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)]
1064#[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 J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
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)]
1065#[cfg_attr(
1066 feature = "nightly",
1067 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_hash::StableHash for
CoercePredicate<I> where
I::Ty: ::rustc_data_structures::stable_hash::StableHash {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
CoercePredicate { a: ref __binding_0, b: ref __binding_1 }
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
1068)]
1069pub struct CoercePredicate<I: Interner> {
1070 pub a: I::Ty,
1071 pub b: I::Ty,
1072}
1073
1074impl<I: Interner> Eq for CoercePredicate<I> {}
1075
1076#[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)]
1077#[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_hash::StableHash for
BoundConstness {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
BoundConstness::Const => {}
BoundConstness::Maybe => {}
}
}
}
};StableHash))]
1078pub enum BoundConstness {
1079 Const,
1083 Maybe,
1087}
1088
1089impl BoundConstness {
1090 pub fn satisfies(self, goal: BoundConstness) -> bool {
1091 match (self, goal) {
1092 (BoundConstness::Const, BoundConstness::Const | BoundConstness::Maybe) => true,
1093 (BoundConstness::Maybe, BoundConstness::Maybe) => true,
1094 (BoundConstness::Maybe, BoundConstness::Const) => false,
1095 }
1096 }
1097
1098 pub fn as_str(self) -> &'static str {
1099 match self {
1100 Self::Const => "const",
1101 Self::Maybe => "[const]",
1102 }
1103 }
1104}
1105
1106impl fmt::Display for BoundConstness {
1107 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1108 match self {
1109 Self::Const => f.write_str("const"),
1110 Self::Maybe => f.write_str("[const]"),
1111 }
1112 }
1113}