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::upcast::{Upcast, UpcastFrom};
13use crate::visit::TypeVisitableExt as _;
14use crate::{self as ty, Alias, Interner, Region};
15
16#[automatically_derived]
impl<I: Interner, A> ::core::clone::Clone for OutlivesClause<I, A> where
I: Interner, A: ::core::clone::Clone {
#[inline]
fn clone(&self) -> Self {
match self {
OutlivesClause(ref __field_0, ref __field_1) =>
OutlivesClause {
0: ::core::clone::Clone::clone(__field_0),
1: ::core::clone::Clone::clone(__field_1),
},
}
}
}
#[automatically_derived]
impl<I: Interner, A> ::core::hash::Hash for OutlivesClause<I, A> where
I: Interner, A: ::core::hash::Hash {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
OutlivesClause(ref __field_0, ref __field_1) => {
::core::hash::Hash::hash(__field_0, __state);
::core::hash::Hash::hash(__field_1, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner, A> ::core::cmp::PartialEq for OutlivesClause<I, A> where
I: Interner, A: ::core::cmp::PartialEq {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(OutlivesClause(ref __field_0, ref __field_1),
OutlivesClause(ref __other_field_0, ref __other_field_1)) =>
true && ::core::cmp::PartialEq::eq(__field_0, __other_field_0)
&& ::core::cmp::PartialEq::eq(__field_1, __other_field_1),
}
}
}
#[automatically_derived]
impl<I: Interner, A> ::core::fmt::Debug for OutlivesClause<I, A> where
I: Interner, A: ::core::fmt::Debug {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
OutlivesClause(ref __field_0, ref __field_1) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "OutlivesClause");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::field(&mut __builder, __field_1);
::core::fmt::DebugTuple::finish(&mut __builder)
}
}
}
}
#[automatically_derived]
impl<I: Interner, A> ::core::marker::Copy for OutlivesClause<I, A> where
I: Interner, A: Copy {
}#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, A)]
18#[derive_where(Copy; I: Interner, A: Copy)]
19#[derive(const _: () =
{
impl<I: Interner, A> ::rustc_type_ir::TypeVisitable<I> for
OutlivesClause<I, A> where I: Interner,
A: ::rustc_type_ir::TypeVisitable<I>,
Region<I>: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
OutlivesClause(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, const _: () =
{
unsafe impl<I: Interner, A, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for
OutlivesClause<I, A> where
A: ::rustc_type_ir::GenericTypeVisitable<__V>,
Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
OutlivesClause(ref __binding_0, ref __binding_1) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner, A> ::rustc_type_ir::TypeFoldable<I> for
OutlivesClause<I, A> where I: Interner,
A: ::rustc_type_ir::TypeFoldable<I>,
A: ::rustc_type_ir::TypeFoldable<I>,
Region<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 {
OutlivesClause(__binding_0, __binding_1) => {
OutlivesClause(::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 {
OutlivesClause(__binding_0, __binding_1) => {
OutlivesClause(::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
OutlivesClause<I, A> where J: Interner,
I: ::rustc_type_ir::LiftInto<J>, A: ::rustc_type_ir::lift::Lift<J>
{
type Lifted =
OutlivesClause<J,
<A as ::rustc_type_ir::lift::Lift<J>>::Lifted>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
OutlivesClause(__binding_0, __binding_1) => {
OutlivesClause(__binding_0.lift_to_interner(interner),
__binding_1.lift_to_interner(interner))
}
}
}
}
};Lift_Generic)]
20#[cfg_attr(
21 feature = "nightly",
22 derive(const _: () =
{
impl<I: Interner, A, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for OutlivesClause<I, A> where
A: ::rustc_serialize::Decodable<__D>,
Region<I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
OutlivesClause(::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 OutlivesClause<I, A> where
A: ::rustc_serialize::Encodable<__E>,
Region<I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let OutlivesClause(ref __binding_0, ref __binding_1) = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, A> ::rustc_data_structures::stable_hash::StableHash
for OutlivesClause<I, A> where
A: ::rustc_data_structures::stable_hash::StableHash,
Region<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 {
OutlivesClause(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
23)]
24pub struct OutlivesClause<I: Interner, A>(pub A, pub Region<I>);
25
26impl<I: Interner, A: Eq> Eq for OutlivesClause<I, A> {}
27
28#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for RegionEqPredicate<I> where
I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for RegionEqPredicate<I> where
I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for RegionEqPredicate<I> where
I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
RegionEqPredicate(ref __field_0, ref __field_1) => {
::core::hash::Hash::hash(__field_0, __state);
::core::hash::Hash::hash(__field_1, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for RegionEqPredicate<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(RegionEqPredicate(ref __field_0, ref __field_1),
RegionEqPredicate(ref __other_field_0, ref __other_field_1))
=>
true && ::core::cmp::PartialEq::eq(__field_0, __other_field_0)
&& ::core::cmp::PartialEq::eq(__field_1, __other_field_1),
}
}
}
const _: () =
{
trait DeriveWhereAssertEq {
fn assert(&self);
}
impl<I: Interner> DeriveWhereAssertEq for RegionEqPredicate<I> where
I: Interner {
fn assert(&self) {
struct __AssertEq<__T: ::core::cmp::Eq +
?::core::marker::Sized>(::core::marker::PhantomData<__T>);
let _: __AssertEq<Region<I>>;
let _: __AssertEq<Region<I>>;
}
}
};
#[automatically_derived]
impl<I: Interner> ::core::cmp::Eq for RegionEqPredicate<I> where I: Interner {
}
#[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)]
33#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
RegionEqPredicate<I> where I: Interner,
Region<I>: ::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, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for
RegionEqPredicate<I> where
Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
RegionEqPredicate(ref __binding_0, ref __binding_1) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
RegionEqPredicate<I> where I: Interner,
Region<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 {
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)]
34#[cfg_attr(
35 feature = "nightly",
36 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for RegionEqPredicate<I> where
Region<I>: ::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
Region<I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let RegionEqPredicate(ref __binding_0, ref __binding_1) =
*self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
RegionEqPredicate<I> where
Region<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 {
RegionEqPredicate(ref __binding_0, ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
37)]
38pub struct RegionEqPredicate<I: Interner>(pub Region<I>, pub Region<I>);
39
40impl<I: Interner> RegionEqPredicate<I> {
41 pub fn into_bidirectional_outlives(self) -> [OutlivesClause<I, I::GenericArg>; 2] {
43 [OutlivesClause(self.0.into(), self.1), OutlivesClause(self.1.into(), self.0)]
44 }
45}
46
47#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for RegionConstraint<I> where
I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for RegionConstraint<I> where
I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for RegionConstraint<I> where I: Interner
{
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
RegionConstraint::Outlives(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
RegionConstraint::Eq(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for RegionConstraint<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
if ::core::mem::discriminant(self) ==
::core::mem::discriminant(__other) {
match (self, __other) {
(RegionConstraint::Outlives(ref __field_0),
RegionConstraint::Outlives(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(RegionConstraint::Eq(ref __field_0),
RegionConstraint::Eq(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
} else { false }
}
}
const _: () =
{
trait DeriveWhereAssertEq {
fn assert(&self);
}
impl<I: Interner> DeriveWhereAssertEq for RegionConstraint<I> where
I: Interner {
fn assert(&self) {
struct __AssertEq<__T: ::core::cmp::Eq +
?::core::marker::Sized>(::core::marker::PhantomData<__T>);
let _: __AssertEq<OutlivesClause<I, I::GenericArg>>;
let _: __AssertEq<RegionEqPredicate<I>>;
}
}
};
#[automatically_derived]
impl<I: Interner> ::core::cmp::Eq for RegionConstraint<I> where I: Interner {
}
#[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)]
48#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
RegionConstraint<I> where I: Interner,
OutlivesClause<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, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for RegionConstraint<I>
where
OutlivesClause<I,
I::GenericArg>: ::rustc_type_ir::GenericTypeVisitable<__V>,
RegionEqPredicate<I>: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
RegionConstraint::Outlives(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
RegionConstraint::Eq(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
RegionConstraint<I> where I: Interner,
OutlivesClause<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)]
49#[cfg_attr(
50 feature = "nightly",
51 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for RegionConstraint<I> where
OutlivesClause<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
OutlivesClause<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
OutlivesClause<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)
52)]
53pub enum RegionConstraint<I: Interner> {
54 Outlives(OutlivesClause<I, I::GenericArg>),
55 Eq(RegionEqPredicate<I>),
56}
57
58impl<I: Interner> From<OutlivesClause<I, I::GenericArg>> for RegionConstraint<I> {
59 fn from(value: OutlivesClause<I, I::GenericArg>) -> Self {
60 RegionConstraint::Outlives(value)
61 }
62}
63
64impl<I: Interner> From<RegionEqPredicate<I>> for RegionConstraint<I> {
65 fn from(value: RegionEqPredicate<I>) -> Self {
66 RegionConstraint::Eq(value)
67 }
68}
69
70impl<I: Interner> RegionConstraint<I> {
71 pub fn is_trivial(self) -> bool {
73 match self {
74 RegionConstraint::Outlives(outlives) => {
75 outlives.0.as_region().is_some_and(|re| re == outlives.1)
76 }
77 RegionConstraint::Eq(eq) => eq.0 == eq.1,
78 }
79 }
80
81 pub fn iter_outlives(self) -> impl Iterator<Item = OutlivesClause<I, I::GenericArg>> {
84 match self {
85 RegionConstraint::Outlives(outlives) => iter::once(outlives).chain(None),
86 RegionConstraint::Eq(eq) => {
87 let [outlives1, outlives2] = eq.into_bidirectional_outlives();
88 iter::once(outlives1).chain(Some(outlives2))
89 }
90 }
91 }
92}
93
94#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for TraitRef<I> where I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for TraitRef<I> where I: Interner { }
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for TraitRef<I> where I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
TraitRef {
def_id: ref __field_def_id,
args: ref __field_args,
_use_trait_ref_new_instead: ref __field__use_trait_ref_new_instead
} => {
::core::hash::Hash::hash(__field_def_id, __state);
::core::hash::Hash::hash(__field_args, __state);
::core::hash::Hash::hash(__field__use_trait_ref_new_instead,
__state);
}
}
}
}
#[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)]
108#[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, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for TraitRef<I> where
I::TraitId: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
(): ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
TraitRef {
def_id: ref __binding_0,
args: ref __binding_1,
_use_trait_ref_new_instead: ref __binding_2 } => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
__visitor);
}
}
}
}
}
};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)]
109#[cfg_attr(
110 feature = "nightly",
111 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) {
let TraitRef {
def_id: ref __binding_0,
args: ref __binding_1,
_use_trait_ref_new_instead: ref __binding_2 } = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner> ::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)
112)]
113pub struct TraitRef<I: Interner> {
114 pub def_id: I::TraitId,
115 pub args: I::GenericArgs,
116 _use_trait_ref_new_instead: (),
119}
120
121impl<I: Interner> Eq for TraitRef<I> {}
122
123impl<I: Interner> TraitRef<I> {
124 pub fn new_from_args(interner: I, trait_def_id: I::TraitId, args: I::GenericArgs) -> Self {
125 interner.debug_assert_args_compatible(trait_def_id.into(), args);
126 Self { def_id: trait_def_id, args, _use_trait_ref_new_instead: () }
127 }
128
129 pub fn new(
130 interner: I,
131 trait_def_id: I::TraitId,
132 args: impl IntoIterator<Item: Into<I::GenericArg>>,
133 ) -> Self {
134 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
135 Self::new_from_args(interner, trait_def_id, args)
136 }
137
138 pub fn from_assoc(interner: I, trait_id: I::TraitId, args: I::GenericArgs) -> TraitRef<I> {
139 let generics = interner.generics_of(trait_id.into());
140 if generics.count() == args.len() {
141 TraitRef::new_from_args(interner, trait_id, args)
143 } else {
144 TraitRef::new(interner, trait_id, args.iter().take(generics.count()))
146 }
147 }
148
149 pub fn identity(interner: I, def_id: I::TraitId) -> TraitRef<I> {
152 TraitRef::new_from_args(
153 interner,
154 def_id,
155 I::GenericArgs::identity_for_item(interner, def_id.into()),
156 )
157 }
158
159 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
160 TraitRef::new(
161 interner,
162 self.def_id,
163 [self_ty.into()].into_iter().chain(self.args.iter().skip(1)),
164 )
165 }
166
167 #[inline]
168 pub fn self_ty(&self) -> I::Ty {
169 self.args.type_at(0)
170 }
171}
172
173impl<I: Interner> ty::Binder<I, TraitRef<I>> {
174 pub fn self_ty(&self) -> ty::Binder<I, I::Ty> {
175 self.map_bound_ref(|tr| tr.self_ty())
176 }
177
178 pub fn def_id(&self) -> I::TraitId {
179 self.skip_binder().def_id
180 }
181
182 pub fn to_host_effect_clause(self, cx: I, constness: BoundConstness) -> I::Clause {
183 self.map_bound(|trait_ref| {
184 ty::ClauseKind::HostEffect(HostEffectClause { trait_ref, constness })
185 })
186 .upcast(cx)
187 }
188}
189
190#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for TraitClause<I> where I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for TraitClause<I> where I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for TraitClause<I> where I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
TraitClause {
trait_ref: ref __field_trait_ref,
polarity: ref __field_polarity } => {
::core::hash::Hash::hash(__field_trait_ref, __state);
::core::hash::Hash::hash(__field_polarity, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for TraitClause<I> where I: Interner
{
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(TraitClause {
trait_ref: ref __field_trait_ref,
polarity: ref __field_polarity }, TraitClause {
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)]
191#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for TraitClause<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 {
TraitClause {
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, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for TraitClause<I>
where TraitRef<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
ClausePolarity: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
TraitClause {
trait_ref: ref __binding_0, polarity: ref __binding_1 } => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for TraitClause<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 {
TraitClause { trait_ref: __binding_0, polarity: __binding_1
} => {
TraitClause {
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 {
TraitClause { trait_ref: __binding_0, polarity: __binding_1
} => {
TraitClause {
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 TraitClause<I>
where J: Interner, I: ::rustc_type_ir::LiftInto<J> {
type Lifted = TraitClause<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
TraitClause { trait_ref: __binding_0, polarity: __binding_1
} => {
TraitClause {
trait_ref: __binding_0.lift_to_interner(interner),
polarity: __binding_1,
}
}
}
}
}
};Lift_Generic)]
192#[cfg_attr(
193 feature = "nightly",
194 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for TraitClause<I> where
TraitRef<I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
TraitClause {
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 TraitClause<I> where
TraitRef<I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let TraitClause {
trait_ref: ref __binding_0, polarity: ref __binding_1 } =
*self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
TraitClause<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 {
TraitClause {
trait_ref: ref __binding_0, polarity: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
195)]
196pub struct TraitClause<I: Interner> {
197 pub trait_ref: TraitRef<I>,
198
199 #[lift(identity)]
205 pub polarity: ClausePolarity,
206}
207
208impl<I: Interner> Eq for TraitClause<I> {}
209
210impl<I: Interner> TraitClause<I> {
211 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
212 Self {
213 trait_ref: self.trait_ref.with_replaced_self_ty(interner, self_ty),
214 polarity: self.polarity,
215 }
216 }
217
218 pub fn def_id(self) -> I::TraitId {
219 self.trait_ref.def_id
220 }
221
222 pub fn self_ty(self) -> I::Ty {
223 self.trait_ref.self_ty()
224 }
225}
226
227impl<I: Interner> ty::Binder<I, TraitClause<I>> {
228 pub fn def_id(self) -> I::TraitId {
229 self.skip_binder().def_id()
231 }
232
233 pub fn self_ty(self) -> ty::Binder<I, I::Ty> {
234 self.map_bound(|trait_ref| trait_ref.self_ty())
235 }
236
237 #[inline]
238 pub fn polarity(self) -> ClausePolarity {
239 self.skip_binder().polarity
240 }
241}
242
243impl<I: Interner> UpcastFrom<I, TraitRef<I>> for TraitClause<I> {
244 fn upcast_from(from: TraitRef<I>, _tcx: I) -> Self {
245 TraitClause { trait_ref: from, polarity: ClausePolarity::Positive }
246 }
247}
248
249impl<I: Interner> UpcastFrom<I, ty::Binder<I, TraitRef<I>>> for ty::Binder<I, TraitClause<I>> {
250 fn upcast_from(from: ty::Binder<I, TraitRef<I>>, _tcx: I) -> Self {
251 from.map_bound(|trait_ref| TraitClause { trait_ref, polarity: ClausePolarity::Positive })
252 }
253}
254
255impl<I: Interner> fmt::Debug for TraitClause<I> {
256 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
257 f.write_fmt(format_args!("TraitClause({0:?}, polarity:{1:?})", self.trait_ref,
self.polarity))write!(f, "TraitClause({:?}, polarity:{:?})", self.trait_ref, self.polarity)
258 }
259}
260
261#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ImplPolarity { }
#[automatically_derived]
impl ::core::clone::Clone for ImplPolarity {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ImplPolarity { }Copy, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for ImplPolarity { }
#[automatically_derived]
impl ::core::cmp::PartialEq for ImplPolarity {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ImplPolarity { }Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for ImplPolarity {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::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: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for ImplPolarity {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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",
})
}
}Debug)]
262#[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 }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ImplPolarity`, expected 0..2, 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 }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
}
}
};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 => {}
}
}
}
};StableHash))]
263pub enum ImplPolarity {
264 Positive,
266 Negative,
268}
269
270impl fmt::Display for ImplPolarity {
271 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
272 match self {
273 Self::Positive => f.write_str("positive"),
274 Self::Negative => f.write_str("negative"),
275 }
276 }
277}
278
279impl ImplPolarity {
280 pub fn as_str(self) -> &'static str {
282 match self {
283 Self::Positive => "",
284 Self::Negative => "!",
285 }
286 }
287}
288
289#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ClausePolarity { }
#[automatically_derived]
impl ::core::clone::Clone for ClausePolarity {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ClausePolarity { }Copy, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for ClausePolarity { }
#[automatically_derived]
impl ::core::cmp::PartialEq for ClausePolarity {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ClausePolarity { }Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for ClausePolarity {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for ClausePolarity {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for ClausePolarity {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for ClausePolarity {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
ClausePolarity::Positive => "Positive",
ClausePolarity::Negative => "Negative",
})
}
}Debug)]
295#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for ClausePolarity {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { ClausePolarity::Positive }
1usize => { ClausePolarity::Negative }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ClausePolarity`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for ClausePolarity {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
ClausePolarity::Positive => { 0usize }
ClausePolarity::Negative => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
}
}
};Encodable_NoContext, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
ClausePolarity {
#[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 {
ClausePolarity::Positive => {}
ClausePolarity::Negative => {}
}
}
}
};StableHash))]
296pub enum ClausePolarity {
297 Positive,
299 Negative,
301}
302
303impl ClausePolarity {
304 pub fn flip(&self) -> ClausePolarity {
306 match self {
307 ClausePolarity::Positive => ClausePolarity::Negative,
308 ClausePolarity::Negative => ClausePolarity::Positive,
309 }
310 }
311}
312
313impl fmt::Display for ClausePolarity {
314 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
315 match self {
316 Self::Positive => f.write_str("positive"),
317 Self::Negative => f.write_str("negative"),
318 }
319 }
320}
321
322#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ExistentialPredicate<I> where
I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for ExistentialPredicate<I> where
I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ExistentialPredicate<I> where
I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
ExistentialPredicate::Trait(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
ExistentialPredicate::Projection(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
ExistentialPredicate::AutoTrait(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ExistentialPredicate<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
if ::core::mem::discriminant(self) ==
::core::mem::discriminant(__other) {
match (self, __other) {
(ExistentialPredicate::Trait(ref __field_0),
ExistentialPredicate::Trait(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(ExistentialPredicate::Projection(ref __field_0),
ExistentialPredicate::Projection(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(ExistentialPredicate::AutoTrait(ref __field_0),
ExistentialPredicate::AutoTrait(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
} else { false }
}
}
#[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)]
323#[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, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for
ExistentialPredicate<I> where
ExistentialTraitRef<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
ExistentialProjection<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::TraitId: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
ExistentialPredicate::Trait(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
ExistentialPredicate::Projection(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
ExistentialPredicate::AutoTrait(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
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)]
324#[cfg_attr(
325 feature = "nightly",
326 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)
327)]
328pub enum ExistentialPredicate<I: Interner> {
329 Trait(ExistentialTraitRef<I>),
331 Projection(ExistentialProjection<I>),
333 AutoTrait(I::TraitId),
335}
336
337impl<I: Interner> Eq for ExistentialPredicate<I> {}
338
339impl<I: Interner> ty::Binder<I, ExistentialPredicate<I>> {
340 pub fn def_id(&self) -> I::DefId {
341 match self.skip_binder() {
342 ExistentialPredicate::Trait(tr) => tr.def_id.into(),
343 ExistentialPredicate::Projection(p) => p.def_id.into(),
344 ExistentialPredicate::AutoTrait(did) => did.into(),
345 }
346 }
347 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> I::Clause {
351 match self.skip_binder() {
352 ExistentialPredicate::Trait(tr) => self.rebind(tr).with_self_ty(cx, self_ty).upcast(cx),
353 ExistentialPredicate::Projection(p) => {
354 self.rebind(p.with_self_ty(cx, self_ty)).upcast(cx)
355 }
356 ExistentialPredicate::AutoTrait(did) => {
357 let generics = cx.generics_of(did.into());
358 let trait_ref = if generics.count() == 1 {
359 ty::TraitRef::new(cx, did, [self_ty])
360 } else {
361 let err_args =
364 GenericArgs::extend_with_error(cx, did.into(), &[self_ty.into()]);
365 ty::TraitRef::new_from_args(cx, did, err_args)
366 };
367 self.rebind(trait_ref).upcast(cx)
368 }
369 }
370 }
371}
372
373#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ExistentialTraitRef<I> where
I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for ExistentialTraitRef<I> where
I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ExistentialTraitRef<I> where
I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
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
} => {
::core::hash::Hash::hash(__field_def_id, __state);
::core::hash::Hash::hash(__field_args, __state);
::core::hash::Hash::hash(__field__use_existential_trait_ref_new_instead,
__state);
}
}
}
}
#[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)]
381#[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, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for
ExistentialTraitRef<I> where
I::TraitId: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
(): ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
ExistentialTraitRef {
def_id: ref __binding_0,
args: ref __binding_1,
_use_existential_trait_ref_new_instead: ref __binding_2 } =>
{
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
__visitor);
}
}
}
}
}
};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)]
382#[cfg_attr(
383 feature = "nightly",
384 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) {
let ExistentialTraitRef {
def_id: ref __binding_0,
args: ref __binding_1,
_use_existential_trait_ref_new_instead: ref __binding_2 } =
*self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner> ::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)
385)]
386pub struct ExistentialTraitRef<I: Interner> {
387 pub def_id: I::TraitId,
388 pub args: I::GenericArgs,
389 _use_existential_trait_ref_new_instead: (),
392}
393
394impl<I: Interner> Eq for ExistentialTraitRef<I> {}
395
396impl<I: Interner> ExistentialTraitRef<I> {
397 pub fn new_from_args(interner: I, trait_def_id: I::TraitId, args: I::GenericArgs) -> Self {
398 interner.debug_assert_existential_args_compatible(trait_def_id.into(), args);
399 Self { def_id: trait_def_id, args, _use_existential_trait_ref_new_instead: () }
400 }
401
402 pub fn new(
403 interner: I,
404 trait_def_id: I::TraitId,
405 args: impl IntoIterator<Item: Into<I::GenericArg>>,
406 ) -> Self {
407 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
408 Self::new_from_args(interner, trait_def_id, args)
409 }
410
411 pub fn erase_self_ty(interner: I, trait_ref: TraitRef<I>) -> ExistentialTraitRef<I> {
412 trait_ref.args.type_at(0);
414
415 ExistentialTraitRef {
416 def_id: trait_ref.def_id,
417 args: interner.mk_args(&trait_ref.args.as_slice()[1..]),
418 _use_existential_trait_ref_new_instead: (),
419 }
420 }
421
422 pub fn with_self_ty(self, interner: I, self_ty: I::Ty) -> TraitRef<I> {
428 TraitRef::new(interner, self.def_id, [self_ty.into()].into_iter().chain(self.args.iter()))
429 }
430}
431
432impl<I: Interner> ty::Binder<I, ExistentialTraitRef<I>> {
433 pub fn def_id(&self) -> I::TraitId {
434 self.skip_binder().def_id
435 }
436
437 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, TraitRef<I>> {
441 self.map_bound(|trait_ref| trait_ref.with_self_ty(cx, self_ty))
442 }
443}
444
445#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ExistentialProjection<I> where
I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for ExistentialProjection<I> where
I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ExistentialProjection<I> where
I: Interner {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
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
} => {
::core::hash::Hash::hash(__field_def_id, __state);
::core::hash::Hash::hash(__field_args, __state);
::core::hash::Hash::hash(__field_term, __state);
::core::hash::Hash::hash(__field_use_existential_projection_new_instead,
__state);
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ExistentialProjection<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(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
}, ExistentialProjection {
def_id: ref __other_field_def_id,
args: ref __other_field_args,
term: ref __other_field_term,
use_existential_projection_new_instead: ref __other_field_use_existential_projection_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_term, __other_field_term)
&&
::core::cmp::PartialEq::eq(__field_use_existential_projection_new_instead,
__other_field_use_existential_projection_new_instead),
}
}
}
#[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)]
447#[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, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for
ExistentialProjection<I> where
I::TraitAssocTermId: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::GenericArgs: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Term: ::rustc_type_ir::GenericTypeVisitable<__V>,
(): ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
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_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_3,
__visitor);
}
}
}
}
}
};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)]
448#[cfg_attr(
449 feature = "nightly",
450 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) {
let ExistentialProjection {
def_id: ref __binding_0,
args: ref __binding_1,
term: ref __binding_2,
use_existential_projection_new_instead: ref __binding_3 } =
*self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::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)
451)]
452pub struct ExistentialProjection<I: Interner> {
453 pub def_id: I::TraitAssocTermId,
454 pub args: I::GenericArgs,
455 pub term: I::Term,
456
457 #[derive_where(skip(Debug))]
460 use_existential_projection_new_instead: (),
461}
462
463impl<I: Interner> Eq for ExistentialProjection<I> {}
464
465impl<I: Interner> ExistentialProjection<I> {
466 pub fn new_from_args(
467 interner: I,
468 def_id: I::TraitAssocTermId,
469 args: I::GenericArgs,
470 term: I::Term,
471 ) -> ExistentialProjection<I> {
472 interner.debug_assert_existential_args_compatible(def_id.into(), args);
473 Self { def_id, args, term, use_existential_projection_new_instead: () }
474 }
475
476 pub fn new(
477 interner: I,
478 def_id: I::TraitAssocTermId,
479 args: impl IntoIterator<Item: Into<I::GenericArg>>,
480 term: I::Term,
481 ) -> ExistentialProjection<I> {
482 let args = interner.mk_args_from_iter(args.into_iter().map(Into::into));
483 Self::new_from_args(interner, def_id, args, term)
484 }
485
486 pub fn trait_ref(&self, interner: I) -> ExistentialTraitRef<I> {
492 let def_id = interner.projection_parent(self.def_id);
493 let args_count = interner.generics_of(def_id.into()).count() - 1;
494 let args = interner.mk_args(&self.args.as_slice()[..args_count]);
495 ExistentialTraitRef::new_from_args(interner, def_id, args)
496 }
497
498 pub fn alias_kind(&self) -> ty::AliasTermKind<I> {
499 match self.term.kind() {
500 ty::TermKind::Ty(_) => {
501 ty::AliasTermKind::ProjectionTy { def_id: self.def_id.try_into().unwrap() }
502 }
503 ty::TermKind::Const(_) => {
504 ty::AliasTermKind::ProjectionConst { def_id: self.def_id.try_into().unwrap() }
505 }
506 }
507 }
508
509 pub fn with_self_ty(&self, interner: I, self_ty: I::Ty) -> ProjectionClause<I> {
510 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());
512
513 ProjectionClause {
514 projection_term: ty::AliasTerm::new(
515 interner,
516 self.alias_kind(),
517 [self_ty.into()].iter().chain(self.args.iter()),
518 ),
519 term: self.term,
520 }
521 }
522
523 pub fn erase_self_ty(interner: I, projection_predicate: ProjectionClause<I>) -> Self {
524 projection_predicate.projection_term.args.type_at(0);
526
527 Self {
528 def_id: projection_predicate.def_id(),
529 args: interner.mk_args(&projection_predicate.projection_term.args.as_slice()[1..]),
530 term: projection_predicate.term,
531 use_existential_projection_new_instead: (),
532 }
533 }
534}
535
536impl<I: Interner> ty::Binder<I, ExistentialProjection<I>> {
537 pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, ProjectionClause<I>> {
538 self.map_bound(|p| p.with_self_ty(cx, self_ty))
539 }
540
541 pub fn item_def_id(&self) -> I::TraitAssocTermId {
542 self.skip_binder().def_id
543 }
544}
545
546#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for ProjectionClause<I> where
I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for ProjectionClause<I> where
I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for ProjectionClause<I> where I: Interner
{
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
ProjectionClause {
projection_term: ref __field_projection_term,
term: ref __field_term } => {
::core::hash::Hash::hash(__field_projection_term, __state);
::core::hash::Hash::hash(__field_term, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for ProjectionClause<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(ProjectionClause {
projection_term: ref __field_projection_term,
term: ref __field_term }, ProjectionClause {
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)]
559#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
ProjectionClause<I> where I: Interner,
ty::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 {
ProjectionClause {
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, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for ProjectionClause<I>
where
ty::AliasTerm<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Term: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
ProjectionClause {
projection_term: ref __binding_0, term: ref __binding_1 } =>
{
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
ProjectionClause<I> where I: Interner,
ty::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 {
ProjectionClause {
projection_term: __binding_0, term: __binding_1 } => {
ProjectionClause {
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 {
ProjectionClause {
projection_term: __binding_0, term: __binding_1 } => {
ProjectionClause {
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
ProjectionClause<I> where J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
type Lifted = ProjectionClause<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
ProjectionClause {
projection_term: __binding_0, term: __binding_1 } => {
ProjectionClause {
projection_term: __binding_0.lift_to_interner(interner),
term: __binding_1.lift_to_interner(interner),
}
}
}
}
}
};Lift_Generic)]
560#[cfg_attr(
561 feature = "nightly",
562 derive(const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for ProjectionClause<I> where
ty::AliasTerm<I>: ::rustc_serialize::Decodable<__D>,
I::Term: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
ProjectionClause {
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 ProjectionClause<I> where
ty::AliasTerm<I>: ::rustc_serialize::Encodable<__E>,
I::Term: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let ProjectionClause {
projection_term: ref __binding_0, term: ref __binding_1 } =
*self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner> ::rustc_data_structures::stable_hash::StableHash for
ProjectionClause<I> where
ty::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 {
ProjectionClause {
projection_term: ref __binding_0, term: ref __binding_1 } =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
563)]
564pub struct ProjectionClause<I: Interner> {
565 pub projection_term: ty::AliasTerm<I>,
566 pub term: I::Term,
567}
568
569impl<I: Interner> Eq for ProjectionClause<I> {}
570
571impl<I: Interner> ProjectionClause<I> {
572 pub fn self_ty(self) -> I::Ty {
573 self.projection_term.self_ty()
574 }
575
576 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> ProjectionClause<I> {
577 Self {
578 projection_term: self.projection_term.with_replaced_self_ty(interner, self_ty),
579 ..self
580 }
581 }
582
583 pub fn trait_def_id(self, interner: I) -> I::TraitId {
584 self.projection_term.trait_def_id(interner)
585 }
586
587 pub fn def_id(self) -> I::TraitAssocTermId {
588 self.projection_term.expect_projection_def_id()
589 }
590}
591
592impl<I: Interner> ty::Binder<I, ProjectionClause<I>> {
593 #[inline]
595 pub fn trait_def_id(&self, cx: I) -> I::TraitId {
596 self.skip_binder().projection_term.trait_def_id(cx)
597 }
598
599 pub fn term(&self) -> ty::Binder<I, I::Term> {
600 self.map_bound(|predicate| predicate.term)
601 }
602
603 pub fn item_def_id(&self) -> I::TraitAssocTermId {
608 self.skip_binder().def_id()
610 }
611}
612
613impl<I: Interner> fmt::Debug for ProjectionClause<I> {
614 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
615 f.write_fmt(format_args!("ProjectionClause({0:?}, {1:?})",
self.projection_term, self.term))write!(f, "ProjectionClause({:?}, {:?})", self.projection_term, self.term)
616 }
617}
618
619#[automatically_derived]
impl<I: Interner, K> ::core::clone::Clone for NormalizesTo<I, K> where
I: Interner, K: ::core::clone::Clone {
#[inline]
fn clone(&self) -> Self {
match self {
NormalizesTo { alias: ref __field_alias, term: ref __field_term }
=>
NormalizesTo {
alias: ::core::clone::Clone::clone(__field_alias),
term: ::core::clone::Clone::clone(__field_term),
},
}
}
}
#[automatically_derived]
impl<I: Interner, K> ::core::marker::Copy for NormalizesTo<I, K> where
I: Interner, K: ::core::marker::Copy {
}
#[automatically_derived]
impl<I: Interner, K> ::core::hash::Hash for NormalizesTo<I, K> where
I: Interner, K: ::core::hash::Hash {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
NormalizesTo { alias: ref __field_alias, term: ref __field_term }
=> {
::core::hash::Hash::hash(__field_alias, __state);
::core::hash::Hash::hash(__field_term, __state);
}
}
}
}
const _: () =
{
trait DeriveWhereAssertEq {
fn assert(&self);
}
impl<I: Interner, K> DeriveWhereAssertEq for NormalizesTo<I, K> where
I: Interner, K: ::core::cmp::Eq {
fn assert(&self) {
struct __AssertEq<__T: ::core::cmp::Eq +
?::core::marker::Sized>(::core::marker::PhantomData<__T>);
let _: __AssertEq<Alias<I, K>>;
let _: __AssertEq<I::Term>;
}
}
};
#[automatically_derived]
impl<I: Interner, K> ::core::cmp::Eq for NormalizesTo<I, K> where I: Interner,
K: ::core::cmp::Eq {
}
#[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)]
622#[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, const _: () =
{
unsafe impl<I: Interner, K, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for NormalizesTo<I, K>
where Alias<I, K>: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Term: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
NormalizesTo { alias: ref __binding_0, term: ref __binding_1
} => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner, 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)]
623#[cfg_attr(
624 feature = "nightly",
625 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) {
let NormalizesTo {
alias: ref __binding_0, term: ref __binding_1 } = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, 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)
626)]
627pub struct NormalizesTo<I: Interner, K = ty::AliasTermKind<I>> {
628 pub alias: Alias<I, K>,
629 pub term: I::Term,
630}
631
632impl<I: Interner> NormalizesTo<I> {
633 pub fn self_ty(self) -> I::Ty {
634 self.alias.self_ty()
635 }
636
637 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> NormalizesTo<I> {
638 Self { alias: self.alias.with_replaced_self_ty(interner, self_ty), ..self }
639 }
640
641 pub fn trait_def_id(self, interner: I) -> I::TraitId {
642 self.alias.trait_def_id(interner)
643 }
644}
645
646impl<I: Interner, K> fmt::Debug for NormalizesTo<I, K>
647where
648 Alias<I, K>: fmt::Debug,
652{
653 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
654 f.write_fmt(format_args!("NormalizesTo({0:?}, {1:?})", self.alias, self.term))write!(f, "NormalizesTo({:?}, {:?})", self.alias, self.term)
655 }
656}
657
658#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for HostEffectClause<I> where
I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for HostEffectClause<I> where
I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for HostEffectClause<I> where I: Interner
{
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
HostEffectClause {
trait_ref: ref __field_trait_ref,
constness: ref __field_constness } => {
::core::hash::Hash::hash(__field_trait_ref, __state);
::core::hash::Hash::hash(__field_constness, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for HostEffectClause<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(HostEffectClause {
trait_ref: ref __field_trait_ref,
constness: ref __field_constness }, HostEffectClause {
trait_ref: ref __other_field_trait_ref,
constness: ref __other_field_constness }) =>
true &&
::core::cmp::PartialEq::eq(__field_trait_ref,
__other_field_trait_ref) &&
::core::cmp::PartialEq::eq(__field_constness,
__other_field_constness),
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for HostEffectClause<I> where I: Interner
{
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
HostEffectClause {
trait_ref: ref __field_trait_ref,
constness: ref __field_constness } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f,
"HostEffectClause");
::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)]
659#[derive(const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeVisitable<I> for
HostEffectClause<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 {
HostEffectClause {
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, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for HostEffectClause<I>
where ty::TraitRef<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
BoundConstness: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
HostEffectClause {
trait_ref: ref __binding_0, constness: ref __binding_1 } =>
{
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
HostEffectClause<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 {
HostEffectClause {
trait_ref: __binding_0, constness: __binding_1 } => {
HostEffectClause {
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 {
HostEffectClause {
trait_ref: __binding_0, constness: __binding_1 } => {
HostEffectClause {
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
HostEffectClause<I> where J: Interner,
I: ::rustc_type_ir::LiftInto<J> {
type Lifted = HostEffectClause<J>;
fn lift_to_interner(self, interner: J) -> Self::Lifted {
match self {
HostEffectClause {
trait_ref: __binding_0, constness: __binding_1 } => {
HostEffectClause {
trait_ref: __binding_0.lift_to_interner(interner),
constness: __binding_1,
}
}
}
}
}
};Lift_Generic)]
660#[cfg_attr(
661 feature = "nightly",
662 derive(const _: () =
{
impl<I: Interner, __E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for HostEffectClause<I> where
ty::TraitRef<I>: ::rustc_serialize::Encodable<__E> {
fn encode(&self, __encoder: &mut __E) {
let HostEffectClause {
trait_ref: ref __binding_0, constness: ref __binding_1 } =
*self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner, __D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for HostEffectClause<I> where
ty::TraitRef<I>: ::rustc_serialize::Decodable<__D> {
fn decode(__decoder: &mut __D) -> Self {
HostEffectClause {
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
HostEffectClause<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 {
HostEffectClause {
trait_ref: ref __binding_0, constness: ref __binding_1 } =>
{
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext)
663)]
664pub struct HostEffectClause<I: Interner> {
665 pub trait_ref: ty::TraitRef<I>,
666 #[lift(identity)]
667 pub constness: BoundConstness,
668}
669
670impl<I: Interner> Eq for HostEffectClause<I> {}
671
672impl<I: Interner> HostEffectClause<I> {
673 pub fn self_ty(self) -> I::Ty {
674 self.trait_ref.self_ty()
675 }
676
677 pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
678 Self { trait_ref: self.trait_ref.with_replaced_self_ty(interner, self_ty), ..self }
679 }
680
681 pub fn def_id(self) -> I::TraitId {
682 self.trait_ref.def_id
683 }
684}
685
686impl<I: Interner> ty::Binder<I, HostEffectClause<I>> {
687 pub fn def_id(self) -> I::TraitId {
688 self.skip_binder().def_id()
690 }
691
692 pub fn self_ty(self) -> ty::Binder<I, I::Ty> {
693 self.map_bound(|trait_ref| trait_ref.self_ty())
694 }
695
696 #[inline]
697 pub fn constness(self) -> BoundConstness {
698 self.skip_binder().constness
699 }
700}
701
702#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for SubtypePredicate<I> where
I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for SubtypePredicate<I> where
I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for SubtypePredicate<I> where I: Interner
{
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
SubtypePredicate {
a_is_expected: ref __field_a_is_expected,
a: ref __field_a,
b: ref __field_b } => {
::core::hash::Hash::hash(__field_a_is_expected, __state);
::core::hash::Hash::hash(__field_a, __state);
::core::hash::Hash::hash(__field_b, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for SubtypePredicate<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(SubtypePredicate {
a_is_expected: ref __field_a_is_expected,
a: ref __field_a,
b: ref __field_b }, SubtypePredicate {
a_is_expected: ref __other_field_a_is_expected,
a: ref __other_field_a,
b: ref __other_field_b }) =>
true &&
::core::cmp::PartialEq::eq(__field_a_is_expected,
__other_field_a_is_expected) &&
::core::cmp::PartialEq::eq(__field_a, __other_field_a) &&
::core::cmp::PartialEq::eq(__field_b, __other_field_b),
}
}
}
#[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)]
706#[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, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for SubtypePredicate<I>
where bool: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
SubtypePredicate {
a_is_expected: ref __binding_0,
a: ref __binding_1,
b: ref __binding_2 } => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
__visitor);
}
}
}
}
}
};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)]
707#[cfg_attr(
708 feature = "nightly",
709 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) {
let SubtypePredicate {
a_is_expected: ref __binding_0,
a: ref __binding_1,
b: ref __binding_2 } = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner> ::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)
710)]
711pub struct SubtypePredicate<I: Interner> {
712 #[lift(identity)]
713 pub a_is_expected: bool,
714 pub a: I::Ty,
715 pub b: I::Ty,
716}
717
718impl<I: Interner> Eq for SubtypePredicate<I> {}
719
720#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for CoercePredicate<I> where
I: Interner {
#[inline]
fn clone(&self) -> Self { *self }
}
#[automatically_derived]
impl<I: Interner> ::core::marker::Copy for CoercePredicate<I> where
I: Interner {
}
#[automatically_derived]
impl<I: Interner> ::core::hash::Hash for CoercePredicate<I> where I: Interner
{
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
CoercePredicate { a: ref __field_a, b: ref __field_b } => {
::core::hash::Hash::hash(__field_a, __state);
::core::hash::Hash::hash(__field_b, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::cmp::PartialEq for CoercePredicate<I> where
I: Interner {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(CoercePredicate { a: ref __field_a, b: ref __field_b },
CoercePredicate {
a: ref __other_field_a, b: ref __other_field_b }) =>
true && ::core::cmp::PartialEq::eq(__field_a, __other_field_a)
&& ::core::cmp::PartialEq::eq(__field_b, __other_field_b),
}
}
}
#[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)]
722#[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, const _: () =
{
unsafe impl<I: Interner, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for CoercePredicate<I>
where I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
CoercePredicate { a: ref __binding_0, b: ref __binding_1 }
=> {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
__visitor);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner> ::rustc_type_ir::TypeFoldable<I> for
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)]
723#[cfg_attr(
724 feature = "nightly",
725 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) {
let CoercePredicate { a: ref __binding_0, b: ref __binding_1
} = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};Encodable_NoContext, const _: () =
{
impl<I: Interner> ::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)
726)]
727pub struct CoercePredicate<I: Interner> {
728 pub a: I::Ty,
729 pub b: I::Ty,
730}
731
732impl<I: Interner> Eq for CoercePredicate<I> {}
733
734#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for BoundConstness { }
#[automatically_derived]
impl ::core::clone::Clone for BoundConstness {
#[inline]
fn clone(&self) -> Self { *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) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for BoundConstness { }
#[automatically_derived]
impl ::core::cmp::PartialEq for BoundConstness {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for BoundConstness { }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)]
735#[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);
}
}
};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))]
736pub enum BoundConstness {
737 Const,
741 Maybe,
745}
746
747impl BoundConstness {
748 pub fn satisfies(self, goal: BoundConstness) -> bool {
749 match (self, goal) {
750 (BoundConstness::Const, BoundConstness::Const | BoundConstness::Maybe) => true,
751 (BoundConstness::Maybe, BoundConstness::Maybe) => true,
752 (BoundConstness::Maybe, BoundConstness::Const) => false,
753 }
754 }
755
756 pub fn as_str(self) -> &'static str {
757 match self {
758 Self::Const => "const",
759 Self::Maybe => "[const]",
760 }
761 }
762}
763
764impl fmt::Display for BoundConstness {
765 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
766 match self {
767 Self::Const => f.write_str("const"),
768 Self::Maybe => f.write_str("[const]"),
769 }
770 }
771}