1use derive_where::derive_where;
4use indexmap::IndexSet;
5#[cfg(feature = "nightly")]
6use rustc_data_structures::transitive_relation::{TransitiveRelation, TransitiveRelationBuilder};
7#[cfg(feature = "nightly")]
8use rustc_macros::StableHash_NoContext;
9use rustc_type_ir_macros::{GenericTypeVisitable, TypeFoldable_Generic, TypeVisitable_Generic};
10use tracing::{debug, instrument};
11
12use crate::Const;
13
14#[cfg(not(feature = "nightly"))]
16#[derive(Default, Clone, Debug)]
17pub struct TransitiveRelation<T>(T);
18#[cfg(not(feature = "nightly"))]
19impl<T> TransitiveRelation<T> {
20 pub fn reachable_from(&self, _data: T) -> Vec<T> {
21 unreachable!("-Zassumptions-on-binders is not supported for r-a")
22 }
23
24 pub fn base_edges(&self) -> impl Iterator<Item = (T, T)> {
25 unreachable!("-Zassumptions-on-binders is not supported for r-a");
26
27 #[allow(unreachable_code)]
28 [].into_iter()
29 }
30}
31#[derive(Clone, Debug)]
32#[cfg(not(feature = "nightly"))]
33pub struct TransitiveRelationBuilder<T>(T);
34#[cfg(not(feature = "nightly"))]
35impl<T> TransitiveRelationBuilder<T> {
36 pub fn freeze(self) -> TransitiveRelation<T> {
37 unreachable!("-Zassumptions-on-binders is not supported for r-a")
38 }
39
40 pub fn add(&mut self, _: T, _: T) {
41 unreachable!("-Zassumptions-on-binders is not supported for r-a")
42 }
43}
44#[cfg(not(feature = "nightly"))]
45impl<T> Default for TransitiveRelationBuilder<T> {
46 fn default() -> Self {
47 unreachable!("-Zassumptions-on-binders is not supported for r-a")
48 }
49}
50
51use crate::data_structures::IndexMap;
52use crate::fold::TypeSuperFoldable;
53use crate::inherent::*;
54use crate::relate::{Relate, RelateResult, TypeRelation, VarianceDiagInfo};
55use crate::{
56 AliasTy, Binder, BoundRegion, BoundVar, BoundVariableKind, ClauseKind, DebruijnIndex,
57 InferCtxtLike, Interner, IsRigid, OutlivesClause, Region, RegionKind, TyKind, TypeFoldable,
58 TypeFolder, TypingMode, UniverseIndex, Variance, elaborate, max_universe,
59 set_aliases_to_non_rigid,
60};
61
62#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for Assumptions<I> where I: Interner {
#[inline]
fn clone(&self) -> Self {
match self {
Assumptions {
type_outlives: ref __field_type_outlives,
region_outlives: ref __field_region_outlives,
inverse_region_outlives: ref __field_inverse_region_outlives }
=>
Assumptions {
type_outlives: ::core::clone::Clone::clone(__field_type_outlives),
region_outlives: ::core::clone::Clone::clone(__field_region_outlives),
inverse_region_outlives: ::core::clone::Clone::clone(__field_inverse_region_outlives),
},
}
}
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for Assumptions<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
Assumptions {
type_outlives: ref __field_type_outlives,
region_outlives: ref __field_region_outlives,
inverse_region_outlives: ref __field_inverse_region_outlives }
=> {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "Assumptions");
::core::fmt::DebugStruct::field(&mut __builder,
"type_outlives", __field_type_outlives);
::core::fmt::DebugStruct::field(&mut __builder,
"region_outlives", __field_region_outlives);
::core::fmt::DebugStruct::field(&mut __builder,
"inverse_region_outlives", __field_inverse_region_outlives);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Debug; I: Interner)]
63pub struct Assumptions<I: Interner> {
64 pub type_outlives: Vec<Binder<I, OutlivesClause<I, I::Ty>>>,
65 pub region_outlives: TransitiveRelation<Region<I>>,
70 pub inverse_region_outlives: TransitiveRelation<Region<I>>,
71}
72
73impl<I: Interner> Assumptions<I> {
74 pub fn empty() -> Self {
75 Self {
76 type_outlives: Vec::new(),
77 region_outlives: TransitiveRelationBuilder::default().freeze(),
78 inverse_region_outlives: TransitiveRelationBuilder::default().freeze(),
79 }
80 }
81
82 pub fn new(
104 infcx: &impl InferCtxtLike<Interner = I>,
105 clauses: impl IntoIterator<Item = I::Clause>,
106 region_outlives: TransitiveRelation<Region<I>>,
107 universe: UniverseIndex,
108 ) -> Self {
109 let mut type_outlives = ::alloc::vec::Vec::new()vec![];
110 let mut region_outlives_builder = TransitiveRelationBuilder::default();
111 for (r1, r2) in region_outlives.base_edges() {
112 region_outlives_builder.add(r1, r2);
113 }
114
115 let clauses = elaborate::elaborate(infcx.cx(), clauses)
116 .filter(|clause| max_universe(infcx, *clause) == universe);
117 for clause in clauses {
118 match clause.kind().skip_binder() {
119 ClauseKind::TypeOutlives(_) => {
122 type_outlives.push(clause.as_type_outlives_clause().unwrap());
123 }
124 ClauseKind::RegionOutlives(OutlivesClause(r1, r2)) => {
125 if true {
if !(!r1.is_bound() && !r2.is_bound()) {
::core::panicking::panic("assertion failed: !r1.is_bound() && !r2.is_bound()")
};
};debug_assert!(!r1.is_bound() && !r2.is_bound());
129 region_outlives_builder.add(r1, r2);
130 }
131 _ => (),
133 }
134 }
135
136 Self::new_unelaborated(type_outlives, region_outlives_builder.freeze())
137 }
138
139 pub fn new_unelaborated(
142 type_outlives: Vec<Binder<I, OutlivesClause<I, I::Ty>>>,
143 region_outlives: TransitiveRelation<Region<I>>,
144 ) -> Self {
145 Self {
146 inverse_region_outlives: {
147 let mut builder = TransitiveRelationBuilder::default();
148 for (r1, r2) in region_outlives.base_edges() {
149 builder.add(r2, r1);
150 }
151 builder.freeze()
152 },
153 type_outlives,
154 region_outlives,
155 }
156 }
157}
158
159#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::clone::Clone for
LeafRegionConstraint<I, S> where I: Interner, S: ::core::clone::Clone {
#[inline]
fn clone(&self) -> Self {
match self {
LeafRegionConstraint::Ambiguity(ref __field_0) =>
LeafRegionConstraint::Ambiguity {
0: ::core::clone::Clone::clone(__field_0),
},
LeafRegionConstraint::RegionOutlives(ref __field_0, ref __field_1,
ref __field_2) =>
LeafRegionConstraint::RegionOutlives {
0: ::core::clone::Clone::clone(__field_0),
1: ::core::clone::Clone::clone(__field_1),
2: ::core::clone::Clone::clone(__field_2),
},
LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __field_0,
ref __field_1) =>
LeafRegionConstraint::AliasTyOutlivesViaEnv {
0: ::core::clone::Clone::clone(__field_0),
1: ::core::clone::Clone::clone(__field_1),
},
LeafRegionConstraint::PlaceholderTyOutlives(ref __field_0,
ref __field_1, ref __field_2) =>
LeafRegionConstraint::PlaceholderTyOutlives {
0: ::core::clone::Clone::clone(__field_0),
1: ::core::clone::Clone::clone(__field_1),
2: ::core::clone::Clone::clone(__field_2),
},
}
}
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::hash::Hash for
LeafRegionConstraint<I, S> where I: Interner, S: ::core::hash::Hash {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
LeafRegionConstraint::Ambiguity(ref __field_0) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
}
LeafRegionConstraint::RegionOutlives(ref __field_0, ref __field_1,
ref __field_2) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
::core::hash::Hash::hash(__field_1, __state);
::core::hash::Hash::hash(__field_2, __state);
}
LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __field_0,
ref __field_1) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
::core::hash::Hash::hash(__field_1, __state);
}
LeafRegionConstraint::PlaceholderTyOutlives(ref __field_0,
ref __field_1, ref __field_2) => {
::core::hash::Hash::hash(&::core::mem::discriminant(self),
__state);
::core::hash::Hash::hash(__field_0, __state);
::core::hash::Hash::hash(__field_1, __state);
::core::hash::Hash::hash(__field_2, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::PartialEq for
LeafRegionConstraint<I, S> where I: Interner, S: ::core::cmp::PartialEq {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
if ::core::mem::discriminant(self) ==
::core::mem::discriminant(__other) {
match (self, __other) {
(LeafRegionConstraint::Ambiguity(ref __field_0),
LeafRegionConstraint::Ambiguity(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
(LeafRegionConstraint::RegionOutlives(ref __field_0,
ref __field_1, ref __field_2),
LeafRegionConstraint::RegionOutlives(ref __other_field_0,
ref __other_field_1, ref __other_field_2)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1) &&
::core::cmp::PartialEq::eq(__field_2, __other_field_2),
(LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __field_0,
ref __field_1),
LeafRegionConstraint::AliasTyOutlivesViaEnv(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),
(LeafRegionConstraint::PlaceholderTyOutlives(ref __field_0,
ref __field_1, ref __field_2),
LeafRegionConstraint::PlaceholderTyOutlives(ref __other_field_0,
ref __other_field_1, ref __other_field_2)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
::core::cmp::PartialEq::eq(__field_1, __other_field_1) &&
::core::cmp::PartialEq::eq(__field_2, __other_field_2),
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
} else { false }
}
}
const _: () =
{
trait DeriveWhereAssertEq {
fn assert(&self);
}
impl<I: Interner, S: Clone + std::fmt::Debug> DeriveWhereAssertEq for
LeafRegionConstraint<I, S> where I: Interner, S: ::core::cmp::Eq {
fn assert(&self) {
struct __AssertEq<__T: ::core::cmp::Eq +
?::core::marker::Sized>(::core::marker::PhantomData<__T>);
let _: __AssertEq<S>;
let _: __AssertEq<Region<I>>;
let _: __AssertEq<Region<I>>;
let _: __AssertEq<S>;
let _: __AssertEq<Binder<I, (AliasTy<I>, Region<I>)>>;
let _: __AssertEq<S>;
let _: __AssertEq<I::Ty>;
let _: __AssertEq<Region<I>>;
let _: __AssertEq<S>;
}
}
};
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::Eq for
LeafRegionConstraint<I, S> where I: Interner, S: ::core::cmp::Eq {
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::fmt::Debug for
LeafRegionConstraint<I, S> where I: Interner, S: ::core::fmt::Debug {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
LeafRegionConstraint::Ambiguity(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "Ambiguity");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
LeafRegionConstraint::RegionOutlives(ref __field_0, ref __field_1,
ref __field_2) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "RegionOutlives");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::field(&mut __builder, __field_1);
::core::fmt::DebugTuple::field(&mut __builder, __field_2);
::core::fmt::DebugTuple::finish(&mut __builder)
}
LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __field_0,
ref __field_1) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f,
"AliasTyOutlivesViaEnv");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::field(&mut __builder, __field_1);
::core::fmt::DebugTuple::finish(&mut __builder)
}
LeafRegionConstraint::PlaceholderTyOutlives(ref __field_0,
ref __field_1, ref __field_2) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f,
"PlaceholderTyOutlives");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::field(&mut __builder, __field_1);
::core::fmt::DebugTuple::field(&mut __builder, __field_2);
::core::fmt::DebugTuple::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Hash, PartialEq, Eq, Debug; I: Interner, S)]
160#[derive(const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_type_ir::TypeVisitable<I> for LeafRegionConstraint<I, S>
where I: Interner, S: ::rustc_type_ir::TypeVisitable<I>,
Region<I>: ::rustc_type_ir::TypeVisitable<I>,
Binder<I,
(AliasTy<I>, Region<I>)>: ::rustc_type_ir::TypeVisitable<I>,
I::Ty: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
LeafRegionConstraint::Ambiguity(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);
}
}
}
}
LeafRegionConstraint::RegionOutlives(ref __binding_0,
ref __binding_1, 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);
}
}
}
}
LeafRegionConstraint::AliasTyOutlivesViaEnv(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);
}
}
}
}
LeafRegionConstraint::PlaceholderTyOutlives(ref __binding_0,
ref __binding_1, 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, S: Clone + std::fmt::Debug, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for
LeafRegionConstraint<I, S> where
S: ::rustc_type_ir::GenericTypeVisitable<__V>,
Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
S: ::rustc_type_ir::GenericTypeVisitable<__V>,
Binder<I,
(AliasTy<I>,
Region<I>)>: ::rustc_type_ir::GenericTypeVisitable<__V>,
S: ::rustc_type_ir::GenericTypeVisitable<__V>,
I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
S: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
LeafRegionConstraint::Ambiguity(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
LeafRegionConstraint::RegionOutlives(ref __binding_0,
ref __binding_1, 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);
}
}
LeafRegionConstraint::AliasTyOutlivesViaEnv(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);
}
}
LeafRegionConstraint::PlaceholderTyOutlives(ref __binding_0,
ref __binding_1, 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, S: Clone + std::fmt::Debug>
::rustc_type_ir::TypeFoldable<I> for LeafRegionConstraint<I, S>
where I: Interner, S: ::rustc_type_ir::TypeFoldable<I>,
S: ::rustc_type_ir::TypeFoldable<I>,
Region<I>: ::rustc_type_ir::TypeFoldable<I>,
Binder<I,
(AliasTy<I>, Region<I>)>: ::rustc_type_ir::TypeFoldable<I>,
I::Ty: ::rustc_type_ir::TypeFoldable<I> {
fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
LeafRegionConstraint::Ambiguity(__binding_0) => {
LeafRegionConstraint::Ambiguity(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?)
}
LeafRegionConstraint::RegionOutlives(__binding_0,
__binding_1, __binding_2) => {
LeafRegionConstraint::RegionOutlives(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
__folder)?)
}
LeafRegionConstraint::AliasTyOutlivesViaEnv(__binding_0,
__binding_1) => {
LeafRegionConstraint::AliasTyOutlivesViaEnv(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
__folder)?)
}
LeafRegionConstraint::PlaceholderTyOutlives(__binding_0,
__binding_1, __binding_2) => {
LeafRegionConstraint::PlaceholderTyOutlives(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
::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 {
LeafRegionConstraint::Ambiguity(__binding_0) => {
LeafRegionConstraint::Ambiguity(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder))
}
LeafRegionConstraint::RegionOutlives(__binding_0,
__binding_1, __binding_2) => {
LeafRegionConstraint::RegionOutlives(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
__folder))
}
LeafRegionConstraint::AliasTyOutlivesViaEnv(__binding_0,
__binding_1) => {
LeafRegionConstraint::AliasTyOutlivesViaEnv(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder))
}
LeafRegionConstraint::PlaceholderTyOutlives(__binding_0,
__binding_1, __binding_2) => {
LeafRegionConstraint::PlaceholderTyOutlives(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
__folder))
}
}
}
}
};TypeFoldable_Generic)]
161#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_data_structures::stable_hash::StableHash for
LeafRegionConstraint<I, S> where
S: ::rustc_data_structures::stable_hash::StableHash,
Region<I>: ::rustc_data_structures::stable_hash::StableHash,
Binder<I,
(AliasTy<I>,
Region<I>)>: ::rustc_data_structures::stable_hash::StableHash,
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) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
LeafRegionConstraint::Ambiguity(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
LeafRegionConstraint::RegionOutlives(ref __binding_0,
ref __binding_1, ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __binding_0,
ref __binding_1) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
LeafRegionConstraint::PlaceholderTyOutlives(ref __binding_0,
ref __binding_1, ref __binding_2) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext))]
162pub enum LeafRegionConstraint<I: Interner, S: Clone + std::fmt::Debug = ()> {
163 Ambiguity(S),
164 RegionOutlives(Region<I>, Region<I>, S),
165 AliasTyOutlivesViaEnv(Binder<I, (AliasTy<I>, Region<I>)>, S),
175 PlaceholderTyOutlives(I::Ty, Region<I>, S),
185}
186
187impl<I: Interner> LeafRegionConstraint<I> {
188 pub fn with_span<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
189 self,
190 span: S,
191 ) -> LeafRegionConstraint<I, S> {
192 use LeafRegionConstraint::*;
193
194 match self {
195 Ambiguity(()) => Ambiguity(span),
196 RegionOutlives(r1, r2, ()) => RegionOutlives(r1, r2, span),
197 AliasTyOutlivesViaEnv(bound_outlives, ()) => {
198 AliasTyOutlivesViaEnv(bound_outlives, span)
199 }
200 PlaceholderTyOutlives(ty, r, ()) => PlaceholderTyOutlives(ty, r, span),
201 }
202 }
203}
204
205impl<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash> LeafRegionConstraint<I, S> {
206 pub fn without_span(self) -> LeafRegionConstraint<I> {
207 use LeafRegionConstraint::*;
208
209 match self {
210 Ambiguity(_) => Ambiguity(()),
211 RegionOutlives(r1, r2, _) => RegionOutlives(r1, r2, ()),
212 AliasTyOutlivesViaEnv(bound_outlives, _) => AliasTyOutlivesViaEnv(bound_outlives, ()),
213 PlaceholderTyOutlives(ty, r, _) => PlaceholderTyOutlives(ty, r, ()),
214 }
215 }
216
217 pub fn span(&self) -> S {
218 use LeafRegionConstraint::*;
219
220 let (Ambiguity(s)
221 | RegionOutlives(_, _, s)
222 | AliasTyOutlivesViaEnv(_, s)
223 | PlaceholderTyOutlives(_, _, s)) = self;
224 s.clone()
225 }
226}
227
228#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::clone::Clone for
Or<I, S> where I: Interner, S: ::core::clone::Clone {
#[inline]
fn clone(&self) -> Self {
match self {
Or(ref __field_0) =>
Or { 0: ::core::clone::Clone::clone(__field_0) },
}
}
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::hash::Hash for Or<I, S>
where I: Interner, S: ::core::hash::Hash {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
Or(ref __field_0) => {
::core::hash::Hash::hash(__field_0, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::PartialEq for
Or<I, S> where I: Interner, S: ::core::cmp::PartialEq {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(Or(ref __field_0), Or(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
}
}
}
const _: () =
{
trait DeriveWhereAssertEq {
fn assert(&self);
}
impl<I: Interner, S: Clone + std::fmt::Debug> DeriveWhereAssertEq for
Or<I, S> where I: Interner, S: ::core::cmp::Eq {
fn assert(&self) {
struct __AssertEq<__T: ::core::cmp::Eq +
?::core::marker::Sized>(::core::marker::PhantomData<__T>);
let _: __AssertEq<Box<[And<I, S>]>>;
}
}
};
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::Eq for Or<I, S>
where I: Interner, S: ::core::cmp::Eq {
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::fmt::Debug for Or<I, S>
where I: Interner, S: ::core::fmt::Debug {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
Or(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "Or");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Hash, PartialEq, Eq, Debug; I: Interner, S)]
229#[derive(const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_type_ir::TypeVisitable<I> for Or<I, S> where I: Interner,
Box<[And<I, S>]>: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
Or(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, S: Clone + std::fmt::Debug, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for Or<I, S> where
Box<[And<I, S>]>: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
Or(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_type_ir::TypeFoldable<I> for Or<I, S> where I: Interner,
S: ::rustc_type_ir::TypeFoldable<I>,
Box<[And<I, S>]>: ::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 {
Or(__binding_0) => {
Or(::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 {
Or(__binding_0) => {
Or(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder))
}
}
}
}
};TypeFoldable_Generic)]
230#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_data_structures::stable_hash::StableHash for Or<I, S>
where
Box<[And<I, S>]>: ::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 {
Or(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext))]
231pub struct Or<I: Interner, S: Clone + std::fmt::Debug = ()>(pub Box<[And<I, S>]>);
242impl<I: Interner> Or<I> {
243 pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
244 self,
245 span: S,
246 ) -> Or<I, S> {
247 Or(self.0.into_iter().map(|and| and.with_spans(span.clone())).collect())
248 }
249}
250impl<I: Interner, S: Clone + std::hash::Hash + std::fmt::Debug + Eq> Or<I, S> {
251 pub fn new_true() -> Self {
252 Self(Box::new([And::new_true()]))
253 }
254
255 pub fn is_true(&self) -> bool {
256 if let [and] = &*self.0
258 && and.0.len() == 0
259 {
260 true
261 } else {
262 false
263 }
264 }
265
266 pub fn new_false() -> Self {
267 Self(Box::new([]))
268 }
269
270 pub fn is_false(&self) -> bool {
271 self.0.len() == 0
273 }
274
275 pub fn new(i: impl IntoIterator<Item = And<I, S>>) -> Self {
276 let ands = i.into_iter().collect::<Vec<_>>().into_boxed_slice();
277 let mut new_ands: Vec<And<I, S>> = Vec::new();
278
279 for and in ands {
280 if and.0.is_empty() {
284 return Self::new_true();
285 }
286
287 if new_ands.iter().all(|c| !c.is_and_equivalent_to(&and)) {
292 new_ands.push(and)
293 }
294 }
295
296 Self(new_ands.into_boxed_slice())
297 }
298
299 pub fn new_ambig(s: S) -> Self {
300 Or::new_leaf(LeafRegionConstraint::Ambiguity(s))
301 }
302
303 pub fn new_leaf(l: LeafRegionConstraint<I, S>) -> Self {
304 Or::new([And::new([l])])
305 }
306
307 pub fn build_and(a: Or<I, S>, b: Or<I, S>) -> Self {
308 let mut ands = Vec::new();
313 for b_and in b.0 {
314 for a_and in a.0.clone().into_iter() {
315 ands.push(And::new(a_and.0.into_iter().chain(b_and.0.clone())))
316 }
317 }
318
319 Or::new(ands)
320 }
321
322 pub fn build_or(a: Or<I, S>, b: Or<I, S>) -> Self {
323 Or::new(a.0.into_iter().chain(b.0))
324 }
325
326 pub fn without_spans(self) -> Or<I> {
327 Or(self.0.into_iter().map(|and| and.without_spans()).collect())
328 }
329}
330
331#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::clone::Clone for
And<I, S> where I: Interner, S: ::core::clone::Clone {
#[inline]
fn clone(&self) -> Self {
match self {
And(ref __field_0) =>
And { 0: ::core::clone::Clone::clone(__field_0) },
}
}
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::hash::Hash for And<I, S>
where I: Interner, S: ::core::hash::Hash {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
And(ref __field_0) => {
::core::hash::Hash::hash(__field_0, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::PartialEq for
And<I, S> where I: Interner, S: ::core::cmp::PartialEq {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(And(ref __field_0), And(ref __other_field_0)) =>
true &&
::core::cmp::PartialEq::eq(__field_0, __other_field_0),
}
}
}
const _: () =
{
trait DeriveWhereAssertEq {
fn assert(&self);
}
impl<I: Interner, S: Clone + std::fmt::Debug> DeriveWhereAssertEq for
And<I, S> where I: Interner, S: ::core::cmp::Eq {
fn assert(&self) {
struct __AssertEq<__T: ::core::cmp::Eq +
?::core::marker::Sized>(::core::marker::PhantomData<__T>);
let _: __AssertEq<Box<[LeafRegionConstraint<I, S>]>>;
}
}
};
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::Eq for And<I, S>
where I: Interner, S: ::core::cmp::Eq {
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::fmt::Debug for And<I, S>
where I: Interner, S: ::core::fmt::Debug {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
And(ref __field_0) => {
let mut __builder =
::core::fmt::Formatter::debug_tuple(__f, "And");
::core::fmt::DebugTuple::field(&mut __builder, __field_0);
::core::fmt::DebugTuple::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Hash, PartialEq, Eq, Debug; I: Interner, S)]
332#[derive(const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_type_ir::TypeVisitable<I> for And<I, S> where I: Interner,
Box<[LeafRegionConstraint<I,
S>]>: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
And(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, S: Clone + std::fmt::Debug, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for And<I, S> where
Box<[LeafRegionConstraint<I,
S>]>: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
And(ref __binding_0) => {
{
::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
__visitor);
}
}
}
}
}
};GenericTypeVisitable, const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_type_ir::TypeFoldable<I> for And<I, S> where I: Interner,
S: ::rustc_type_ir::TypeFoldable<I>,
Box<[LeafRegionConstraint<I,
S>]>: ::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 {
And(__binding_0) => {
And(::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 {
And(__binding_0) => {
And(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder))
}
}
}
}
};TypeFoldable_Generic)]
333#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_data_structures::stable_hash::StableHash for And<I, S>
where
Box<[LeafRegionConstraint<I,
S>]>: ::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 {
And(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext))]
334pub struct And<I: Interner, S: Clone + std::fmt::Debug = ()>(pub Box<[LeafRegionConstraint<I, S>]>);
338impl<I: Interner> And<I> {
339 pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
340 self,
341 span: S,
342 ) -> And<I, S> {
343 And(self.0.into_iter().map(|leaf| leaf.with_span(span.clone())).collect())
344 }
345}
346impl<I: Interner, S: Clone + std::hash::Hash + std::fmt::Debug + Eq> And<I, S> {
347 pub fn new_true() -> Self {
348 Self(Box::new([]))
349 }
350
351 pub fn new(i: impl IntoIterator<Item = LeafRegionConstraint<I, S>>) -> Self {
352 let mut seen = IndexSet::new();
353 And(i
354 .into_iter()
355 .filter(|leaf| {
356 if let LeafRegionConstraint::RegionOutlives(r1, r2, _) = leaf
360 && r1 == r2
361 {
362 return false;
363 }
364
365 if seen.contains(&leaf.clone().without_span()) {
366 false
367 } else {
368 seen.insert(leaf.clone().without_span());
369 true
370 }
371 })
372 .collect())
373 }
374
375 fn is_and_equivalent_to(&self, other: &And<I, S>) -> bool {
376 let this = self.clone().0;
377 let other = other.clone().0;
378
379 this.iter()
380 .all(|c1| other.iter().any(|c2| c1.clone().without_span() == c2.clone().without_span()))
381 && other.iter().all(|c2| {
382 this.iter().any(|c1| c1.clone().without_span() == c2.clone().without_span())
383 })
384 }
385
386 pub fn without_spans(self) -> And<I> {
387 And(self.0.into_iter().map(|leaf| leaf.without_span()).collect())
388 }
389}
390
391#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::clone::Clone for
RegionConstraint<I, S> where I: Interner, S: ::core::clone::Clone {
#[inline]
fn clone(&self) -> Self {
match self {
RegionConstraint {
and_constraint: ref __field_and_constraint,
or_constraint: ref __field_or_constraint } =>
RegionConstraint {
and_constraint: ::core::clone::Clone::clone(__field_and_constraint),
or_constraint: ::core::clone::Clone::clone(__field_or_constraint),
},
}
}
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::hash::Hash for
RegionConstraint<I, S> where I: Interner, S: ::core::hash::Hash {
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
match self {
RegionConstraint {
and_constraint: ref __field_and_constraint,
or_constraint: ref __field_or_constraint } => {
::core::hash::Hash::hash(__field_and_constraint, __state);
::core::hash::Hash::hash(__field_or_constraint, __state);
}
}
}
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::PartialEq for
RegionConstraint<I, S> where I: Interner, S: ::core::cmp::PartialEq {
#[inline]
fn eq(&self, __other: &Self) -> ::core::primitive::bool {
match (self, __other) {
(RegionConstraint {
and_constraint: ref __field_and_constraint,
or_constraint: ref __field_or_constraint }, RegionConstraint {
and_constraint: ref __other_field_and_constraint,
or_constraint: ref __other_field_or_constraint }) =>
true &&
::core::cmp::PartialEq::eq(__field_and_constraint,
__other_field_and_constraint) &&
::core::cmp::PartialEq::eq(__field_or_constraint,
__other_field_or_constraint),
}
}
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::fmt::Debug for
RegionConstraint<I, S> where I: Interner, S: ::core::fmt::Debug {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
RegionConstraint {
and_constraint: ref __field_and_constraint,
or_constraint: ref __field_or_constraint } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f,
"RegionConstraint");
::core::fmt::DebugStruct::field(&mut __builder,
"and_constraint", __field_and_constraint);
::core::fmt::DebugStruct::field(&mut __builder,
"or_constraint", __field_or_constraint);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, S)]
392#[derive(const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_type_ir::TypeVisitable<I> for RegionConstraint<I, S> where
I: Interner, And<I, S>: ::rustc_type_ir::TypeVisitable<I>,
Or<I, S>: ::rustc_type_ir::TypeVisitable<I> {
fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
RegionConstraint {
and_constraint: ref __binding_0,
or_constraint: 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, S: Clone + std::fmt::Debug, __V>
::rustc_type_ir::GenericTypeVisitable<__V> for
RegionConstraint<I, S> where
And<I, S>: ::rustc_type_ir::GenericTypeVisitable<__V>,
Or<I, S>: ::rustc_type_ir::GenericTypeVisitable<__V> {
fn generic_visit_with(&self, __visitor: &mut __V) {
match *self {
RegionConstraint {
and_constraint: ref __binding_0,
or_constraint: 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, S: Clone + std::fmt::Debug>
::rustc_type_ir::TypeFoldable<I> for RegionConstraint<I, S> where
I: Interner, S: ::rustc_type_ir::TypeFoldable<I>,
And<I, S>: ::rustc_type_ir::TypeFoldable<I>,
Or<I, S>: ::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 {
and_constraint: __binding_0, or_constraint: __binding_1 } =>
{
RegionConstraint {
and_constraint: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
or_constraint: ::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 {
RegionConstraint {
and_constraint: __binding_0, or_constraint: __binding_1 } =>
{
RegionConstraint {
and_constraint: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
__folder),
or_constraint: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable_Generic)]
393#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_data_structures::stable_hash::StableHash for
RegionConstraint<I, S> where
And<I, S>: ::rustc_data_structures::stable_hash::StableHash,
Or<I, S>: ::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 {
RegionConstraint {
and_constraint: ref __binding_0,
or_constraint: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash_NoContext))]
394pub struct RegionConstraint<I: Interner, S: Clone + std::fmt::Debug = ()> {
404 pub and_constraint: And<I, S>,
405 pub or_constraint: Or<I, S>,
406}
407
408impl<I: Interner> RegionConstraint<I> {
409 pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
410 self,
411 span: S,
412 ) -> RegionConstraint<I, S> {
413 RegionConstraint {
414 and_constraint: self.and_constraint.with_spans(span.clone()),
415 or_constraint: self.or_constraint.with_spans(span.clone()),
416 }
417 }
418}
419impl<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash> RegionConstraint<I, S> {
420 pub fn new_from_or(or: Or<I, S>) -> Self {
421 let Some(fst) = or.0.get(0).clone() else {
422 return RegionConstraint::new_false();
423 };
424 let mut and_constraint = fst.0.to_vec();
425
426 for and in or.0.split_first().unwrap().1 {
427 and_constraint.retain(|c| {
428 and.0.iter().any(|c2| c.clone().without_span() == c2.clone().without_span())
429 });
430 }
431 let and_constraint = And::new(and_constraint);
432
433 let or_constraint = Or::new(or.0.into_iter().map(|and| {
434 And::new(and.0.into_iter().filter(|c| {
435 and_constraint
436 .0
437 .iter()
438 .all(|s_c| c.clone().without_span() != s_c.clone().without_span())
439 }))
440 }));
441
442 Self {
443 and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
444 or_constraint,
445 }
446 }
447
448 pub fn splatted_and_constraints(&self) -> Or<I, S> {
449 Or::new(self.or_constraint.0.iter().map(|and| {
450 And::new(and.0.iter().cloned().chain(self.and_constraint.0.iter().cloned()))
451 }))
452 }
453
454 pub fn build_and(a: RegionConstraint<I, S>, b: RegionConstraint<I, S>) -> Self {
455 let and_constraint = And::new(a.and_constraint.0.into_iter().chain(b.and_constraint.0));
456 let or_constraint = Or::build_and(a.or_constraint, b.or_constraint);
457
458 Self {
459 and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
460 or_constraint,
461 }
462 }
463
464 pub fn build_or(a: RegionConstraint<I, S>, b: RegionConstraint<I, S>) -> Self {
465 Self::new_from_or(Or::build_or(a.splatted_and_constraints(), b.splatted_and_constraints()))
466 }
467
468 pub fn new_true() -> Self {
469 Self { and_constraint: And::new_true(), or_constraint: Or::new_true() }
470 }
471
472 pub fn is_true(&self) -> bool {
473 self.and_constraint.0.is_empty() && self.or_constraint.is_true()
474 }
475
476 pub fn new_false() -> Self {
477 Self { and_constraint: And::new_true(), or_constraint: Or::new_false() }
478 }
479
480 pub fn is_false(&self) -> bool {
481 self.or_constraint.is_false()
482 }
483
484 pub fn new_ambig(span: S) -> Self {
485 Self {
486 and_constraint: And::new([LeafRegionConstraint::Ambiguity(span)]),
487 or_constraint: Or::new_true(),
488 }
489 }
490
491 pub fn is_ambig(&self) -> bool {
492 if let [c] = &*self.and_constraint.0
493 && c.is_ambig()
494 && self.or_constraint.is_true()
495 {
496 true
497 } else {
498 false
499 }
500 }
501
502 pub fn without_spans(self) -> RegionConstraint<I> {
503 RegionConstraint {
504 and_constraint: self.and_constraint.without_spans(),
505 or_constraint: self.or_constraint.without_spans(),
506 }
507 }
508
509 pub fn new_leaf(l: LeafRegionConstraint<I, S>) -> Self {
510 RegionConstraint { and_constraint: And::new([l]), or_constraint: Or::new_true() }
511 }
512}
513
514impl<I: Interner, S: Clone + std::fmt::Debug> LeafRegionConstraint<I, S> {
515 pub fn is_ambig(&self) -> bool {
516 #[allow(non_exhaustive_omitted_patterns)] match self {
Self::Ambiguity(_) => true,
_ => false,
}matches!(self, Self::Ambiguity(_))
517 }
518}
519
520{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("eagerly_handle_placeholders_in_universe",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(533u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("constraint")
}> =
::tracing::__macro_support::FieldName::new("constraint");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("u")
}> =
::tracing::__macro_support::FieldName::new("u");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: RegionConstraint<I> =
loop {};
return __tracing_attr_fake_return;
}
{
let assumptions = infcx.get_placeholder_assumptions(u);
let constraint =
rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
constraint, u, &assumptions);
let constraint =
compute_new_region_constraints(infcx, constraint, u);
let constraint =
pull_region_outlives_constraints_out_of_universe(infcx,
constraint, u, &assumptions);
constraint
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:533",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(533u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
534pub fn eagerly_handle_placeholders_in_universe<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
535 infcx: &Infcx,
536 constraint: RegionConstraint<I>,
537 u: UniverseIndex,
538) -> RegionConstraint<I> {
539 let assumptions = infcx.get_placeholder_assumptions(u);
540
541 let constraint = rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling(
546 infcx,
547 constraint,
548 u,
549 &assumptions,
550 );
551
552 let constraint = compute_new_region_constraints(infcx, constraint, u);
556
557 let constraint =
559 pull_region_outlives_constraints_out_of_universe(infcx, constraint, u, &assumptions);
560
561 constraint
562}
563
564{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("compute_new_region_constraints",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(572u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("constraint")
}> =
::tracing::__macro_support::FieldName::new("constraint");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("u")
}> =
::tracing::__macro_support::FieldName::new("u");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: RegionConstraint<I> =
loop {};
return __tracing_attr_fake_return;
}
{
use LeafRegionConstraint::*;
let extend_from_and =
|builder: &mut TransitiveRelationBuilder<_>,
regions: &mut IndexSet<_>, constraints: &mut Vec<_>,
and: &And<I>|
{
for c in &and.0 {
match c {
Ambiguity(()) | PlaceholderTyOutlives(..) |
AliasTyOutlivesViaEnv(..) => {
constraints.push(c.clone())
}
RegionOutlives(r1, r2, ()) => {
regions.insert(*r1);
regions.insert(*r2);
builder.add(*r2, *r1);
}
}
}
};
let mut base_region_flows_builder =
TransitiveRelationBuilder::default();
let mut base_regions = IndexSet::new();
let mut base_constraints = Vec::new();
extend_from_and(&mut base_region_flows_builder,
&mut base_regions, &mut base_constraints,
&constraint.and_constraint);
let mut new_ands = Vec::new();
for and in &constraint.or_constraint.0 {
let mut region_flows_builder =
base_region_flows_builder.clone();
let mut regions = base_regions.clone();
let mut constraints = base_constraints.clone();
extend_from_and(&mut region_flows_builder, &mut regions,
&mut constraints, and);
let region_flow = region_flows_builder.freeze();
for r in regions.into_iter() {
for ub in region_flow.reachable_from(r) {
let is_placeholder_like =
|r: Region<I>|
match r.kind() {
RegionKind::ReLateParam(..) | RegionKind::ReEarlyParam(..) |
RegionKind::RePlaceholder(..) | RegionKind::ReStatic =>
true,
RegionKind::ReVar(..) => max_universe(infcx, r) < u,
RegionKind::ReError(..) => false,
RegionKind::ReErased | RegionKind::ReBound(..) =>
::core::panicking::panic("internal error: entered unreachable code"),
};
if is_placeholder_like(r) && is_placeholder_like(ub) {
constraints.push(RegionOutlives(ub, r, ()));
}
}
}
new_ands.push(Or::new([And::new(constraints)]))
}
RegionConstraint::new_from_or(new_ands.into_iter().fold(Or::new_false(),
|acc, c| Or::build_or(acc, c)))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:572",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(572u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
573fn compute_new_region_constraints<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
574 infcx: &Infcx,
575 constraint: RegionConstraint<I>,
576 u: UniverseIndex,
577) -> RegionConstraint<I> {
578 use LeafRegionConstraint::*;
579
580 let extend_from_and = |builder: &mut TransitiveRelationBuilder<_>,
581 regions: &mut IndexSet<_>,
582 constraints: &mut Vec<_>,
583 and: &And<I>| {
584 for c in &and.0 {
585 match c {
586 Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
587 constraints.push(c.clone())
588 }
589 RegionOutlives(r1, r2, ()) => {
590 regions.insert(*r1);
591 regions.insert(*r2);
592 builder.add(*r2, *r1);
593 }
594 }
595 }
596 };
597
598 let mut base_region_flows_builder = TransitiveRelationBuilder::default();
599 let mut base_regions = IndexSet::new();
600 let mut base_constraints = Vec::new();
601 extend_from_and(
602 &mut base_region_flows_builder,
603 &mut base_regions,
604 &mut base_constraints,
605 &constraint.and_constraint,
606 );
607
608 let mut new_ands = Vec::new();
609 for and in &constraint.or_constraint.0 {
610 let mut region_flows_builder = base_region_flows_builder.clone();
611 let mut regions = base_regions.clone();
612 let mut constraints = base_constraints.clone();
613 extend_from_and(&mut region_flows_builder, &mut regions, &mut constraints, and);
614
615 let region_flow = region_flows_builder.freeze();
616 for r in regions.into_iter() {
617 for ub in region_flow.reachable_from(r) {
618 let is_placeholder_like = |r: Region<I>| match r.kind() {
621 RegionKind::ReLateParam(..)
622 | RegionKind::ReEarlyParam(..)
623 | RegionKind::RePlaceholder(..)
624 | RegionKind::ReStatic => true,
625 RegionKind::ReVar(..) => max_universe(infcx, r) < u,
626 RegionKind::ReError(..) => false,
627 RegionKind::ReErased | RegionKind::ReBound(..) => unreachable!(),
628 };
629
630 if is_placeholder_like(r) && is_placeholder_like(ub) {
631 constraints.push(RegionOutlives(ub, r, ()));
632 }
633 }
634 }
635
636 new_ands.push(Or::new([And::new(constraints)]))
637 }
638
639 RegionConstraint::new_from_or(
641 new_ands.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c)),
642 )
643}
644
645{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("pull_region_outlives_constraints_out_of_universe",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(665u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("constraint")
}> =
::tracing::__macro_support::FieldName::new("constraint");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("u")
}> =
::tracing::__macro_support::FieldName::new("u");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("assumptions")
}> =
::tracing::__macro_support::FieldName::new("assumptions");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: RegionConstraint<I> =
loop {};
return __tracing_attr_fake_return;
}
{
if !(max_universe(infcx, constraint.clone()) <= u) {
::core::panicking::panic("assertion failed: max_universe(infcx, constraint.clone()) <= u")
};
use LeafRegionConstraint::*;
let pull_and =
|and: And<I>|
{
let mut pulled_constraints = Vec::new();
for c in and.0 {
match c {
Ambiguity(()) | PlaceholderTyOutlives(..) |
AliasTyOutlivesViaEnv(..) => {
if !(max_universe(infcx, c.clone()) < u) {
::core::panicking::panic("assertion failed: max_universe(infcx, c.clone()) < u")
};
pulled_constraints.push(Or::new_leaf(c.clone()));
}
RegionOutlives(region_1, region_2, ()) => {
let region_1_u = max_universe(infcx, region_1);
let region_2_u = max_universe(infcx, region_2);
if region_1_u != u && region_2_u != u {
pulled_constraints.push(Or::new_leaf(c));
continue;
}
if regions_outlived_by(region_1,
assumptions).any(|r| r == region_2) {
continue;
}
let mut candidates = ::alloc::vec::Vec::new();
for ub in
regions_outlived_by(region_1,
assumptions).filter(|r| max_universe(infcx, *r) < u) {
for lb in
regions_outliving(region_2, assumptions,
infcx.cx()).filter(|r| max_universe(infcx, *r) < u) {
candidates.push(RegionOutlives(ub, lb, ()));
}
}
pulled_constraints.push(Or::new(candidates.into_iter().map(|c|
And::new([c]))));
}
};
}
pulled_constraints.into_iter().fold(Or::new_true(),
|acc, c| Or::build_and(acc, c))
};
let and_constraint = pull_and(constraint.and_constraint);
let or_constraint =
constraint.or_constraint.0.into_iter().fold(Or::new_false(),
|acc, c| Or::build_or(acc, pull_and(c)));
RegionConstraint::new_from_or(Or::build_and(and_constraint,
or_constraint))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:665",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(665u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
666fn pull_region_outlives_constraints_out_of_universe<
667 Infcx: InferCtxtLike<Interner = I>,
668 I: Interner,
669>(
670 infcx: &Infcx,
671 constraint: RegionConstraint<I>,
672 u: UniverseIndex,
673 assumptions: &Assumptions<I>,
674) -> RegionConstraint<I> {
675 assert!(max_universe(infcx, constraint.clone()) <= u);
676
677 use LeafRegionConstraint::*;
685
686 let pull_and = |and: And<I>| {
687 let mut pulled_constraints = Vec::new();
688 for c in and.0 {
689 match c {
690 Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
691 assert!(max_universe(infcx, c.clone()) < u);
692 pulled_constraints.push(Or::new_leaf(c.clone()));
693 }
694 RegionOutlives(region_1, region_2, ()) => {
695 let region_1_u = max_universe(infcx, region_1);
696 let region_2_u = max_universe(infcx, region_2);
697
698 if region_1_u != u && region_2_u != u {
699 pulled_constraints.push(Or::new_leaf(c));
700 continue;
701 }
702
703 if regions_outlived_by(region_1, assumptions).any(|r| r == region_2) {
708 continue;
709 }
710
711 let mut candidates = vec![];
712
713 for ub in regions_outlived_by(region_1, assumptions)
714 .filter(|r| max_universe(infcx, *r) < u)
715 {
716 for lb in regions_outliving(region_2, assumptions, infcx.cx())
720 .filter(|r| max_universe(infcx, *r) < u)
721 {
722 candidates.push(RegionOutlives(ub, lb, ()));
726 }
727 }
728
729 pulled_constraints.push(Or::new(candidates.into_iter().map(|c| And::new([c]))));
730 }
731 };
732 }
733
734 pulled_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
735 };
736
737 let and_constraint = pull_and(constraint.and_constraint);
738 let or_constraint = constraint
739 .or_constraint
740 .0
741 .into_iter()
742 .fold(Or::new_false(), |acc, c| Or::build_or(acc, pull_and(c)));
743 RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
744}
745
746{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("destructure_type_outlives_constraints_in_root",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(750u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("constraint")
}> =
::tracing::__macro_support::FieldName::new("constraint");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("assumptions")
}> =
::tracing::__macro_support::FieldName::new("assumptions");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: RegionConstraint<I, S> =
loop {};
return __tracing_attr_fake_return;
}
{
use LeafRegionConstraint::*;
let destructure_and =
|and: &And<I, S>|
{
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:763",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(763u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("rewriting and: {0:?}",
and) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let mut destructured_constraints = Vec::new();
for c in &and.0 {
match c {
Ambiguity(_) | RegionOutlives(..) => {
destructured_constraints.push(Or::new_leaf(c.clone()))
}
PlaceholderTyOutlives(ty, r, span) =>
destructured_constraints.push(Or::new(regions_outlived_by_placeholder(*ty,
assumptions,
infcx.cx()).map(move |assumption_r|
{
And::new([RegionOutlives(assumption_r, *r, span.clone())])
}))),
AliasTyOutlivesViaEnv(bound_outlives, span) => {
destructured_constraints.push(alias_outlives_candidates_from_assumptions(infcx,
*bound_outlives, assumptions).with_spans(span.clone()));
}
}
}
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:789",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(789u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("destructured_constraints")
}> =
::tracing::__macro_support::FieldName::new("destructured_constraints");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&destructured_constraints)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let merged_constraints =
destructured_constraints.into_iter().fold(Or::new_true(),
|acc, c| Or::build_and(acc, c));
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:793",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(793u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("merged_constraints")
}> =
::tracing::__macro_support::FieldName::new("merged_constraints");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&merged_constraints)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
merged_constraints
};
let and_constraint =
destructure_and(&constraint.and_constraint);
let or_constraint =
constraint.or_constraint.0.into_iter().fold(Or::new_false(),
|acc, c| Or::build_or(acc, destructure_and(&c)));
RegionConstraint::new_from_or(Or::build_and(and_constraint,
or_constraint))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:750",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(750u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
751pub fn destructure_type_outlives_constraints_in_root<
752 Infcx: InferCtxtLike<Interner = I>,
753 I: Interner,
754 S: Clone + std::fmt::Debug + Eq + std::hash::Hash,
755>(
756 infcx: &Infcx,
757 constraint: RegionConstraint<I, S>,
758 assumptions: &Assumptions<I>,
759) -> RegionConstraint<I, S> {
760 use LeafRegionConstraint::*;
761
762 let destructure_and = |and: &And<I, S>| {
763 debug!("rewriting and: {:?}", and);
764 let mut destructured_constraints = Vec::new();
765 for c in &and.0 {
766 match c {
767 Ambiguity(_) | RegionOutlives(..) => {
768 destructured_constraints.push(Or::new_leaf(c.clone()))
769 }
770 PlaceholderTyOutlives(ty, r, span) => destructured_constraints.push(Or::new(
771 regions_outlived_by_placeholder(*ty, assumptions, infcx.cx()).map(
772 move |assumption_r| {
773 And::new([RegionOutlives(assumption_r, *r, span.clone())])
774 },
775 ),
776 )),
777 AliasTyOutlivesViaEnv(bound_outlives, span) => {
778 destructured_constraints.push(
779 alias_outlives_candidates_from_assumptions(
780 infcx,
781 *bound_outlives,
782 assumptions,
783 )
784 .with_spans(span.clone()),
785 );
786 }
787 }
788 }
789 debug!(?destructured_constraints);
790 let merged_constraints = destructured_constraints
791 .into_iter()
792 .fold(Or::new_true(), |acc, c| Or::build_and(acc, c));
793 debug!(?merged_constraints);
794 merged_constraints
795 };
796
797 let and_constraint = destructure_and(&constraint.and_constraint);
798 let or_constraint = constraint
799 .or_constraint
800 .0
801 .into_iter()
802 .fold(Or::new_false(), |acc, c| Or::build_or(acc, destructure_and(&c)));
803
804 RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
805}
806
807{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(817u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("constraint")
}> =
::tracing::__macro_support::FieldName::new("constraint");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("u")
}> =
::tracing::__macro_support::FieldName::new("u");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("assumptions")
}> =
::tracing::__macro_support::FieldName::new("assumptions");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: RegionConstraint<I> =
loop {};
return __tracing_attr_fake_return;
}
{
use LeafRegionConstraint::*;
if !(max_universe(infcx, constraint.clone()) <= u) {
{
::core::panicking::panic_fmt(format_args!("constraint {0:?} contains terms from a larger universe than {1:?}",
constraint.clone(), u));
}
};
let rewrite_and =
|and: And<I>|
{
let mut rewritten_constraints = Vec::new();
for c in and.0 {
match c {
Ambiguity(()) | RegionOutlives(..) =>
rewritten_constraints.push(Or::new_leaf(c)),
PlaceholderTyOutlives(ty, region, ()) => {
rewritten_constraints.push(rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
ty, region, u, assumptions));
}
AliasTyOutlivesViaEnv(bound_outlives, ()) => {
rewritten_constraints.push(rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
bound_outlives, u, assumptions));
}
}
}
rewritten_constraints.into_iter().fold(Or::new_true(),
|acc, c| Or::build_and(acc, c))
};
let and_constraint = rewrite_and(constraint.and_constraint);
let or_constraint =
constraint.or_constraint.0.into_iter().fold(Or::new_false(),
|acc, c| Or::build_or(acc, rewrite_and(c)));
RegionConstraint::new_from_or(Or::build_and(and_constraint,
or_constraint))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:817",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(817u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
818fn rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling<
819 Infcx: InferCtxtLike<Interner = I>,
820 I: Interner,
821>(
822 infcx: &Infcx,
823 constraint: RegionConstraint<I>,
824 u: UniverseIndex,
825 assumptions: &Assumptions<I>,
826) -> RegionConstraint<I> {
827 use LeafRegionConstraint::*;
828
829 assert!(
830 max_universe(infcx, constraint.clone()) <= u,
831 "constraint {:?} contains terms from a larger universe than {:?}",
832 constraint.clone(),
833 u
834 );
835
836 let rewrite_and = |and: And<I>| {
837 let mut rewritten_constraints = Vec::new();
838 for c in and.0 {
839 match c {
840 Ambiguity(()) | RegionOutlives(..) => rewritten_constraints.push(Or::new_leaf(c)),
841 PlaceholderTyOutlives(ty, region, ()) => {
842 rewritten_constraints.push(rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, ty, region, u, assumptions));
843 }
844 AliasTyOutlivesViaEnv(bound_outlives, ()) => {
845 rewritten_constraints.push(rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, bound_outlives, u, assumptions));
846 }
847 }
848 }
849 rewritten_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
850 };
851
852 let and_constraint = rewrite_and(constraint.and_constraint);
853 let or_constraint = constraint
854 .or_constraint
855 .0
856 .into_iter()
857 .fold(Or::new_false(), |acc, c| Or::build_or(acc, rewrite_and(c)));
858
859 RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
860}
861
862fn rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
863 Infcx: InferCtxtLike<Interner = I>,
864 I: Interner,
865>(
866 infcx: &Infcx,
867 ty: I::Ty,
868 region: Region<I>,
869 u: UniverseIndex,
870 assumptions: &Assumptions<I>,
871) -> Or<I> {
872 use LeafRegionConstraint::*;
873
874 let ty_u = max_universe(infcx, ty);
875 let region_u = max_universe(infcx, region);
876
877 if region_u != u && ty_u != u {
878 return Or::new_leaf(PlaceholderTyOutlives(ty, region, ()));
879 }
880
881 let mut candidates = ::alloc::vec::Vec::new()vec![];
882
883 candidates.extend(
886 regions_outlived_by_placeholder(ty, assumptions, infcx.cx())
887 .map(move |assumption_r| RegionOutlives(assumption_r, region, ())),
888 );
889
890 if region_u == u && ty_u < u {
894 candidates.extend(
895 regions_outliving::<I>(region, assumptions, infcx.cx())
896 .filter(|r| max_universe(infcx, *r) < u)
897 .map(|r| PlaceholderTyOutlives(ty, r, ())),
898 );
899 }
900
901 Or::new(candidates.into_iter().map(|c| And::new([c])))
902}
903
904fn rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
905 Infcx: InferCtxtLike<Interner = I>,
906 I: Interner,
907>(
908 infcx: &Infcx,
909 bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
910 u: UniverseIndex,
911 assumptions: &Assumptions<I>,
912) -> Or<I> {
913 use LeafRegionConstraint::*;
914
915 let mut candidates = Vec::new();
916
917 if max_universe(infcx, bound_outlives) == u {
933 let mut replacer = PlaceholderReplacer {
934 cx: infcx.cx(),
935 existing_var_count: bound_outlives.bound_vars().len(),
936 bound_vars: IndexMap::default(),
937 universe: u,
938 current_index: DebruijnIndex::ZERO,
939 };
940 let escaping_outlives = bound_outlives.skip_binder().fold_with(&mut replacer);
941 let bound_vars = bound_outlives.bound_vars().iter().chain(
942 core::mem::take(&mut replacer.bound_vars)
943 .into_iter()
944 .map(|(_, bound_region)| BoundVariableKind::Region(bound_region.kind)),
945 );
946 let bound_outlives = Binder::bind_with_vars(
947 escaping_outlives,
948 I::BoundVarKinds::from_vars(infcx.cx(), bound_vars),
949 );
950 let candidate = Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, ()));
951 if max_universe(infcx, candidate.clone()) < u {
952 candidates.push(candidate);
953 } else {
954 candidates.push(Or::new_ambig(()));
958 }
959 }
960
961 candidates.push(alias_outlives_candidates_from_assumptions(infcx, bound_outlives, assumptions));
964
965 let (escaping_alias, escaping_r) = bound_outlives.skip_binder();
970 if max_universe(infcx, escaping_r) == u {
971 let mut replacer = PlaceholderReplacer {
972 cx: infcx.cx(),
973 existing_var_count: bound_outlives.bound_vars().len(),
974 bound_vars: IndexMap::default(),
975 universe: u,
976 current_index: DebruijnIndex::ZERO,
977 };
978 let escaping_alias = escaping_alias.fold_with(&mut replacer);
979 let bound_vars = bound_outlives.bound_vars().iter().chain(
980 core::mem::take(&mut replacer.bound_vars)
981 .into_iter()
982 .map(|(_, bound_region)| BoundVariableKind::Region(bound_region.kind)),
983 );
984 let bound_alias = Binder::bind_with_vars(
985 escaping_alias,
986 I::BoundVarKinds::from_vars(infcx.cx(), bound_vars),
987 );
988
989 candidates.push(Or::new(
992 regions_outliving(escaping_r, assumptions, infcx.cx())
993 .filter(|r2| max_universe(infcx, *r2) < u)
994 .map(|r2| {
995 let candidate =
996 AliasTyOutlivesViaEnv(bound_alias.map_bound(|alias| (alias, r2)), ());
997 if max_universe(infcx, candidate.clone()) < u {
998 And::new([candidate])
999 } else {
1000 And::new([Ambiguity(())])
1001 }
1002 }),
1003 ));
1004 }
1005
1006 match infcx.typing_mode_raw() {
1010 TypingMode::Coherence => candidates.push(Or::new_ambig(())),
1011 TypingMode::Typeck { .. }
1012 | TypingMode::Reflection
1013 | TypingMode::ErasedNotCoherence { .. }
1014 | TypingMode::PostTypeckUntilBorrowck { .. }
1015 | TypingMode::PostBorrowck { .. }
1016 | TypingMode::PostAnalysis
1017 | TypingMode::Codegen => (),
1018 };
1019
1020 candidates.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c))
1021}
1022
1023pub fn regions_outlived_by<I: Interner>(
1026 r: Region<I>,
1027 assumptions: &Assumptions<I>,
1028) -> impl Iterator<Item = Region<I>> {
1029 assumptions.region_outlives.reachable_from(r).into_iter().chain([r])
1030}
1031
1032pub fn regions_outliving<I: Interner>(
1035 r: Region<I>,
1036 assumptions: &Assumptions<I>,
1037 cx: I,
1038) -> impl Iterator<Item = Region<I>> {
1039 assumptions
1040 .inverse_region_outlives
1041 .reachable_from(r)
1042 .into_iter()
1043 .chain([r, Region::new_static(cx)])
1046}
1047
1048pub fn regions_outlived_by_placeholder<I: Interner>(
1051 t: I::Ty,
1052 assumptions: &Assumptions<I>,
1053 cx: I,
1054) -> impl Iterator<Item = Region<I>> {
1055 match t.kind() {
1056 TyKind::Placeholder(..) | TyKind::Param(..) => (),
1057 _ => {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("non-placeholder in `regions_outlived_by_placeholder`: {0:?}",
t)));
}unreachable!("non-placeholder in `regions_outlived_by_placeholder`: {t:?}"),
1058 }
1059
1060 assumptions.type_outlives.iter().flat_map(move |binder| match binder.no_bound_vars() {
1061 Some(OutlivesClause(ty, r)) => (ty == t).then_some(r),
1062 None => Some(Region::new_static(cx)),
1063 })
1064}
1065
1066pub struct PlaceholderReplacer<I: Interner> {
1067 cx: I,
1068 existing_var_count: usize,
1069 bound_vars: IndexMap<BoundVar, BoundRegion<I>>,
1070 universe: UniverseIndex,
1071 current_index: DebruijnIndex,
1072}
1073
1074impl<I: Interner> TypeFolder<I> for PlaceholderReplacer<I> {
1075 fn cx(&self) -> I {
1076 self.cx
1077 }
1078
1079 fn fold_region(&mut self, r: Region<I>) -> Region<I> {
1080 match r.kind() {
1081 RegionKind::RePlaceholder(p) if p.universe == self.universe => {
1082 let bound_vars_len = self.bound_vars.len();
1083 let mapped_var = self.bound_vars.entry(p.bound.var).or_insert(BoundRegion {
1084 var: BoundVar::from_usize(self.existing_var_count + bound_vars_len),
1085 kind: p.bound.kind,
1086 });
1087 Region::new_bound(self.cx, self.current_index, *mapped_var)
1088 }
1089 _ => r,
1091 }
1092 }
1093
1094 fn fold_binder<T: TypeFoldable<I>>(&mut self, b: Binder<I, T>) -> Binder<I, T> {
1095 self.current_index.shift_in(1);
1096 let b = b.super_fold_with(self);
1097 self.current_index.shift_out(1);
1098 b
1099 }
1100}
1101
1102{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("alias_outlives_candidates_from_assumptions",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(1106u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("bound_outlives")
}> =
::tracing::__macro_support::FieldName::new("bound_outlives");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("assumptions")
}> =
::tracing::__macro_support::FieldName::new("assumptions");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bound_outlives)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: Or<I> = loop {};
return __tracing_attr_fake_return;
}
{
let mut candidates = Vec::new();
let prev_universe = infcx.universe();
infcx.enter_forall_with_empty_assumptions(bound_outlives,
|(alias, r)|
{
for bound_type_outlives in assumptions.type_outlives.iter()
{
let OutlivesClause(alias2, r2) =
infcx.instantiate_binder_with_infer(*bound_type_outlives);
let mut relation =
HigherRankedAliasMatcher {
infcx,
region_constraints: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[LeafRegionConstraint::RegionOutlives(r2, r, ())])),
};
if let Ok(_) =
relation.relate(alias.to_ty(infcx.cx(), IsRigid::No),
set_aliases_to_non_rigid(infcx.cx(),
alias2).skip_norm_wip()) {
candidates.push(And::new(relation.region_constraints));
}
}
});
let constraint =
RegionConstraint::new_from_or(Or::new(candidates));
let largest_universe = infcx.universe();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:1140",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(1140u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("prev_universe")
}> =
::tracing::__macro_support::FieldName::new("prev_universe");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("largest_universe")
}> =
::tracing::__macro_support::FieldName::new("largest_universe");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&prev_universe)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&largest_universe)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let canonical_constraint =
((prev_universe.index() +
1)..=largest_universe.index()).map(|u|
UniverseIndex::from_usize(u)).rev().fold(constraint,
|constraint, u|
{
eagerly_handle_placeholders_in_universe(infcx, constraint,
u)
});
canonical_constraint.splatted_and_constraints()
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:1106",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(1106u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
1107fn alias_outlives_candidates_from_assumptions<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
1108 infcx: &Infcx,
1109 bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
1110 assumptions: &Assumptions<I>,
1111) -> Or<I> {
1112 let mut candidates = Vec::new();
1113
1114 let prev_universe = infcx.universe();
1115
1116 infcx.enter_forall_with_empty_assumptions(bound_outlives, |(alias, r)| {
1117 for bound_type_outlives in assumptions.type_outlives.iter() {
1118 let OutlivesClause(alias2, r2) =
1119 infcx.instantiate_binder_with_infer(*bound_type_outlives);
1120
1121 let mut relation = HigherRankedAliasMatcher {
1122 infcx,
1123 region_constraints: vec![LeafRegionConstraint::RegionOutlives(r2, r, ())],
1124 };
1125
1126 if let Ok(_) = relation.relate(
1129 alias.to_ty(infcx.cx(), IsRigid::No),
1130 set_aliases_to_non_rigid(infcx.cx(), alias2).skip_norm_wip(),
1131 ) {
1132 candidates.push(And::new(relation.region_constraints));
1133 }
1134 }
1135 });
1136
1137 let constraint = RegionConstraint::new_from_or(Or::new(candidates));
1138
1139 let largest_universe = infcx.universe();
1140 debug!(?prev_universe, ?largest_universe);
1141
1142 let canonical_constraint = ((prev_universe.index() + 1)..=largest_universe.index())
1143 .map(|u| UniverseIndex::from_usize(u))
1144 .rev()
1145 .fold(constraint, |constraint, u| {
1146 eagerly_handle_placeholders_in_universe(infcx, constraint, u)
1147 });
1148
1149 canonical_constraint.splatted_and_constraints()
1150}
1151
1152struct HigherRankedAliasMatcher<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> {
1153 infcx: &'a Infcx,
1154 region_constraints: Vec<LeafRegionConstraint<I>>,
1155}
1156
1157impl<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeRelation<I>
1158 for HigherRankedAliasMatcher<'a, Infcx, I>
1159{
1160 fn cx(&self) -> I {
1161 self.infcx.cx()
1162 }
1163
1164 fn relate_ty_args(
1165 &mut self,
1166 a_ty: I::Ty,
1167 _b_ty: I::Ty,
1168 _ty_def_id: I::DefId,
1169 a_args: I::GenericArgs,
1170 b_args: I::GenericArgs,
1171 _mk: impl FnOnce(I::GenericArgs) -> I::Ty,
1172 ) -> RelateResult<I, I::Ty> {
1173 rustc_type_ir::relate::relate_args_invariantly(self, a_args, b_args)?;
1174 Ok(a_ty)
1175 }
1176
1177 fn relate_with_variance<T: Relate<I>>(
1178 &mut self,
1179 _variance: Variance,
1180 _info: VarianceDiagInfo<I>,
1181 a: T,
1182 b: T,
1183 ) -> RelateResult<I, T> {
1184 self.relate(a, b)
1187 }
1188
1189 fn tys(&mut self, a: I::Ty, b: I::Ty) -> RelateResult<I, I::Ty> {
1190 rustc_type_ir::relate::structurally_relate_tys(self, a, b)
1191 }
1192
1193 fn regions(&mut self, a: Region<I>, b: Region<I>) -> RelateResult<I, Region<I>> {
1194 if a != b {
1195 self.region_constraints.push(LeafRegionConstraint::RegionOutlives(a, b, ()));
1196 self.region_constraints.push(LeafRegionConstraint::RegionOutlives(b, a, ()));
1197 }
1198 Ok(a)
1199 }
1200
1201 fn consts(&mut self, a: Const<I>, b: Const<I>) -> RelateResult<I, Const<I>> {
1202 rustc_type_ir::relate::structurally_relate_consts(self, a, b)
1203 }
1204
1205 fn binders<T>(&mut self, a: Binder<I, T>, b: Binder<I, T>) -> RelateResult<I, Binder<I, T>>
1206 where
1207 T: Relate<I>,
1208 {
1209 self.infcx.enter_forall_with_empty_assumptions(a, |a| {
1210 let u = self.infcx.universe();
1211 self.infcx.insert_placeholder_assumptions(u, Assumptions::empty());
1212 let b = self.infcx.instantiate_binder_with_infer(b);
1213 self.relate(a, b)
1214 })?;
1215
1216 self.infcx.enter_forall_with_empty_assumptions(b, |b| {
1217 let u = self.infcx.universe();
1218 self.infcx.insert_placeholder_assumptions(u, Assumptions::empty());
1219 let a = self.infcx.instantiate_binder_with_infer(a);
1220 self.relate(a, b)
1221 })?;
1222
1223 Ok(a)
1224 }
1225}