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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/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);
propagate_ambiguity(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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/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 propagate_ambiguity(constraint)
563}
564
565{}
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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(573u32),
::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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs:573",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(573u32),
::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)]
574fn compute_new_region_constraints<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
575 infcx: &Infcx,
576 constraint: RegionConstraint<I>,
577 u: UniverseIndex,
578) -> RegionConstraint<I> {
579 use LeafRegionConstraint::*;
580
581 let extend_from_and = |builder: &mut TransitiveRelationBuilder<_>,
582 regions: &mut IndexSet<_>,
583 constraints: &mut Vec<_>,
584 and: &And<I>| {
585 for c in &and.0 {
586 match c {
587 Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
588 constraints.push(c.clone())
589 }
590 RegionOutlives(r1, r2, ()) => {
591 regions.insert(*r1);
592 regions.insert(*r2);
593 builder.add(*r2, *r1);
594 }
595 }
596 }
597 };
598
599 let mut base_region_flows_builder = TransitiveRelationBuilder::default();
600 let mut base_regions = IndexSet::new();
601 let mut base_constraints = Vec::new();
602 extend_from_and(
603 &mut base_region_flows_builder,
604 &mut base_regions,
605 &mut base_constraints,
606 &constraint.and_constraint,
607 );
608
609 let mut new_ands = Vec::new();
610 for and in &constraint.or_constraint.0 {
611 let mut region_flows_builder = base_region_flows_builder.clone();
612 let mut regions = base_regions.clone();
613 let mut constraints = base_constraints.clone();
614 extend_from_and(&mut region_flows_builder, &mut regions, &mut constraints, and);
615
616 let region_flow = region_flows_builder.freeze();
617 for r in regions.into_iter() {
618 for ub in region_flow.reachable_from(r) {
619 let is_placeholder_like = |r: Region<I>| match r.kind() {
622 RegionKind::ReLateParam(..)
623 | RegionKind::ReEarlyParam(..)
624 | RegionKind::RePlaceholder(..)
625 | RegionKind::ReStatic => true,
626 RegionKind::ReVar(..) => max_universe(infcx, r) < u,
627 RegionKind::ReError(..) => false,
628 RegionKind::ReErased | RegionKind::ReBound(..) => unreachable!(),
629 };
630
631 if is_placeholder_like(r) && is_placeholder_like(ub) {
632 constraints.push(RegionOutlives(ub, r, ()));
633 }
634 }
635 }
636
637 new_ands.push(Or::new([And::new(constraints)]))
638 }
639
640 RegionConstraint::new_from_or(
642 new_ands.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c)),
643 )
644}
645
646{}
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("propagate_ambiguity",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(663u32),
::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()
}], ::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))])
})
} 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;
}
{
if let Some(ambig) =
constraint.and_constraint.0.iter().find(|c| c.is_ambig()) {
return RegionConstraint::new_leaf(ambig.clone());
}
for and in constraint.or_constraint.0.iter() {
if let Some(ambig) = and.0.iter().find(|c| c.is_ambig()) {
return RegionConstraint::new_leaf(ambig.clone());
}
}
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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs:663",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(663u32),
::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", ret)]
664pub fn propagate_ambiguity<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
665 constraint: RegionConstraint<I, S>,
666) -> RegionConstraint<I, S> {
667 if let Some(ambig) = constraint.and_constraint.0.iter().find(|c| c.is_ambig()) {
668 return RegionConstraint::new_leaf(ambig.clone());
669 }
670
671 for and in constraint.or_constraint.0.iter() {
672 if let Some(ambig) = and.0.iter().find(|c| c.is_ambig()) {
683 return RegionConstraint::new_leaf(ambig.clone());
684 }
685 }
686
687 constraint
688}
689
690{}
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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(710u32),
::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;
}
let assumptions =
match assumptions {
Some(assumptions) => assumptions,
None => {
pulled_constraints.push(Or::new_ambig(()));
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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs:710",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(710u32),
::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)]
711fn pull_region_outlives_constraints_out_of_universe<
712 Infcx: InferCtxtLike<Interner = I>,
713 I: Interner,
714>(
715 infcx: &Infcx,
716 constraint: RegionConstraint<I>,
717 u: UniverseIndex,
718 assumptions: &Option<Assumptions<I>>,
719) -> RegionConstraint<I> {
720 assert!(max_universe(infcx, constraint.clone()) <= u);
721
722 use LeafRegionConstraint::*;
730
731 let pull_and = |and: And<I>| {
732 let mut pulled_constraints = Vec::new();
733 for c in and.0 {
734 match c {
735 Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
736 assert!(max_universe(infcx, c.clone()) < u);
737 pulled_constraints.push(Or::new_leaf(c.clone()));
738 }
739 RegionOutlives(region_1, region_2, ()) => {
740 let region_1_u = max_universe(infcx, region_1);
741 let region_2_u = max_universe(infcx, region_2);
742
743 if region_1_u != u && region_2_u != u {
744 pulled_constraints.push(Or::new_leaf(c));
745 continue;
746 }
747
748 let assumptions = match assumptions {
749 Some(assumptions) => assumptions,
750 None => {
751 pulled_constraints.push(Or::new_ambig(()));
752 continue;
753 }
754 };
755
756 if regions_outlived_by(region_1, assumptions).any(|r| r == region_2) {
761 continue;
762 }
763
764 let mut candidates = vec![];
765
766 for ub in regions_outlived_by(region_1, assumptions)
767 .filter(|r| max_universe(infcx, *r) < u)
768 {
769 for lb in regions_outliving(region_2, assumptions, infcx.cx())
773 .filter(|r| max_universe(infcx, *r) < u)
774 {
775 candidates.push(RegionOutlives(ub, lb, ()));
779 }
780 }
781
782 pulled_constraints.push(Or::new(candidates.into_iter().map(|c| And::new([c]))));
783 }
784 };
785 }
786
787 pulled_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
788 };
789
790 let and_constraint = pull_and(constraint.and_constraint);
791 let or_constraint = constraint
792 .or_constraint
793 .0
794 .into_iter()
795 .fold(Or::new_false(), |acc, c| Or::build_or(acc, pull_and(c)));
796 RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
797}
798
799{}
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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(803u32),
::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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs:816",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(816u32),
::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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs:842",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(842u32),
::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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs:846",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(846u32),
::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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs:803",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(803u32),
::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)]
804pub fn destructure_type_outlives_constraints_in_root<
805 Infcx: InferCtxtLike<Interner = I>,
806 I: Interner,
807 S: Clone + std::fmt::Debug + Eq + std::hash::Hash,
808>(
809 infcx: &Infcx,
810 constraint: RegionConstraint<I, S>,
811 assumptions: &Assumptions<I>,
812) -> RegionConstraint<I, S> {
813 use LeafRegionConstraint::*;
814
815 let destructure_and = |and: &And<I, S>| {
816 debug!("rewriting and: {:?}", and);
817 let mut destructured_constraints = Vec::new();
818 for c in &and.0 {
819 match c {
820 Ambiguity(_) | RegionOutlives(..) => {
821 destructured_constraints.push(Or::new_leaf(c.clone()))
822 }
823 PlaceholderTyOutlives(ty, r, span) => destructured_constraints.push(Or::new(
824 regions_outlived_by_placeholder(*ty, assumptions, infcx.cx()).map(
825 move |assumption_r| {
826 And::new([RegionOutlives(assumption_r, *r, span.clone())])
827 },
828 ),
829 )),
830 AliasTyOutlivesViaEnv(bound_outlives, span) => {
831 destructured_constraints.push(
832 alias_outlives_candidates_from_assumptions(
833 infcx,
834 *bound_outlives,
835 assumptions,
836 )
837 .with_spans(span.clone()),
838 );
839 }
840 }
841 }
842 debug!(?destructured_constraints);
843 let merged_constraints = destructured_constraints
844 .into_iter()
845 .fold(Or::new_true(), |acc, c| Or::build_and(acc, c));
846 debug!(?merged_constraints);
847 merged_constraints
848 };
849
850 let and_constraint = destructure_and(&constraint.and_constraint);
851 let or_constraint = constraint
852 .or_constraint
853 .0
854 .into_iter()
855 .fold(Or::new_false(), |acc, c| Or::build_or(acc, destructure_and(&c)));
856
857 RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
858}
859
860{}
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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(870u32),
::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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs:870",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(870u32),
::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)]
871fn rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling<
872 Infcx: InferCtxtLike<Interner = I>,
873 I: Interner,
874>(
875 infcx: &Infcx,
876 constraint: RegionConstraint<I>,
877 u: UniverseIndex,
878 assumptions: &Option<Assumptions<I>>,
879) -> RegionConstraint<I> {
880 use LeafRegionConstraint::*;
881
882 assert!(
883 max_universe(infcx, constraint.clone()) <= u,
884 "constraint {:?} contains terms from a larger universe than {:?}",
885 constraint.clone(),
886 u
887 );
888
889 let rewrite_and = |and: And<I>| {
890 let mut rewritten_constraints = Vec::new();
891 for c in and.0 {
892 match c {
893 Ambiguity(()) | RegionOutlives(..) => rewritten_constraints.push(Or::new_leaf(c)),
894 PlaceholderTyOutlives(ty, region, ()) => {
895 rewritten_constraints.push(rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, ty, region, u, assumptions));
896 }
897 AliasTyOutlivesViaEnv(bound_outlives, ()) => {
898 rewritten_constraints.push(rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, bound_outlives, u, assumptions));
899 }
900 }
901 }
902 rewritten_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
903 };
904
905 let and_constraint = rewrite_and(constraint.and_constraint);
906 let or_constraint = constraint
907 .or_constraint
908 .0
909 .into_iter()
910 .fold(Or::new_false(), |acc, c| Or::build_or(acc, rewrite_and(c)));
911
912 RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
913}
914
915fn rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
916 Infcx: InferCtxtLike<Interner = I>,
917 I: Interner,
918>(
919 infcx: &Infcx,
920 ty: I::Ty,
921 region: Region<I>,
922 u: UniverseIndex,
923 assumptions: &Option<Assumptions<I>>,
924) -> Or<I> {
925 use LeafRegionConstraint::*;
926
927 let ty_u = max_universe(infcx, ty);
928 let region_u = max_universe(infcx, region);
929
930 if region_u != u && ty_u != u {
931 return Or::new_leaf(PlaceholderTyOutlives(ty, region, ()));
932 }
933
934 let assumptions = match assumptions {
935 Some(assumptions) => assumptions,
936 None => return Or::new_ambig(()),
937 };
938
939 let mut candidates = ::alloc::vec::Vec::new()vec![];
940
941 candidates.extend(
944 regions_outlived_by_placeholder(ty, assumptions, infcx.cx())
945 .map(move |assumption_r| RegionOutlives(assumption_r, region, ())),
946 );
947
948 if region_u == u && ty_u < u {
952 candidates.extend(
953 regions_outliving::<I>(region, assumptions, infcx.cx())
954 .filter(|r| max_universe(infcx, *r) < u)
955 .map(|r| PlaceholderTyOutlives(ty, r, ())),
956 );
957 }
958
959 Or::new(candidates.into_iter().map(|c| And::new([c])))
960}
961
962fn rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
963 Infcx: InferCtxtLike<Interner = I>,
964 I: Interner,
965>(
966 infcx: &Infcx,
967 bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
968 u: UniverseIndex,
969 assumptions: &Option<Assumptions<I>>,
970) -> Or<I> {
971 use LeafRegionConstraint::*;
972
973 let mut candidates = Vec::new();
974
975 if max_universe(infcx, bound_outlives) == u {
991 let mut replacer = PlaceholderReplacer {
992 cx: infcx.cx(),
993 existing_var_count: bound_outlives.bound_vars().len(),
994 bound_vars: IndexMap::default(),
995 universe: u,
996 current_index: DebruijnIndex::ZERO,
997 };
998 let escaping_outlives = bound_outlives.skip_binder().fold_with(&mut replacer);
999 let bound_vars = bound_outlives.bound_vars().iter().chain(
1000 core::mem::take(&mut replacer.bound_vars)
1001 .into_iter()
1002 .map(|(_, bound_region)| BoundVariableKind::Region(bound_region.kind)),
1003 );
1004 let bound_outlives = Binder::bind_with_vars(
1005 escaping_outlives,
1006 I::BoundVarKinds::from_vars(infcx.cx(), bound_vars),
1007 );
1008 let candidate = Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, ()));
1009 if max_universe(infcx, candidate.clone()) < u {
1010 candidates.push(candidate);
1011 } else {
1012 candidates.push(Or::new_ambig(()));
1016 }
1017 }
1018
1019 let assumptions = match assumptions {
1020 Some(assumptions) => assumptions,
1021 None => {
1022 candidates.push(Or::new_ambig(()));
1023 return candidates.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c));
1024 }
1025 };
1026
1027 candidates.push(alias_outlives_candidates_from_assumptions(infcx, bound_outlives, assumptions));
1030
1031 let (escaping_alias, escaping_r) = bound_outlives.skip_binder();
1036 if max_universe(infcx, escaping_r) == u {
1037 let mut replacer = PlaceholderReplacer {
1038 cx: infcx.cx(),
1039 existing_var_count: bound_outlives.bound_vars().len(),
1040 bound_vars: IndexMap::default(),
1041 universe: u,
1042 current_index: DebruijnIndex::ZERO,
1043 };
1044 let escaping_alias = escaping_alias.fold_with(&mut replacer);
1045 let bound_vars = bound_outlives.bound_vars().iter().chain(
1046 core::mem::take(&mut replacer.bound_vars)
1047 .into_iter()
1048 .map(|(_, bound_region)| BoundVariableKind::Region(bound_region.kind)),
1049 );
1050 let bound_alias = Binder::bind_with_vars(
1051 escaping_alias,
1052 I::BoundVarKinds::from_vars(infcx.cx(), bound_vars),
1053 );
1054
1055 candidates.push(Or::new(
1058 regions_outliving(escaping_r, assumptions, infcx.cx())
1059 .filter(|r2| max_universe(infcx, *r2) < u)
1060 .map(|r2| {
1061 let candidate =
1062 AliasTyOutlivesViaEnv(bound_alias.map_bound(|alias| (alias, r2)), ());
1063 if max_universe(infcx, candidate.clone()) < u {
1064 And::new([candidate])
1065 } else {
1066 And::new([Ambiguity(())])
1067 }
1068 }),
1069 ));
1070 }
1071
1072 match infcx.typing_mode_raw() {
1076 TypingMode::Coherence => candidates.push(Or::new_ambig(())),
1077 TypingMode::Typeck { .. }
1078 | TypingMode::Reflection
1079 | TypingMode::ErasedNotCoherence { .. }
1080 | TypingMode::PostTypeckUntilBorrowck { .. }
1081 | TypingMode::PostBorrowck { .. }
1082 | TypingMode::PostAnalysis
1083 | TypingMode::Codegen => (),
1084 };
1085
1086 candidates.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c))
1087}
1088
1089pub fn regions_outlived_by<I: Interner>(
1092 r: Region<I>,
1093 assumptions: &Assumptions<I>,
1094) -> impl Iterator<Item = Region<I>> {
1095 assumptions.region_outlives.reachable_from(r).into_iter().chain([r])
1096}
1097
1098pub fn regions_outliving<I: Interner>(
1101 r: Region<I>,
1102 assumptions: &Assumptions<I>,
1103 cx: I,
1104) -> impl Iterator<Item = Region<I>> {
1105 assumptions
1106 .inverse_region_outlives
1107 .reachable_from(r)
1108 .into_iter()
1109 .chain([r, Region::new_static(cx)])
1112}
1113
1114pub fn regions_outlived_by_placeholder<I: Interner>(
1117 t: I::Ty,
1118 assumptions: &Assumptions<I>,
1119 cx: I,
1120) -> impl Iterator<Item = Region<I>> {
1121 match t.kind() {
1122 TyKind::Placeholder(..) | TyKind::Param(..) => (),
1123 _ => {
::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:?}"),
1124 }
1125
1126 assumptions.type_outlives.iter().flat_map(move |binder| match binder.no_bound_vars() {
1127 Some(OutlivesClause(ty, r)) => (ty == t).then_some(r),
1128 None => Some(Region::new_static(cx)),
1129 })
1130}
1131
1132pub struct PlaceholderReplacer<I: Interner> {
1133 cx: I,
1134 existing_var_count: usize,
1135 bound_vars: IndexMap<BoundVar, BoundRegion<I>>,
1136 universe: UniverseIndex,
1137 current_index: DebruijnIndex,
1138}
1139
1140impl<I: Interner> TypeFolder<I> for PlaceholderReplacer<I> {
1141 fn cx(&self) -> I {
1142 self.cx
1143 }
1144
1145 fn fold_region(&mut self, r: Region<I>) -> Region<I> {
1146 match r.kind() {
1147 RegionKind::RePlaceholder(p) if p.universe == self.universe => {
1148 let bound_vars_len = self.bound_vars.len();
1149 let mapped_var = self.bound_vars.entry(p.bound.var).or_insert(BoundRegion {
1150 var: BoundVar::from_usize(self.existing_var_count + bound_vars_len),
1151 kind: p.bound.kind,
1152 });
1153 Region::new_bound(self.cx, self.current_index, *mapped_var)
1154 }
1155 _ => r,
1157 }
1158 }
1159
1160 fn fold_binder<T: TypeFoldable<I>>(&mut self, b: Binder<I, T>) -> Binder<I, T> {
1161 self.current_index.shift_in(1);
1162 let b = b.super_fold_with(self);
1163 self.current_index.shift_out(1);
1164 b
1165 }
1166}
1167
1168{}
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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(1172u32),
::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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs:1206",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(1206u32),
::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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs:1172",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(1172u32),
::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)]
1173fn alias_outlives_candidates_from_assumptions<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
1174 infcx: &Infcx,
1175 bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
1176 assumptions: &Assumptions<I>,
1177) -> Or<I> {
1178 let mut candidates = Vec::new();
1179
1180 let prev_universe = infcx.universe();
1181
1182 infcx.enter_forall_with_empty_assumptions(bound_outlives, |(alias, r)| {
1183 for bound_type_outlives in assumptions.type_outlives.iter() {
1184 let OutlivesClause(alias2, r2) =
1185 infcx.instantiate_binder_with_infer(*bound_type_outlives);
1186
1187 let mut relation = HigherRankedAliasMatcher {
1188 infcx,
1189 region_constraints: vec![LeafRegionConstraint::RegionOutlives(r2, r, ())],
1190 };
1191
1192 if let Ok(_) = relation.relate(
1195 alias.to_ty(infcx.cx(), IsRigid::No),
1196 set_aliases_to_non_rigid(infcx.cx(), alias2).skip_norm_wip(),
1197 ) {
1198 candidates.push(And::new(relation.region_constraints));
1199 }
1200 }
1201 });
1202
1203 let constraint = RegionConstraint::new_from_or(Or::new(candidates));
1204
1205 let largest_universe = infcx.universe();
1206 debug!(?prev_universe, ?largest_universe);
1207
1208 let canonical_constraint = ((prev_universe.index() + 1)..=largest_universe.index())
1209 .map(|u| UniverseIndex::from_usize(u))
1210 .rev()
1211 .fold(constraint, |constraint, u| {
1212 eagerly_handle_placeholders_in_universe(infcx, constraint, u)
1213 });
1214
1215 canonical_constraint.splatted_and_constraints()
1216}
1217
1218struct HigherRankedAliasMatcher<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> {
1219 infcx: &'a Infcx,
1220 region_constraints: Vec<LeafRegionConstraint<I>>,
1221}
1222
1223impl<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeRelation<I>
1224 for HigherRankedAliasMatcher<'a, Infcx, I>
1225{
1226 fn cx(&self) -> I {
1227 self.infcx.cx()
1228 }
1229
1230 fn relate_ty_args(
1231 &mut self,
1232 a_ty: I::Ty,
1233 _b_ty: I::Ty,
1234 _ty_def_id: I::DefId,
1235 a_args: I::GenericArgs,
1236 b_args: I::GenericArgs,
1237 _mk: impl FnOnce(I::GenericArgs) -> I::Ty,
1238 ) -> RelateResult<I, I::Ty> {
1239 rustc_type_ir::relate::relate_args_invariantly(self, a_args, b_args)?;
1240 Ok(a_ty)
1241 }
1242
1243 fn relate_with_variance<T: Relate<I>>(
1244 &mut self,
1245 _variance: Variance,
1246 _info: VarianceDiagInfo<I>,
1247 a: T,
1248 b: T,
1249 ) -> RelateResult<I, T> {
1250 self.relate(a, b)
1253 }
1254
1255 fn tys(&mut self, a: I::Ty, b: I::Ty) -> RelateResult<I, I::Ty> {
1256 rustc_type_ir::relate::structurally_relate_tys(self, a, b)
1257 }
1258
1259 fn regions(&mut self, a: Region<I>, b: Region<I>) -> RelateResult<I, Region<I>> {
1260 if a != b {
1261 self.region_constraints.push(LeafRegionConstraint::RegionOutlives(a, b, ()));
1262 self.region_constraints.push(LeafRegionConstraint::RegionOutlives(b, a, ()));
1263 }
1264 Ok(a)
1265 }
1266
1267 fn consts(&mut self, a: Const<I>, b: Const<I>) -> RelateResult<I, Const<I>> {
1268 rustc_type_ir::relate::structurally_relate_consts(self, a, b)
1269 }
1270
1271 fn binders<T>(&mut self, a: Binder<I, T>, b: Binder<I, T>) -> RelateResult<I, Binder<I, T>>
1272 where
1273 T: Relate<I>,
1274 {
1275 self.infcx.enter_forall_with_empty_assumptions(a, |a| {
1276 let u = self.infcx.universe();
1277 self.infcx.insert_placeholder_assumptions(u, Some(Assumptions::empty()));
1278 let b = self.infcx.instantiate_binder_with_infer(b);
1279 self.relate(a, b)
1280 })?;
1281
1282 self.infcx.enter_forall_with_empty_assumptions(b, |b| {
1283 let u = self.infcx.universe();
1284 self.infcx.insert_placeholder_assumptions(u, Some(Assumptions::empty()));
1285 let a = self.infcx.instantiate_binder_with_infer(a);
1286 self.relate(a, b)
1287 })?;
1288
1289 Ok(a)
1290 }
1291}