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 smallvec::SmallVec;
52
53use crate::data_structures::IndexMap;
54use crate::fold::TypeSuperFoldable;
55use crate::inherent::*;
56use crate::relate::{Relate, RelateResult, TypeRelation, VarianceDiagInfo};
57use crate::visit::TypeVisitableExt;
58use crate::{
59 AliasTy, Binder, BoundRegion, BoundRegionKind, BoundVar, BoundVariableKind, ClauseKind,
60 DebruijnIndex, InferCtxtLike, Interner, IsRigid, OutlivesClause, Region, RegionKind, TyKind,
61 TypeFoldable, TypeFolder, TypingMode, UniverseIndex, Variance, elaborate, max_universe,
62 set_aliases_to_non_rigid,
63};
64
65#[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),
},
}
}
}#[derive_where(Clone; I: Interner)]
66pub struct Assumptions<I: Interner> {
67 pub type_outlives: Vec<Binder<I, OutlivesClause<I, I::Ty>>>,
68 pub region_outlives: TransitiveRelation<Region<I>>,
73 pub inverse_region_outlives: TransitiveRelation<Region<I>>,
74}
75
76impl<I: Interner> std::fmt::Debug for Assumptions<I> {
77 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
78 f.debug_struct("Assumptions")
79 .field("type_outlives", &self.type_outlives)
80 .field("region_graph", &"elided")
81 .finish()
82 }
83}
84
85impl<I: Interner> Assumptions<I> {
86 pub fn empty() -> Self {
87 Self {
88 type_outlives: Vec::new(),
89 region_outlives: TransitiveRelationBuilder::default().freeze(),
90 inverse_region_outlives: TransitiveRelationBuilder::default().freeze(),
91 }
92 }
93
94 pub fn new(
116 infcx: &impl InferCtxtLike<Interner = I>,
117 clauses: impl IntoIterator<Item = I::Clause>,
118 region_outlives: TransitiveRelation<Region<I>>,
119 universe: UniverseIndex,
120 ) -> Self {
121 let mut type_outlives = ::alloc::vec::Vec::new()vec![];
122 let mut region_outlives_builder = TransitiveRelationBuilder::default();
123 for (r1, r2) in region_outlives.base_edges() {
124 region_outlives_builder.add(r1, r2);
125 }
126
127 let clauses = elaborate::elaborate(infcx.cx(), clauses)
128 .filter(|clause| max_universe(infcx, *clause) == universe);
129 for clause in clauses {
130 match clause.kind().skip_binder() {
131 ClauseKind::TypeOutlives(_) => {
134 type_outlives.push(clause.as_type_outlives_clause().unwrap());
135 }
136 ClauseKind::RegionOutlives(OutlivesClause(r1, r2)) => {
137 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());
141 region_outlives_builder.add(r1, r2);
142 }
143 _ => (),
145 }
146 }
147
148 Self::new_unelaborated(type_outlives, region_outlives_builder.freeze())
149 }
150
151 pub fn new_unelaborated(
154 type_outlives: Vec<Binder<I, OutlivesClause<I, I::Ty>>>,
155 region_outlives: TransitiveRelation<Region<I>>,
156 ) -> Self {
157 Self {
158 inverse_region_outlives: {
159 let mut builder = TransitiveRelationBuilder::default();
160 for (r1, r2) in region_outlives.base_edges() {
161 builder.add(r2, r1);
162 }
163 builder.freeze()
164 },
165 type_outlives,
166 region_outlives,
167 }
168 }
169}
170
171#[automatically_derived]
impl<I: Interner, S: Clone> ::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> ::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> ::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> 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> ::core::cmp::Eq for LeafRegionConstraint<I, S>
where I: Interner, S: ::core::cmp::Eq {
}#[derive_where(Clone, Hash, PartialEq, Eq; I: Interner, S)]
172#[derive(const _: () =
{
impl<I: Interner, S: Clone> ::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, __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> ::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)]
173#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<I: Interner, S: Clone>
::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))]
174pub enum LeafRegionConstraint<I: Interner, S: Clone = ()> {
175 Ambiguity(S),
176 RegionOutlives(Region<I>, Region<I>, S),
177 AliasTyOutlivesViaEnv(Binder<I, (AliasTy<I>, Region<I>)>, S),
187 PlaceholderTyOutlives(I::Ty, Region<I>, S),
197}
198
199impl<I: Interner, S: Clone> std::fmt::Debug for LeafRegionConstraint<I, S> {
200 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
201 match self {
202 Self::Ambiguity(_span) => f.write_str("ambiguity"),
203 Self::RegionOutlives(r1, r2, _span) => {
204 r1.fmt(f)?;
205 f.write_str(": ")?;
206 r2.fmt(f)
207 }
208 Self::AliasTyOutlivesViaEnv(bound_outlives, _span) => {
209 f.write_str("for<")?;
210 bound_outlives.bound_vars().fmt(f)?;
211 f.write_str(">")?;
212 let (ty, r) = bound_outlives.skip_binder();
213 ty.fmt(f)?;
214 f.write_str(": ")?;
215 r.fmt(f)
216 }
217 Self::PlaceholderTyOutlives(ty, r, _span) => {
218 ty.fmt(f)?;
219 f.write_str(": ")?;
220 r.fmt(f)
221 }
222 }
223 }
224}
225
226impl<I: Interner> LeafRegionConstraint<I> {
227 pub fn with_span<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
228 self,
229 span: S,
230 ) -> LeafRegionConstraint<I, S> {
231 use LeafRegionConstraint::*;
232
233 match self {
234 Ambiguity(()) => Ambiguity(span),
235 RegionOutlives(r1, r2, ()) => RegionOutlives(r1, r2, span),
236 AliasTyOutlivesViaEnv(bound_outlives, ()) => {
237 AliasTyOutlivesViaEnv(bound_outlives, span)
238 }
239 PlaceholderTyOutlives(ty, r, ()) => PlaceholderTyOutlives(ty, r, span),
240 }
241 }
242}
243
244impl<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash> LeafRegionConstraint<I, S> {
245 pub fn without_span(self) -> LeafRegionConstraint<I> {
246 use LeafRegionConstraint::*;
247
248 match self {
249 Ambiguity(_) => Ambiguity(()),
250 RegionOutlives(r1, r2, _) => RegionOutlives(r1, r2, ()),
251 AliasTyOutlivesViaEnv(bound_outlives, _) => AliasTyOutlivesViaEnv(bound_outlives, ()),
252 PlaceholderTyOutlives(ty, r, _) => PlaceholderTyOutlives(ty, r, ()),
253 }
254 }
255
256 pub fn span(&self) -> S {
257 use LeafRegionConstraint::*;
258
259 let (Ambiguity(s)
260 | RegionOutlives(_, _, s)
261 | AliasTyOutlivesViaEnv(_, s)
262 | PlaceholderTyOutlives(_, _, s)) = self;
263 s.clone()
264 }
265}
266
267#[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<SmallVec<[And<I, S>; 1]>>;
}
}
};
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::Eq for Or<I, S>
where I: Interner, S: ::core::cmp::Eq {
}#[derive_where(Clone, Hash, PartialEq, Eq; I: Interner, S)]
268#[derive(const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_type_ir::TypeVisitable<I> for Or<I, S> where I: Interner,
SmallVec<[And<I, S>; 1]>: ::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
SmallVec<[And<I,
S>; 1]>: ::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>,
SmallVec<[And<I, S>; 1]>: ::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)]
269#[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
SmallVec<[And<I,
S>; 1]>: ::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))]
270pub struct Or<I: Interner, S: Clone + std::fmt::Debug = ()>(pub SmallVec<[And<I, S>; 1]>);
281impl<I: Interner> Or<I> {
282 pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
283 self,
284 span: S,
285 ) -> Or<I, S> {
286 Or(self.0.into_iter().map(|and| and.with_spans(span.clone())).collect())
287 }
288}
289impl<I: Interner, S: Clone + std::hash::Hash + std::fmt::Debug + Eq> Or<I, S> {
290 pub fn new_true() -> Self {
291 Self(SmallVec::from_buf([And::new_true()]))
292 }
293
294 pub fn is_true(&self) -> bool {
295 if let [and] = &*self.0
297 && and.0.is_empty()
298 {
299 true
300 } else {
301 false
302 }
303 }
304
305 pub fn new_false() -> Self {
306 Self(SmallVec::new())
307 }
308
309 pub fn is_false(&self) -> bool {
310 self.0.is_empty()
312 }
313
314 pub fn new(i: impl IntoIterator<Item = And<I, S>>) -> Self {
315 let mut new_ands: SmallVec<[And<I, S>; _]> = SmallVec::new();
316
317 for and in i {
318 if and.0.is_empty() {
322 return Self::new_true();
323 }
324
325 if new_ands.iter().all(|c| !c.is_and_equivalent_to(&and)) {
330 new_ands.push(and)
331 }
332 }
333
334 Self(new_ands)
335 }
336
337 pub fn new_ambig(s: S) -> Self {
338 Or::new_leaf(LeafRegionConstraint::Ambiguity(s))
339 }
340
341 pub fn new_leaf(l: LeafRegionConstraint<I, S>) -> Self {
342 Or::new([And::new([l])])
343 }
344
345 pub fn build_and(a: Or<I, S>, b: Or<I, S>) -> Self {
346 let mut ands = Vec::new();
351 for b_and in b.0 {
352 for a_and in a.0.clone().into_iter() {
353 ands.push(And::new(a_and.0.into_iter().chain(b_and.0.clone())))
354 }
355 }
356
357 Or::new(ands)
358 }
359
360 pub fn build_or(a: Or<I, S>, b: Or<I, S>) -> Self {
361 Or::new(a.0.into_iter().chain(b.0))
362 }
363
364 pub fn without_spans(self) -> Or<I> {
365 Or(self.0.into_iter().map(|and| and.without_spans()).collect())
366 }
367}
368
369impl<I: Interner, S: Clone + std::fmt::Debug> std::fmt::Debug for Or<I, S> {
370 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
371 if self.0.is_empty() {
372 f.write_str("false")
373 } else if let [single] = &*self.0 {
374 single.fmt(f)
375 } else {
376 f.write_str("or ")?;
377 f.debug_set().entries(&self.0).finish()
378 }
379 }
380}
381
382#[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<SmallVec<[LeafRegionConstraint<I, S>; 1]>>;
}
}
};
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::Eq for And<I, S>
where I: Interner, S: ::core::cmp::Eq {
}#[derive_where(Clone, Hash, PartialEq, Eq; I: Interner, S)]
383#[derive(const _: () =
{
impl<I: Interner, S: Clone + std::fmt::Debug>
::rustc_type_ir::TypeVisitable<I> for And<I, S> where I: Interner,
SmallVec<[LeafRegionConstraint<I,
S>; 1]>: ::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
SmallVec<[LeafRegionConstraint<I,
S>; 1]>: ::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>,
SmallVec<[LeafRegionConstraint<I,
S>; 1]>: ::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)]
384#[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
SmallVec<[LeafRegionConstraint<I,
S>; 1]>: ::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))]
385pub struct And<I: Interner, S: Clone + std::fmt::Debug = ()>(
389 pub SmallVec<[LeafRegionConstraint<I, S>; 1]>,
390);
391impl<I: Interner> And<I> {
392 pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
393 self,
394 span: S,
395 ) -> And<I, S> {
396 And(self.0.into_iter().map(|leaf| leaf.with_span(span.clone())).collect())
397 }
398}
399impl<I: Interner, S: Clone + std::hash::Hash + std::fmt::Debug + Eq> And<I, S> {
400 pub fn new_true() -> Self {
401 Self(SmallVec::new())
402 }
403
404 pub fn new(i: impl IntoIterator<Item = LeafRegionConstraint<I, S>>) -> Self {
405 let mut seen = IndexSet::new();
406 And(i
407 .into_iter()
408 .filter(|leaf| {
409 if let LeafRegionConstraint::RegionOutlives(r1, r2, _) = leaf
413 && r1 == r2
414 {
415 return false;
416 }
417
418 if seen.contains(&leaf.clone().without_span()) {
419 false
420 } else {
421 seen.insert(leaf.clone().without_span());
422 true
423 }
424 })
425 .collect())
426 }
427
428 fn is_and_equivalent_to(&self, other: &And<I, S>) -> bool {
429 let this = self.clone().0;
430 let other = other.clone().0;
431
432 this.iter()
433 .all(|c1| other.iter().any(|c2| c1.clone().without_span() == c2.clone().without_span()))
434 && other.iter().all(|c2| {
435 this.iter().any(|c1| c1.clone().without_span() == c2.clone().without_span())
436 })
437 }
438
439 pub fn without_spans(self) -> And<I> {
440 And(self.0.into_iter().map(|leaf| leaf.without_span()).collect())
441 }
442}
443
444impl<I: Interner, S: Clone + std::fmt::Debug> std::fmt::Debug for And<I, S> {
445 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
446 if self.0.is_empty() {
447 f.write_str("true")
448 } else if let [single] = &*self.0 {
449 single.fmt(f)
450 } else {
451 f.write_str("and ")?;
452 f.debug_set().entries(&self.0).finish()
453 }
454 }
455}
456
457#[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),
}
}
}#[derive_where(Clone, Hash, PartialEq; I: Interner, S)]
458#[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)]
459#[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))]
460pub struct RegionConstraint<I: Interner, S: Clone + std::fmt::Debug = ()> {
470 pub and_constraint: And<I, S>,
471 pub or_constraint: Or<I, S>,
472}
473
474impl<I: Interner> RegionConstraint<I> {
475 pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
476 self,
477 span: S,
478 ) -> RegionConstraint<I, S> {
479 RegionConstraint {
480 and_constraint: self.and_constraint.with_spans(span.clone()),
481 or_constraint: self.or_constraint.with_spans(span.clone()),
482 }
483 }
484}
485impl<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash> RegionConstraint<I, S> {
486 pub fn new_from_or(or: Or<I, S>) -> Self {
487 let Some(fst) = or.0.get(0).clone() else {
488 return RegionConstraint::new_false();
489 };
490 let mut and_constraint = fst.0.to_vec();
491
492 for and in or.0.split_first().unwrap().1 {
493 and_constraint.retain(|c| {
494 and.0.iter().any(|c2| c.clone().without_span() == c2.clone().without_span())
495 });
496 }
497 let and_constraint = And::new(and_constraint);
498
499 let or_constraint = Or::new(or.0.into_iter().map(|and| {
500 And::new(and.0.into_iter().filter(|c| {
501 and_constraint
502 .0
503 .iter()
504 .all(|s_c| c.clone().without_span() != s_c.clone().without_span())
505 }))
506 }));
507
508 Self {
509 and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
510 or_constraint,
511 }
512 }
513
514 pub fn splatted_and_constraints(&self) -> Or<I, S> {
515 Or::new(self.or_constraint.0.iter().map(|and| {
516 And::new(and.0.iter().cloned().chain(self.and_constraint.0.iter().cloned()))
517 }))
518 }
519
520 pub fn build_and(a: RegionConstraint<I, S>, b: RegionConstraint<I, S>) -> Self {
521 let and_constraint = And::new(a.and_constraint.0.into_iter().chain(b.and_constraint.0));
522 let or_constraint = Or::build_and(a.or_constraint, b.or_constraint);
523
524 Self {
525 and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
526 or_constraint,
527 }
528 }
529
530 pub fn build_or(a: RegionConstraint<I, S>, b: RegionConstraint<I, S>) -> Self {
531 Self::new_from_or(Or::build_or(a.splatted_and_constraints(), b.splatted_and_constraints()))
532 }
533
534 pub fn new_true() -> Self {
535 Self { and_constraint: And::new_true(), or_constraint: Or::new_true() }
536 }
537
538 pub fn is_true(&self) -> bool {
539 self.and_constraint.0.is_empty() && self.or_constraint.is_true()
540 }
541
542 pub fn new_false() -> Self {
543 Self { and_constraint: And::new_true(), or_constraint: Or::new_false() }
544 }
545
546 pub fn is_false(&self) -> bool {
547 self.or_constraint.is_false()
548 }
549
550 pub fn new_ambig(span: S) -> Self {
551 Self {
552 and_constraint: And::new([LeafRegionConstraint::Ambiguity(span)]),
553 or_constraint: Or::new_true(),
554 }
555 }
556
557 pub fn is_ambig(&self) -> bool {
558 if let [c] = &*self.and_constraint.0
559 && c.is_ambig()
560 && self.or_constraint.is_true()
561 {
562 true
563 } else {
564 false
565 }
566 }
567
568 pub fn without_spans(self) -> RegionConstraint<I> {
569 RegionConstraint {
570 and_constraint: self.and_constraint.without_spans(),
571 or_constraint: self.or_constraint.without_spans(),
572 }
573 }
574
575 pub fn new_leaf(l: LeafRegionConstraint<I, S>) -> Self {
576 RegionConstraint { and_constraint: And::new([l]), or_constraint: Or::new_true() }
577 }
578}
579
580impl<I: Interner, S: Clone + std::fmt::Debug> std::fmt::Debug for RegionConstraint<I, S> {
581 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
582 if let [single_or] = &*self.or_constraint.0
583 && single_or.0.is_empty()
584 {
585 self.and_constraint.fmt(f)
586 } else if self.and_constraint.0.is_empty() {
587 self.or_constraint.fmt(f)
588 } else {
589 f.write_str("and ")?;
590 f.debug_set().entries(&self.and_constraint.0).entry(&self.or_constraint).finish()
591 }
592 }
593}
594
595impl<I: Interner, S: Clone + std::fmt::Debug> LeafRegionConstraint<I, S> {
596 pub fn is_ambig(&self) -> bool {
597 #[allow(non_exhaustive_omitted_patterns)] match self {
Self::Ambiguity(_) => true,
_ => false,
}matches!(self, Self::Ambiguity(_))
598 }
599}
600
601{}
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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(614u32),
::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;
}
{
if !(u > UniverseIndex::ROOT) {
{
::core::panicking::panic_fmt(format_args!("eagerly handle placeholders called for root universe"));
}
};
let assumptions = infcx.get_placeholder_assumptions(u);
let constraint =
rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
constraint, u, &assumptions);
let constraint =
compute_new_region_constraints(infcx, constraint, u);
let constraint =
pull_region_outlives_constraints_out_of_universe(infcx,
constraint, u, &assumptions);
constraint
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:614",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(614u32),
::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)]
615pub fn eagerly_handle_placeholders_in_universe<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
616 infcx: &Infcx,
617 constraint: RegionConstraint<I>,
618 u: UniverseIndex,
619) -> RegionConstraint<I> {
620 assert!(u > UniverseIndex::ROOT, "eagerly handle placeholders called for root universe");
621
622 let assumptions = infcx.get_placeholder_assumptions(u);
623
624 let constraint = rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling(
629 infcx,
630 constraint,
631 u,
632 &assumptions,
633 );
634
635 let constraint = compute_new_region_constraints(infcx, constraint, u);
639
640 let constraint =
642 pull_region_outlives_constraints_out_of_universe(infcx, constraint, u, &assumptions);
643
644 constraint
645}
646
647{}
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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(655u32),
::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:655",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(655u32),
::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)]
656fn compute_new_region_constraints<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
657 infcx: &Infcx,
658 constraint: RegionConstraint<I>,
659 u: UniverseIndex,
660) -> RegionConstraint<I> {
661 use LeafRegionConstraint::*;
662
663 let extend_from_and = |builder: &mut TransitiveRelationBuilder<_>,
664 regions: &mut IndexSet<_>,
665 constraints: &mut Vec<_>,
666 and: &And<I>| {
667 for c in &and.0 {
668 match c {
669 Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
670 constraints.push(c.clone())
671 }
672 RegionOutlives(r1, r2, ()) => {
673 regions.insert(*r1);
674 regions.insert(*r2);
675 builder.add(*r2, *r1);
676 }
677 }
678 }
679 };
680
681 let mut base_region_flows_builder = TransitiveRelationBuilder::default();
682 let mut base_regions = IndexSet::new();
683 let mut base_constraints = Vec::new();
684 extend_from_and(
685 &mut base_region_flows_builder,
686 &mut base_regions,
687 &mut base_constraints,
688 &constraint.and_constraint,
689 );
690
691 let mut new_ands = Vec::new();
692 for and in &constraint.or_constraint.0 {
693 let mut region_flows_builder = base_region_flows_builder.clone();
694 let mut regions = base_regions.clone();
695 let mut constraints = base_constraints.clone();
696 extend_from_and(&mut region_flows_builder, &mut regions, &mut constraints, and);
697
698 let region_flow = region_flows_builder.freeze();
699 for r in regions.into_iter() {
700 for ub in region_flow.reachable_from(r) {
701 let is_placeholder_like = |r: Region<I>| match r.kind() {
704 RegionKind::ReLateParam(..)
705 | RegionKind::ReEarlyParam(..)
706 | RegionKind::RePlaceholder(..)
707 | RegionKind::ReStatic => true,
708 RegionKind::ReVar(..) => max_universe(infcx, r) < u,
709 RegionKind::ReError(..) => false,
710 RegionKind::ReErased | RegionKind::ReBound(..) => unreachable!(),
711 };
712
713 if is_placeholder_like(r) && is_placeholder_like(ub) {
714 constraints.push(RegionOutlives(ub, r, ()));
715 }
716 }
717 }
718
719 new_ands.push(Or::new([And::new(constraints)]))
720 }
721
722 RegionConstraint::new_from_or(
724 new_ands.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c)),
725 )
726}
727
728{}
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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(748u32),
::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("constraint")
}> =
::tracing::__macro_support::FieldName::new("constraint");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("u")
}> =
::tracing::__macro_support::FieldName::new("u");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("assumptions")
}> =
::tracing::__macro_support::FieldName::new("assumptions");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: RegionConstraint<I> =
loop {};
return __tracing_attr_fake_return;
}
{
if !(max_universe(infcx, constraint.clone()) <= u) {
::core::panicking::panic("assertion failed: max_universe(infcx, constraint.clone()) <= u")
};
use LeafRegionConstraint::*;
let pull_and =
|and: And<I>|
{
let mut pulled_constraints = Vec::new();
for c in and.0 {
match c {
Ambiguity(()) | PlaceholderTyOutlives(..) |
AliasTyOutlivesViaEnv(..) => {
if !(max_universe(infcx, c.clone()) < u) {
::core::panicking::panic("assertion failed: max_universe(infcx, c.clone()) < u")
};
pulled_constraints.push(Or::new_leaf(c.clone()));
}
RegionOutlives(region_1, region_2, ()) => {
let region_1_u = max_universe(infcx, region_1);
let region_2_u = max_universe(infcx, region_2);
if region_1_u != u && region_2_u != u {
pulled_constraints.push(Or::new_leaf(c));
continue;
}
if regions_outlived_by(region_1,
assumptions).any(|r| r == region_2) {
continue;
}
let mut candidates = ::alloc::vec::Vec::new();
for ub in
regions_outlived_by(region_1,
assumptions).filter(|r| max_universe(infcx, *r) < u) {
for lb in
regions_outliving(region_2, assumptions,
infcx.cx()).filter(|r| max_universe(infcx, *r) < u) {
candidates.push(RegionOutlives(ub, lb, ()));
}
}
pulled_constraints.push(Or::new(candidates.into_iter().map(|c|
And::new([c]))));
}
};
}
pulled_constraints.into_iter().fold(Or::new_true(),
|acc, c| Or::build_and(acc, c))
};
let and_constraint = pull_and(constraint.and_constraint);
let or_constraint =
constraint.or_constraint.0.into_iter().fold(Or::new_false(),
|acc, c| Or::build_or(acc, pull_and(c)));
RegionConstraint::new_from_or(Or::build_and(and_constraint,
or_constraint))
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:748",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(748u32),
::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)]
749fn pull_region_outlives_constraints_out_of_universe<
750 Infcx: InferCtxtLike<Interner = I>,
751 I: Interner,
752>(
753 infcx: &Infcx,
754 constraint: RegionConstraint<I>,
755 u: UniverseIndex,
756 assumptions: &Assumptions<I>,
757) -> RegionConstraint<I> {
758 assert!(max_universe(infcx, constraint.clone()) <= u);
759
760 use LeafRegionConstraint::*;
768
769 let pull_and = |and: And<I>| {
770 let mut pulled_constraints = Vec::new();
771 for c in and.0 {
772 match c {
773 Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
774 assert!(max_universe(infcx, c.clone()) < u);
775 pulled_constraints.push(Or::new_leaf(c.clone()));
776 }
777 RegionOutlives(region_1, region_2, ()) => {
778 let region_1_u = max_universe(infcx, region_1);
779 let region_2_u = max_universe(infcx, region_2);
780
781 if region_1_u != u && region_2_u != u {
782 pulled_constraints.push(Or::new_leaf(c));
783 continue;
784 }
785
786 if regions_outlived_by(region_1, assumptions).any(|r| r == region_2) {
791 continue;
792 }
793
794 let mut candidates = vec![];
795
796 for ub in regions_outlived_by(region_1, assumptions)
797 .filter(|r| max_universe(infcx, *r) < u)
798 {
799 for lb in regions_outliving(region_2, assumptions, infcx.cx())
803 .filter(|r| max_universe(infcx, *r) < u)
804 {
805 candidates.push(RegionOutlives(ub, lb, ()));
809 }
810 }
811
812 pulled_constraints.push(Or::new(candidates.into_iter().map(|c| And::new([c]))));
813 }
814 };
815 }
816
817 pulled_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
818 };
819
820 let and_constraint = pull_and(constraint.and_constraint);
821 let or_constraint = constraint
822 .or_constraint
823 .0
824 .into_iter()
825 .fold(Or::new_false(), |acc, c| Or::build_or(acc, pull_and(c)));
826 RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
827}
828
829{}
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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(833u32),
::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/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(&["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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:872",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(872u32),
::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:876",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(876u32),
::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:833",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(833u32),
::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)]
834pub fn destructure_type_outlives_constraints_in_root<
835 Infcx: InferCtxtLike<Interner = I>,
836 I: Interner,
837 S: Clone + std::fmt::Debug + Eq + std::hash::Hash,
838>(
839 infcx: &Infcx,
840 constraint: RegionConstraint<I, S>,
841 assumptions: &Assumptions<I>,
842) -> RegionConstraint<I, S> {
843 use LeafRegionConstraint::*;
844
845 let destructure_and = |and: &And<I, S>| {
846 debug!("rewriting and: {:?}", and);
847 let mut destructured_constraints = Vec::new();
848 for c in &and.0 {
849 match c {
850 Ambiguity(_) | RegionOutlives(..) => {
851 destructured_constraints.push(Or::new_leaf(c.clone()))
852 }
853 PlaceholderTyOutlives(ty, r, span) => destructured_constraints.push(Or::new(
854 regions_outlived_by_placeholder(*ty, assumptions, infcx.cx()).map(
855 move |assumption_r| {
856 And::new([RegionOutlives(assumption_r, *r, span.clone())])
857 },
858 ),
859 )),
860 AliasTyOutlivesViaEnv(bound_outlives, span) => {
861 destructured_constraints.push(
862 alias_outlives_candidates_from_assumptions(
863 infcx,
864 *bound_outlives,
865 assumptions,
866 )
867 .with_spans(span.clone()),
868 );
869 }
870 }
871 }
872 debug!(?destructured_constraints);
873 let merged_constraints = destructured_constraints
874 .into_iter()
875 .fold(Or::new_true(), |acc, c| Or::build_and(acc, c));
876 debug!(?merged_constraints);
877 merged_constraints
878 };
879
880 let and_constraint = destructure_and(&constraint.and_constraint);
881 let or_constraint = constraint
882 .or_constraint
883 .0
884 .into_iter()
885 .fold(Or::new_false(), |acc, c| Or::build_or(acc, destructure_and(&c)));
886
887 RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
888}
889
890{}
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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(900u32),
::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:900",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(900u32),
::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)]
901fn rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling<
902 Infcx: InferCtxtLike<Interner = I>,
903 I: Interner,
904>(
905 infcx: &Infcx,
906 constraint: RegionConstraint<I>,
907 u: UniverseIndex,
908 assumptions: &Assumptions<I>,
909) -> RegionConstraint<I> {
910 use LeafRegionConstraint::*;
911
912 assert!(
913 max_universe(infcx, constraint.clone()) <= u,
914 "constraint {:?} contains terms from a larger universe than {:?}",
915 constraint.clone(),
916 u
917 );
918
919 let rewrite_and = |and: And<I>| {
920 let mut rewritten_constraints = Vec::new();
921 for c in and.0 {
922 match c {
923 Ambiguity(()) | RegionOutlives(..) => rewritten_constraints.push(Or::new_leaf(c)),
924 PlaceholderTyOutlives(ty, region, ()) => {
925 rewritten_constraints.push(rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, ty, region, u, assumptions));
926 }
927 AliasTyOutlivesViaEnv(bound_outlives, ()) => {
928 rewritten_constraints.push(rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, bound_outlives, u, assumptions));
929 }
930 }
931 }
932 rewritten_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
933 };
934
935 let and_constraint = rewrite_and(constraint.and_constraint);
936 let or_constraint = constraint
937 .or_constraint
938 .0
939 .into_iter()
940 .fold(Or::new_false(), |acc, c| Or::build_or(acc, rewrite_and(c)));
941
942 RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
943}
944
945{}
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_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(945u32),
::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("ty")
}> =
::tracing::__macro_support::FieldName::new("ty");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("region")
}> =
::tracing::__macro_support::FieldName::new("region");
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(&ty)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(®ion)
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: Or<I> = loop {};
return __tracing_attr_fake_return;
}
{
use LeafRegionConstraint::*;
let ty_u = max_universe(infcx, ty);
let region_u = max_universe(infcx, region);
if region_u != u && ty_u != u {
return Or::new_leaf(PlaceholderTyOutlives(ty, region, ()));
}
let mut candidates = ::alloc::vec::Vec::new();
candidates.extend(regions_outlived_by_placeholder(ty,
assumptions,
infcx.cx()).map(move |assumption_r|
RegionOutlives(assumption_r, region, ())));
if region_u == u && ty_u < u {
candidates.extend(regions_outliving::<I>(region,
assumptions,
infcx.cx()).filter(|r|
max_universe(infcx, *r) <
u).map(|r| PlaceholderTyOutlives(ty, r, ())));
}
Or::new(candidates.into_iter().map(|c| And::new([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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:945",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(945u32),
::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)]
946fn rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
947 Infcx: InferCtxtLike<Interner = I>,
948 I: Interner,
949>(
950 infcx: &Infcx,
951 ty: I::Ty,
952 region: Region<I>,
953 u: UniverseIndex,
954 assumptions: &Assumptions<I>,
955) -> Or<I> {
956 use LeafRegionConstraint::*;
957
958 let ty_u = max_universe(infcx, ty);
959 let region_u = max_universe(infcx, region);
960
961 if region_u != u && ty_u != u {
962 return Or::new_leaf(PlaceholderTyOutlives(ty, region, ()));
963 }
964
965 let mut candidates = vec![];
966
967 candidates.extend(
970 regions_outlived_by_placeholder(ty, assumptions, infcx.cx())
971 .map(move |assumption_r| RegionOutlives(assumption_r, region, ())),
972 );
973
974 if region_u == u && ty_u < u {
978 candidates.extend(
979 regions_outliving::<I>(region, assumptions, infcx.cx())
980 .filter(|r| max_universe(infcx, *r) < u)
981 .map(|r| PlaceholderTyOutlives(ty, r, ())),
982 );
983 }
984
985 Or::new(candidates.into_iter().map(|c| And::new([c])))
986}
987
988{}
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_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(988u32),
::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("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(&bound_outlives)
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: Or<I> = loop {};
return __tracing_attr_fake_return;
}
{
use LeafRegionConstraint::*;
if max_universe(infcx, bound_outlives) != u {
return Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives,
()));
}
let mut candidates = Vec::new();
let higher_ranked_candidate_for_outlived_region =
|region|
{
let bound_outlives =
bound_outlives.map_bound(|(alias, _)| (alias, region));
let mut replacer =
MakeHigherRankederer {
cx: infcx,
preexisting_var_count: bound_outlives.bound_vars().len(),
regions: IndexMap::default(),
universe: u,
current_index: DebruijnIndex::ZERO,
};
let escaping_outlives =
bound_outlives.skip_binder().fold_with(&mut replacer);
let bound_vars =
bound_outlives.bound_vars().iter().chain(core::mem::take(&mut replacer.regions).into_iter().map(|(_,
bound_region)|
BoundVariableKind::Region(bound_region.kind)));
let bound_outlives =
Binder::bind_with_vars(escaping_outlives,
I::BoundVarKinds::from_vars(infcx.cx(), bound_vars));
if max_universe(infcx, bound_outlives) == u {
return Or::new_ambig(());
}
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:1046",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(1046u32),
::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!("higher ranked candidate: {0:?}",
bound_outlives) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, ()))
};
let escaping_r = bound_outlives.skip_binder().1;
if max_universe(infcx, escaping_r) < u ||
escaping_r.has_escaping_bound_vars() {
candidates.push(higher_ranked_candidate_for_outlived_region(escaping_r))
} else {
for r in
regions_outliving(escaping_r, assumptions, infcx.cx()) {
candidates.push(higher_ranked_candidate_for_outlived_region(r));
}
};
candidates.push(alias_outlives_candidates_from_assumptions(infcx,
bound_outlives, assumptions));
match infcx.typing_mode_raw() {
TypingMode::Coherence => candidates.push(Or::new_ambig(())),
TypingMode::Typeck { .. } | TypingMode::Reflection |
TypingMode::ErasedNotCoherence { .. } |
TypingMode::PostTypeckUntilBorrowck { .. } |
TypingMode::PostBorrowck { .. } | TypingMode::PostAnalysis |
TypingMode::Codegen => (),
};
candidates.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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:988",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(988u32),
::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)]
989fn rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
990 Infcx: InferCtxtLike<Interner = I>,
991 I: Interner,
992>(
993 infcx: &Infcx,
994 bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
995 u: UniverseIndex,
996 assumptions: &Assumptions<I>,
997) -> Or<I> {
998 use LeafRegionConstraint::*;
999
1000 if max_universe(infcx, bound_outlives) != u {
1001 return Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, ()));
1002 }
1003
1004 let mut candidates = Vec::new();
1005
1006 let higher_ranked_candidate_for_outlived_region = |region| {
1019 let bound_outlives = bound_outlives.map_bound(|(alias, _)| (alias, region));
1020
1021 let mut replacer = MakeHigherRankederer {
1022 cx: infcx,
1023 preexisting_var_count: bound_outlives.bound_vars().len(),
1024 regions: IndexMap::default(),
1025 universe: u,
1026 current_index: DebruijnIndex::ZERO,
1027 };
1028 let escaping_outlives = bound_outlives.skip_binder().fold_with(&mut replacer);
1029 let bound_vars = bound_outlives.bound_vars().iter().chain(
1030 core::mem::take(&mut replacer.regions)
1031 .into_iter()
1032 .map(|(_, bound_region)| BoundVariableKind::Region(bound_region.kind)),
1033 );
1034 let bound_outlives = Binder::bind_with_vars(
1035 escaping_outlives,
1036 I::BoundVarKinds::from_vars(infcx.cx(), bound_vars),
1037 );
1038
1039 if max_universe(infcx, bound_outlives) == u {
1043 return Or::new_ambig(());
1044 }
1045
1046 debug!("higher ranked candidate: {bound_outlives:?}");
1047 Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, ()))
1048 };
1049
1050 let escaping_r = bound_outlives.skip_binder().1;
1061 if max_universe(infcx, escaping_r) < u || escaping_r.has_escaping_bound_vars() {
1062 candidates.push(higher_ranked_candidate_for_outlived_region(escaping_r))
1065 } else {
1066 for r in regions_outliving(escaping_r, assumptions, infcx.cx()) {
1067 candidates.push(higher_ranked_candidate_for_outlived_region(r));
1068 }
1069 };
1070
1071 candidates.push(alias_outlives_candidates_from_assumptions(infcx, bound_outlives, assumptions));
1074
1075 match infcx.typing_mode_raw() {
1079 TypingMode::Coherence => candidates.push(Or::new_ambig(())),
1080 TypingMode::Typeck { .. }
1081 | TypingMode::Reflection
1082 | TypingMode::ErasedNotCoherence { .. }
1083 | TypingMode::PostTypeckUntilBorrowck { .. }
1084 | TypingMode::PostBorrowck { .. }
1085 | TypingMode::PostAnalysis
1086 | TypingMode::Codegen => (),
1087 };
1088
1089 candidates.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c))
1090}
1091
1092pub fn regions_outlived_by<I: Interner>(
1095 r: Region<I>,
1096 assumptions: &Assumptions<I>,
1097) -> impl Iterator<Item = Region<I>> {
1098 assumptions.region_outlives.reachable_from(r).into_iter().chain([r])
1099}
1100
1101pub fn regions_outliving<I: Interner>(
1104 r: Region<I>,
1105 assumptions: &Assumptions<I>,
1106 cx: I,
1107) -> impl Iterator<Item = Region<I>> {
1108 assumptions
1109 .inverse_region_outlives
1110 .reachable_from(r)
1111 .into_iter()
1112 .chain([r, Region::new_static(cx)])
1115}
1116
1117pub fn regions_outlived_by_placeholder<I: Interner>(
1120 t: I::Ty,
1121 assumptions: &Assumptions<I>,
1122 cx: I,
1123) -> impl Iterator<Item = Region<I>> {
1124 match t.kind() {
1125 TyKind::Placeholder(..) | TyKind::Param(..) => (),
1126 _ => {
::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:?}"),
1127 }
1128
1129 assumptions.type_outlives.iter().flat_map(move |binder| match binder.no_bound_vars() {
1130 Some(OutlivesClause(ty, r)) => (ty == t).then_some(r),
1131 None => Some(Region::new_static(cx)),
1132 })
1133}
1134
1135pub struct MakeHigherRankederer<'a, I: Interner, Infcx: InferCtxtLike<Interner = I>> {
1136 cx: &'a Infcx,
1137 preexisting_var_count: usize,
1138 regions: IndexMap<Region<I>, BoundRegion<I>>,
1139 universe: UniverseIndex,
1140 current_index: DebruijnIndex,
1141}
1142
1143impl<'a, I: Interner, Infcx: InferCtxtLike<Interner = I>> MakeHigherRankederer<'a, I, Infcx> {
1144 fn existing_var_count(&self) -> usize {
1145 self.preexisting_var_count + self.regions.len()
1146 }
1147}
1148
1149impl<'a, I: Interner, Infcx: InferCtxtLike<Interner = I>> TypeFolder<I>
1150 for MakeHigherRankederer<'a, I, Infcx>
1151{
1152 fn cx(&self) -> I {
1153 self.cx.cx()
1154 }
1155
1156 fn fold_region(&mut self, r: Region<I>) -> Region<I> {
1157 let cx = self.cx();
1158
1159 match r.kind() {
1160 RegionKind::RePlaceholder(p) if p.universe == self.universe => {
1161 let existing_var_count = self.existing_var_count();
1162 let mapped_var = self.regions.entry(r).or_insert(BoundRegion {
1163 var: BoundVar::from_usize(existing_var_count),
1164 kind: p.bound.kind,
1165 });
1166 Region::new_bound(cx, self.current_index, *mapped_var)
1167 }
1168 RegionKind::ReVar(inf) => {
1169 let u = self.cx.universe_of_region(inf).unwrap();
1170 if u == self.universe {
1171 let existing_var_count = self.existing_var_count();
1172 let mapped_var = self.regions.entry(r).or_insert(BoundRegion {
1173 var: BoundVar::from_usize(existing_var_count),
1174 kind: BoundRegionKind::Anon,
1175 });
1176 Region::new_bound(cx, self.current_index, *mapped_var)
1177 } else {
1178 r
1179 }
1180 }
1181 _ => r,
1182 }
1183 }
1184
1185 fn fold_binder<T: TypeFoldable<I>>(&mut self, b: Binder<I, T>) -> Binder<I, T> {
1186 self.current_index.shift_in(1);
1187 let b = b.super_fold_with(self);
1188 self.current_index.shift_out(1);
1189 b
1190 }
1191}
1192
1193{}
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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(1197u32),
::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:1231",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(1231u32),
::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/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:1197",
"rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
::tracing_core::__macro_support::Option::Some(1197u32),
::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)]
1198fn alias_outlives_candidates_from_assumptions<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
1199 infcx: &Infcx,
1200 bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
1201 assumptions: &Assumptions<I>,
1202) -> Or<I> {
1203 let mut candidates = Vec::new();
1204
1205 let prev_universe = infcx.universe();
1206
1207 infcx.enter_forall_with_empty_assumptions(bound_outlives, |(alias, r)| {
1208 for bound_type_outlives in assumptions.type_outlives.iter() {
1209 let OutlivesClause(alias2, r2) =
1210 infcx.instantiate_binder_with_infer(*bound_type_outlives);
1211
1212 let mut relation = HigherRankedAliasMatcher {
1213 infcx,
1214 region_constraints: vec![LeafRegionConstraint::RegionOutlives(r2, r, ())],
1215 };
1216
1217 if let Ok(_) = relation.relate(
1220 alias.to_ty(infcx.cx(), IsRigid::No),
1221 set_aliases_to_non_rigid(infcx.cx(), alias2).skip_norm_wip(),
1222 ) {
1223 candidates.push(And::new(relation.region_constraints));
1224 }
1225 }
1226 });
1227
1228 let constraint = RegionConstraint::new_from_or(Or::new(candidates));
1229
1230 let largest_universe = infcx.universe();
1231 debug!(?prev_universe, ?largest_universe);
1232
1233 let canonical_constraint = ((prev_universe.index() + 1)..=largest_universe.index())
1234 .map(|u| UniverseIndex::from_usize(u))
1235 .rev()
1236 .fold(constraint, |constraint, u| {
1237 eagerly_handle_placeholders_in_universe(infcx, constraint, u)
1238 });
1239
1240 canonical_constraint.splatted_and_constraints()
1241}
1242
1243struct HigherRankedAliasMatcher<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> {
1244 infcx: &'a Infcx,
1245 region_constraints: Vec<LeafRegionConstraint<I>>,
1246}
1247
1248impl<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeRelation<I>
1249 for HigherRankedAliasMatcher<'a, Infcx, I>
1250{
1251 fn cx(&self) -> I {
1252 self.infcx.cx()
1253 }
1254
1255 fn relate_ty_args(
1256 &mut self,
1257 a_ty: I::Ty,
1258 _b_ty: I::Ty,
1259 _ty_def_id: I::DefId,
1260 a_args: I::GenericArgs,
1261 b_args: I::GenericArgs,
1262 _mk: impl FnOnce(I::GenericArgs) -> I::Ty,
1263 ) -> RelateResult<I, I::Ty> {
1264 rustc_type_ir::relate::relate_args_invariantly(self, a_args, b_args)?;
1265 Ok(a_ty)
1266 }
1267
1268 fn relate_with_variance<T: Relate<I>>(
1269 &mut self,
1270 _variance: Variance,
1271 _info: VarianceDiagInfo<I>,
1272 a: T,
1273 b: T,
1274 ) -> RelateResult<I, T> {
1275 self.relate(a, b)
1278 }
1279
1280 fn tys(&mut self, a: I::Ty, b: I::Ty) -> RelateResult<I, I::Ty> {
1281 rustc_type_ir::relate::structurally_relate_tys(self, a, b)
1282 }
1283
1284 fn regions(&mut self, a: Region<I>, b: Region<I>) -> RelateResult<I, Region<I>> {
1285 if a != b {
1286 self.region_constraints.push(LeafRegionConstraint::RegionOutlives(a, b, ()));
1287 self.region_constraints.push(LeafRegionConstraint::RegionOutlives(b, a, ()));
1288 }
1289 Ok(a)
1290 }
1291
1292 fn consts(&mut self, a: Const<I>, b: Const<I>) -> RelateResult<I, Const<I>> {
1293 rustc_type_ir::relate::structurally_relate_consts(self, a, b)
1294 }
1295
1296 fn binders<T>(&mut self, a: Binder<I, T>, b: Binder<I, T>) -> RelateResult<I, Binder<I, T>>
1297 where
1298 T: Relate<I>,
1299 {
1300 self.infcx.enter_forall_with_empty_assumptions(a, |a| {
1301 let u = self.infcx.universe();
1302 self.infcx.insert_placeholder_assumptions(u, Assumptions::empty());
1303 let b = self.infcx.instantiate_binder_with_infer(b);
1304 self.relate(a, b)
1305 })?;
1306
1307 self.infcx.enter_forall_with_empty_assumptions(b, |b| {
1308 let u = self.infcx.universe();
1309 self.infcx.insert_placeholder_assumptions(u, Assumptions::empty());
1310 let a = self.infcx.instantiate_binder_with_infer(a);
1311 self.relate(a, b)
1312 })?;
1313
1314 Ok(a)
1315 }
1316}