Skip to main content

rustc_type_ir/
region_constraint.rs

1//! The bulk of the logic for implementing `-Zassumptions-on-binders`
2
3use 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// Workaround for TransitiveRelation being in rustc_data_structures which isn't accessible on stable
15#[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    /// Known `'a: 'b` assumptions, stored as an edge from the outliving region to the
69    /// outlived one, i.e. an edge `('a, 'b)` means `'a: 'b`. Constructors expect a relation
70    /// with this direction, see [`regions_outlived_by`] and [`regions_outliving`] for how it
71    /// is consumed.
72    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    /// Builds assumptions from `clauses`, elaborating them and keeping the outlives ones.
95    ///
96    /// Callers hand us their clauses straight from the environment, so we have to elaborate
97    /// here to get at the implied outlives bounds:
98    /// - a `Ty: 'a` clause tells us that every region component of `Ty` outlives `'a`, e.g.
99    ///   `&'b u8: 'a` implies `'b: 'a`. Without it we'd fail to prove `'b: 'a` when leaving
100    ///   the binder these assumptions belong to.
101    /// - it also gives us the components as type outlives, e.g. `Vec<T>: 'a` implies `T: 'a`,
102    ///   which we need for placeholder and alias outlives.
103    /// - trait clauses imply their supertraits, so `T: Bound<'a>` where `trait Bound<'c>: 'c`
104    ///   gives us `T: 'a`. This is why we take clauses rather than just the outlives ones:
105    ///   filtering down to outlives before elaborating would throw those away.
106    ///
107    /// Only the clauses whose max universe is exactly `universe` are kept, which is what the
108    /// solver wants when computing the assumptions of a single binder. This happens after
109    /// elaboration on purpose, so a clause whose regions live in more than one universe still
110    /// contributes its implied bounds to each of them: `(&'b u8, &'c u8): 'a` gives us
111    /// `'c: 'a` in `'c`s universe even though the clause itself is in `'b`s.
112    ///
113    /// Use [`Assumptions::new_unelaborated`] when the caller needs the assumptions to be
114    /// exactly the clauses it passed in.
115    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                // The type outlives assumptions are kept around as they are required for
132                // proving placeholder and alias outlives.
133                ClauseKind::TypeOutlives(_) => {
134                    type_outlives.push(clause.as_type_outlives_clause().unwrap());
135                }
136                ClauseKind::RegionOutlives(OutlivesClause(r1, r2)) => {
137                    // `elaborate` drops the components which are bound inside of the type and
138                    // bails on `for<'a> Ty: 'a`, so both regions here are free even though the
139                    // clause itself may still be under a binder.
140                    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                // Anything else can't be used as an outlives assumption.
144                _ => (),
145            }
146        }
147
148        Self::new_unelaborated(type_outlives, region_outlives_builder.freeze())
149    }
150
151    /// Builds assumptions from exactly the given clauses, see [`Assumptions::new`] for when
152    /// the clauses should get elaborated instead.
153    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/// The span stored in a [`RegionConstraint`] and friends.
172///
173/// Constraints are created with spans during type checking, but are also stored
174/// without any span, e.g. in query responses, in which case [`NoSpan`] is used.
175/// This trait exists so that code which is generic over the span only needs a
176/// single bound instead of repeating all of the supertrait bounds.
177pub trait ConstraintSpan: Clone + std::fmt::Debug + Eq + std::hash::Hash {}
178
179/// Placeholder for constraints which do not carry a span, see [`ConstraintSpan`].
180#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for NoSpan {
}
#[automatically_derived]impl ::core::clone::Clone for NoSpan {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for NoSpan { }Copy, #[automatically_derived]impl ::core::fmt::Debug for NoSpan {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "NoSpan")
    }
}Debug, #[automatically_derived]impl ::core::default::Default for NoSpan {
    #[inline]
    fn default() -> Self { NoSpan {} }
}Default, #[automatically_derived]impl ::core::hash::Hash for NoSpan {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {}
}Hash, #[automatically_derived]impl ::core::marker::StructuralPartialEq for NoSpan {
}
#[automatically_derived]impl ::core::cmp::PartialEq for NoSpan {
    #[inline]
    fn eq(&self, other: &Self) -> bool { true }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for NoSpan { }Eq)]
181#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for NoSpan {
            #[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 { NoSpan => {} }
            }
        }
    };StableHash_NoContext))]
182pub struct NoSpan;
183
184impl ConstraintSpan for NoSpan {}
185
186#[cfg(feature = "nightly")]
187impl ConstraintSpan for rustc_span::Span {}
188
189#[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)]
190#[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)]
191#[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) {
                match *self {
                    LeafRegionConstraint::Ambiguity(ref __binding_0) =>
                        0u8.stable_hash(__hcx, __hasher),
                    LeafRegionConstraint::RegionOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) =>
                        1u8.stable_hash(__hcx, __hasher),
                    LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __binding_0,
                        ref __binding_1) => 2u8.stable_hash(__hcx, __hasher),
                    LeafRegionConstraint::PlaceholderTyOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) =>
                        3u8.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))]
192pub enum LeafRegionConstraint<I: Interner, S: Clone = NoSpan> {
193    Ambiguity(S),
194    RegionOutlives(Region<I>, Region<I>, S),
195    /// Requirement that a (potentially higher ranked) alias outlives some (potentially higher ranked)
196    /// region due to an assumption in the environment. This cannot be satisfied via component outlives
197    /// or item bounds.
198    ///
199    /// We cannot eagerly look at assumptions as we are usually working with an incomplete set of assumptions
200    /// and there may wind up being assumptions we can use to prove this when we're in a smaller universe.
201    ///
202    /// We eagerly destructure alias outlives requirements into region outlives requirements corresponding to
203    /// component outlives & item bound outlives rules, leaving only param env candidates.
204    AliasTyOutlivesViaEnv(Binder<I, (AliasTy<I>, Region<I>)>, S),
205    /// This is an `I::Ty` for two reasons:
206    /// 1. We need the type visitable impl to be able to `visit_ty` on this so canonicalization
207    ///    knows about the placeholder
208    /// 2. When exiting the trait solver there may be placeholder outlives corresponding to params
209    ///    from the root universe. These need to be changed from a `Placeholder` to the original
210    ///    `Param`.
211    ///
212    /// We cannot eagerly look at assumptions as we are usually working with an incomplete set of assumptions
213    /// and there may wind up being assumptions we can use to prove this when we're in a smaller universe.
214    PlaceholderTyOutlives(I::Ty, Region<I>, S),
215}
216
217impl<I: Interner, S: Clone> std::fmt::Debug for LeafRegionConstraint<I, S> {
218    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
219        match self {
220            Self::Ambiguity(_span) => f.write_str("ambiguity"),
221            Self::RegionOutlives(r1, r2, _span) => {
222                r1.fmt(f)?;
223                f.write_str(": ")?;
224                r2.fmt(f)
225            }
226            Self::AliasTyOutlivesViaEnv(bound_outlives, _span) => {
227                f.write_str("for<")?;
228                bound_outlives.bound_vars().fmt(f)?;
229                f.write_str(">")?;
230                let (ty, r) = bound_outlives.skip_binder();
231                ty.fmt(f)?;
232                f.write_str(": ")?;
233                r.fmt(f)
234            }
235            Self::PlaceholderTyOutlives(ty, r, _span) => {
236                ty.fmt(f)?;
237                f.write_str(": ")?;
238                r.fmt(f)
239            }
240        }
241    }
242}
243
244impl<I: Interner> LeafRegionConstraint<I> {
245    pub fn with_span<S: ConstraintSpan>(self, span: S) -> LeafRegionConstraint<I, S> {
246        use LeafRegionConstraint::*;
247
248        match self {
249            Ambiguity(NoSpan) => Ambiguity(span),
250            RegionOutlives(r1, r2, NoSpan) => RegionOutlives(r1, r2, span),
251            AliasTyOutlivesViaEnv(bound_outlives, NoSpan) => {
252                AliasTyOutlivesViaEnv(bound_outlives, span)
253            }
254            PlaceholderTyOutlives(ty, r, NoSpan) => PlaceholderTyOutlives(ty, r, span),
255        }
256    }
257}
258
259impl<I: Interner, S: ConstraintSpan> LeafRegionConstraint<I, S> {
260    pub fn without_span(self) -> LeafRegionConstraint<I> {
261        use LeafRegionConstraint::*;
262
263        match self {
264            Ambiguity(_) => Ambiguity(NoSpan),
265            RegionOutlives(r1, r2, _) => RegionOutlives(r1, r2, NoSpan),
266            AliasTyOutlivesViaEnv(bound_outlives, _) => {
267                AliasTyOutlivesViaEnv(bound_outlives, NoSpan)
268            }
269            PlaceholderTyOutlives(ty, r, _) => PlaceholderTyOutlives(ty, r, NoSpan),
270        }
271    }
272
273    pub fn span(&self) -> S {
274        use LeafRegionConstraint::*;
275
276        let (Ambiguity(s)
277        | RegionOutlives(_, _, s)
278        | AliasTyOutlivesViaEnv(_, s)
279        | PlaceholderTyOutlives(_, _, s)) = self;
280        s.clone()
281    }
282}
283
284#[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)]
285#[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)]
286#[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))]
287/// An OR of AND of LEAF constraints. Always in "canonical form" meaning:
288/// - No AND is a superset of another AND
289/// - All ANDs are in canonical form
290/// - If any AND is empty, i.e. trivially true, it is the only AND
291pub struct Or<I: Interner, S: Clone + std::fmt::Debug = NoSpan>(pub SmallVec<[And<I, S>; 1]>);
292impl<I: Interner> Or<I> {
293    pub fn with_spans<S: ConstraintSpan>(self, span: S) -> Or<I, S> {
294        Or(self.0.into_iter().map(|and| and.with_spans(span.clone())).collect())
295    }
296}
297enum AndRelation {
298    /// example:
299    /// existed: OR(AND('a: 'b))
300    /// new: AND('a: 'b, 'b: 'c)
301    Subset,
302
303    /// example:
304    /// existed: OR(AND('a: 'b, 'b: 'c))
305    /// new: AND('a: 'b)
306    Superset,
307
308    /// example:
309    /// existed: OR(AND('a: 'b))
310    /// new: AND('a: 'c)
311    Incomparable,
312}
313
314impl<I: Interner, S: ConstraintSpan> Or<I, S> {
315    pub fn new_true() -> Self {
316        Self(SmallVec::from_buf([And::new_true()]))
317    }
318
319    pub fn is_true(&self) -> bool {
320        // OR([AND([])])
321        if let [and] = &*self.0
322            && and.0.is_empty()
323        {
324            true
325        } else {
326            false
327        }
328    }
329
330    pub fn new_false() -> Self {
331        Self(SmallVec::new())
332    }
333
334    pub fn is_false(&self) -> bool {
335        // OR([])
336        self.0.is_empty()
337    }
338
339    pub fn new(i: impl IntoIterator<Item = And<I, S>>) -> Self {
340        let mut new_ands: SmallVec<[And<I, S>; _]> = SmallVec::new();
341
342        for and in i {
343            // An empty AND is trivially true, which makes the whole OR true no matter what the
344            // other candidates are. `And::new` discards leaf constraints which are trivially
345            // true, so this is how e.g. a reflexive `'a: 'a` candidate discharges an OR.
346            if and.0.is_empty() {
347                return Self::new_true();
348            }
349
350            // Currently, this is a more general canonical form:
351            // comparing the existing `new_ands` with a new `and`,
352            // we always keep the and with fewer constraints in new_ands.
353            // In particular, the equivalent case is also classified under the subset branch, and no push operation is performed.
354            let mut is_subset_new = false;
355            new_ands.retain(|c| {
356                let relation = c.compare_and_relation(&and);
357                match relation {
358                    AndRelation::Superset => false,
359                    AndRelation::Subset => {
360                        is_subset_new = true;
361                        return true;
362                    }
363                    AndRelation::Incomparable => true,
364                }
365            });
366            if is_subset_new {
367                continue;
368            }
369            new_ands.push(and);
370        }
371
372        Self(new_ands)
373    }
374
375    pub fn new_ambig(s: S) -> Self {
376        Or::new_leaf(LeafRegionConstraint::Ambiguity(s))
377    }
378
379    pub fn new_leaf(l: LeafRegionConstraint<I, S>) -> Self {
380        Or::new([And::new([l])])
381    }
382
383    pub fn build_and(a: Or<I, S>, b: Or<I, S>) -> Self {
384        // FIXME(-Zassumptions-on-binders): probably bad for perf, doing a lot of reallocating
385        // and whatnot here :3
386
387        // Important: keeps `ands` empty if either `b_and` or `a_and` is empty
388        let mut ands = Vec::new();
389        for b_and in b.0 {
390            for a_and in a.0.clone().into_iter() {
391                ands.push(And::new(a_and.0.into_iter().chain(b_and.0.clone())))
392            }
393        }
394
395        Or::new(ands)
396    }
397
398    pub fn build_or(a: Or<I, S>, b: Or<I, S>) -> Self {
399        Or::new(a.0.into_iter().chain(b.0))
400    }
401
402    pub fn without_spans(self) -> Or<I> {
403        Or(self.0.into_iter().map(|and| and.without_spans()).collect())
404    }
405}
406
407impl<I: Interner, S: Clone + std::fmt::Debug> std::fmt::Debug for Or<I, S> {
408    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
409        if self.0.is_empty() {
410            f.write_str("false")
411        } else if let [single] = &*self.0 {
412            single.fmt(f)
413        } else {
414            f.write_str("or ")?;
415            f.debug_set().entries(&self.0).finish()
416        }
417    }
418}
419
420#[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)]
421#[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)]
422#[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))]
423/// An AND of leaf constraints. Always in "canonical form", meaning:
424/// - No leaf constraints are present twice in this AND
425/// - No leaf constraint is trivially true, i.e. a reflexive `'a: 'a`
426pub struct And<I: Interner, S: Clone + std::fmt::Debug = NoSpan>(
427    pub SmallVec<[LeafRegionConstraint<I, S>; 1]>,
428);
429impl<I: Interner> And<I> {
430    pub fn with_spans<S: ConstraintSpan>(self, span: S) -> And<I, S> {
431        And(self.0.into_iter().map(|leaf| leaf.with_span(span.clone())).collect())
432    }
433}
434impl<I: Interner, S: ConstraintSpan> And<I, S> {
435    pub fn new_true() -> Self {
436        Self(SmallVec::new())
437    }
438
439    pub fn new(i: impl IntoIterator<Item = LeafRegionConstraint<I, S>>) -> Self {
440        let mut seen = IndexSet::new();
441        And(i
442            .into_iter()
443            .filter(|leaf| {
444                // Outlives is reflexive so a `'a: 'a` leaf is always true and carries no
445                // information. Dropping it here keeps the rest of the code from having to special
446                // case it, and is what lets an OR with a reflexive candidate be recognized as true.
447                if let LeafRegionConstraint::RegionOutlives(r1, r2, _) = leaf
448                    && r1 == r2
449                {
450                    return false;
451                }
452
453                if seen.contains(&leaf.clone().without_span()) {
454                    false
455                } else {
456                    seen.insert(leaf.clone().without_span());
457                    true
458                }
459            })
460            .collect())
461    }
462
463    fn compare_and_relation(&self, other: &And<I, S>) -> AndRelation {
464        let this = self.clone().0;
465        let other = other.clone().0;
466
467        // if newcome is superset
468        // In particular, the equivalent case is also classified under the subset branch
469        if this
470            .iter()
471            .all(|c1| other.iter().any(|c2| c1.clone().without_span() == c2.clone().without_span()))
472        {
473            return AndRelation::Subset;
474        }
475
476        // if newcome is subset
477        if other
478            .iter()
479            .all(|c2| this.iter().any(|c1| c1.clone().without_span() == c2.clone().without_span()))
480        {
481            return AndRelation::Superset;
482        }
483        return AndRelation::Incomparable;
484    }
485
486    pub fn without_spans(self) -> And<I> {
487        And(self.0.into_iter().map(|leaf| leaf.without_span()).collect())
488    }
489}
490
491impl<I: Interner, S: Clone + std::fmt::Debug> std::fmt::Debug for And<I, S> {
492    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
493        if self.0.is_empty() {
494            f.write_str("true")
495        } else if let [single] = &*self.0 {
496            single.fmt(f)
497        } else {
498            f.write_str("and ")?;
499            f.debug_set().entries(&self.0).finish()
500        }
501    }
502}
503
504#[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)]
505#[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)]
506#[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))]
507/// An `And` and an `Or` constraint both in canonical forms, with two additional constraints:
508/// - If the `or_constraint` is false then the `and_constraint` is empty
509/// - The `or_constraint` does not have any constraints present in all of its inner `And`s
510///    - i.e. `OR ( AND ('a: 'b, 'b: 'c), AND ('a: 'b, 'b: 'd))` is not a thing
511/// - The OR constraint is in canonical form
512/// - The AND constraint is in canonical form
513///
514/// This should be thought of as an AND consisting of a set of LEAF constraints as well
515/// as a single OR constraint.
516pub struct RegionConstraint<I: Interner, S: Clone + std::fmt::Debug = NoSpan> {
517    pub and_constraint: And<I, S>,
518    pub or_constraint: Or<I, S>,
519}
520
521impl<I: Interner> RegionConstraint<I> {
522    pub fn with_spans<S: ConstraintSpan>(self, span: S) -> RegionConstraint<I, S> {
523        RegionConstraint {
524            and_constraint: self.and_constraint.with_spans(span.clone()),
525            or_constraint: self.or_constraint.with_spans(span.clone()),
526        }
527    }
528}
529impl<I: Interner, S: ConstraintSpan> RegionConstraint<I, S> {
530    pub fn new_from_or(or: Or<I, S>) -> Self {
531        let Some(fst) = or.0.get(0).clone() else {
532            return RegionConstraint::new_false();
533        };
534        let mut and_constraint = fst.0.to_vec();
535
536        for and in or.0.split_first().unwrap().1 {
537            and_constraint.retain(|c| {
538                and.0.iter().any(|c2| c.clone().without_span() == c2.clone().without_span())
539            });
540        }
541        let and_constraint = And::new(and_constraint);
542
543        let or_constraint = Or::new(or.0.into_iter().map(|and| {
544            And::new(and.0.into_iter().filter(|c| {
545                and_constraint
546                    .0
547                    .iter()
548                    .all(|s_c| c.clone().without_span() != s_c.clone().without_span())
549            }))
550        }));
551
552        Self {
553            and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
554            or_constraint,
555        }
556    }
557
558    pub fn splatted_and_constraints(&self) -> Or<I, S> {
559        Or::new(self.or_constraint.0.iter().map(|and| {
560            And::new(and.0.iter().cloned().chain(self.and_constraint.0.iter().cloned()))
561        }))
562    }
563
564    pub fn build_and(a: RegionConstraint<I, S>, b: RegionConstraint<I, S>) -> Self {
565        let and_constraint = And::new(a.and_constraint.0.into_iter().chain(b.and_constraint.0));
566        let or_constraint = Or::build_and(a.or_constraint, b.or_constraint);
567
568        Self {
569            and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
570            or_constraint,
571        }
572    }
573
574    pub fn build_or(a: RegionConstraint<I, S>, b: RegionConstraint<I, S>) -> Self {
575        Self::new_from_or(Or::build_or(a.splatted_and_constraints(), b.splatted_and_constraints()))
576    }
577
578    pub fn new_true() -> Self {
579        Self { and_constraint: And::new_true(), or_constraint: Or::new_true() }
580    }
581
582    pub fn is_true(&self) -> bool {
583        self.and_constraint.0.is_empty() && self.or_constraint.is_true()
584    }
585
586    pub fn new_false() -> Self {
587        Self { and_constraint: And::new_true(), or_constraint: Or::new_false() }
588    }
589
590    pub fn is_false(&self) -> bool {
591        self.or_constraint.is_false()
592    }
593
594    pub fn new_ambig(span: S) -> Self {
595        Self {
596            and_constraint: And::new([LeafRegionConstraint::Ambiguity(span)]),
597            or_constraint: Or::new_true(),
598        }
599    }
600
601    pub fn is_ambig(&self) -> bool {
602        if let [c] = &*self.and_constraint.0
603            && c.is_ambig()
604            && self.or_constraint.is_true()
605        {
606            true
607        } else {
608            false
609        }
610    }
611
612    pub fn without_spans(self) -> RegionConstraint<I> {
613        RegionConstraint {
614            and_constraint: self.and_constraint.without_spans(),
615            or_constraint: self.or_constraint.without_spans(),
616        }
617    }
618
619    pub fn new_leaf(l: LeafRegionConstraint<I, S>) -> Self {
620        RegionConstraint { and_constraint: And::new([l]), or_constraint: Or::new_true() }
621    }
622}
623
624impl<I: Interner, S: Clone + std::fmt::Debug> std::fmt::Debug for RegionConstraint<I, S> {
625    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
626        if let [single_or] = &*self.or_constraint.0
627            && single_or.0.is_empty()
628        {
629            self.and_constraint.fmt(f)
630        } else if self.and_constraint.0.is_empty() {
631            self.or_constraint.fmt(f)
632        } else {
633            f.write_str("and ")?;
634            f.debug_set().entries(&self.and_constraint.0).entry(&self.or_constraint).finish()
635        }
636    }
637}
638
639impl<I: Interner, S: Clone + std::fmt::Debug> LeafRegionConstraint<I, S> {
640    pub fn is_ambig(&self) -> bool {
641        #[allow(non_exhaustive_omitted_patterns)] match self {
    Self::Ambiguity(_) => true,
    _ => false,
}matches!(self, Self::Ambiguity(_))
642    }
643}
644
645/// Takes any constraints involving placeholders from the current universe and eagerly checks them.
646/// This can be done a few ways:
647/// - There's an assumption on the binder introducing the placeholder which means the constraint is satisfied (true)
648/// - There's assumptions on the binder introducing the placeholder which allow us to rewrite the constraint in
649///    terms of lower universe variables. For example given `for<'a> where('b: 'a) { prove(T: '!a_u1) }` we can
650///    convert this constraint to `T: 'b` which no longer references anything from `u1`.
651/// - There are no relevant assumptions so we can neither rewrite the constraint nor consider it satisfied (false)
652/// - We failed to compute the full set of assumptions when entering the binder corresponding to `u`. (ambiguity)
653///
654/// After handling all of the region constraints in `u` we then evaluate the entire constraint as much as possible,
655/// propagating true/false/ambiguity as close to the root of the constraint as we can. The returned constraint should
656/// be checked for whether it is true/false/ambiguous as that should affect the result of whatever operation required
657/// entering the binder corresponding to `u`.
658{}
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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(658u32),
                                ::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 constraint =
                            infcx.deeply_resolve_via_unification_table(constraint);
                        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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:658",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(658u32),
                        ::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)]
659pub fn eagerly_handle_placeholders_in_universe<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
660    infcx: &Infcx,
661    constraint: RegionConstraint<I>,
662    u: UniverseIndex,
663) -> RegionConstraint<I> {
664    assert!(u > UniverseIndex::ROOT, "eagerly handle placeholders called for root universe");
665
666    let constraint = infcx.deeply_resolve_via_unification_table(constraint);
667    let assumptions = infcx.get_placeholder_assumptions(u);
668
669    // 1. rewrite type outlives constraints involving things from `u` into either region constraints
670    //     involving things from `u` or type outlives constraints not involving things from `u`
671    //
672    //    IOW, we only want to encounter things from `u` as part of region out lives constraints.
673    let constraint = rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling(
674        infcx,
675        constraint,
676        u,
677        &assumptions,
678    );
679
680    // 2. compute transitive region outlives and get a new set of region outlives constraints by
681    //     looking for every region which either a placeholder_u flows into it, or it flows into
682    //     the placeholder.
683    let constraint = compute_new_region_constraints(infcx, constraint, u);
684
685    // 3. rewrite region outlives constraints (potentially to false/true)
686    let constraint =
687        pull_region_outlives_constraints_out_of_universe(infcx, constraint, u, &assumptions);
688
689    constraint
690}
691
692/// Filter our region constraints to not include constraints between region variables from `u` and
693/// other regions as those are always satisfied. This requires some care to handle correctly for example:
694/// `'!a_u1: '?x_u1: '!b_u1` should result in us requiring `'!a_u1: '!b_u1` rather than dropping the two
695/// constraints entirely.
696///
697/// The only constraints involving things from `u` should be region outlives constraints at this point. Type
698/// outlives constraints should have been handled already either by destructuring into region outlives or by
699/// being rewritten in terms of smaller universe variables.
700{}
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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(700u32),
                                ::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(NoSpan) | PlaceholderTyOutlives(..) |
                                                AliasTyOutlivesViaEnv(..) => {
                                                constraints.push(c.clone())
                                            }
                                            RegionOutlives(r1, r2, NoSpan) => {
                                                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::unreachable_default_msg(),
                                            };
                                    if is_placeholder_like(r) && is_placeholder_like(ub) {
                                        constraints.push(RegionOutlives(ub, r, NoSpan));
                                    }
                                }
                            }
                            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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:700",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(700u32),
                        ::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)]
701fn compute_new_region_constraints<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
702    infcx: &Infcx,
703    constraint: RegionConstraint<I>,
704    u: UniverseIndex,
705) -> RegionConstraint<I> {
706    use LeafRegionConstraint::*;
707
708    let extend_from_and = |builder: &mut TransitiveRelationBuilder<_>,
709                           regions: &mut IndexSet<_>,
710                           constraints: &mut Vec<_>,
711                           and: &And<I>| {
712        for c in &and.0 {
713            match c {
714                Ambiguity(NoSpan) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
715                    constraints.push(c.clone())
716                }
717                RegionOutlives(r1, r2, NoSpan) => {
718                    regions.insert(*r1);
719                    regions.insert(*r2);
720                    builder.add(*r2, *r1);
721                }
722            }
723        }
724    };
725
726    let mut base_region_flows_builder = TransitiveRelationBuilder::default();
727    let mut base_regions = IndexSet::new();
728    let mut base_constraints = Vec::new();
729    extend_from_and(
730        &mut base_region_flows_builder,
731        &mut base_regions,
732        &mut base_constraints,
733        &constraint.and_constraint,
734    );
735
736    let mut new_ands = Vec::new();
737    for and in &constraint.or_constraint.0 {
738        let mut region_flows_builder = base_region_flows_builder.clone();
739        let mut regions = base_regions.clone();
740        let mut constraints = base_constraints.clone();
741        extend_from_and(&mut region_flows_builder, &mut regions, &mut constraints, and);
742
743        let region_flow = region_flows_builder.freeze();
744        for r in regions.into_iter() {
745            for ub in region_flow.reachable_from(r) {
746                // we want to retain any region constraints between two "placeholder-likes" where for our
747                // purposes a placeholder-like is either a placeholder or variable in a lower universe
748                let is_placeholder_like = |r: Region<I>| match r.kind() {
749                    RegionKind::ReLateParam(..)
750                    | RegionKind::ReEarlyParam(..)
751                    | RegionKind::RePlaceholder(..)
752                    | RegionKind::ReStatic => true,
753                    RegionKind::ReVar(..) => max_universe(infcx, r) < u,
754                    RegionKind::ReError(..) => false,
755                    RegionKind::ReErased | RegionKind::ReBound(..) => unreachable!(),
756                };
757
758                if is_placeholder_like(r) && is_placeholder_like(ub) {
759                    constraints.push(RegionOutlives(ub, r, NoSpan));
760                }
761            }
762        }
763
764        new_ands.push(Or::new([And::new(constraints)]))
765    }
766
767    // FIXME(-Zassumptions-on-binders): probably bad for perf!
768    RegionConstraint::new_from_or(
769        new_ands.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c)),
770    )
771}
772
773/// Handles converting region outlives constraints involving placeholders from `u` into OR constraints
774/// involving regions from smaller universes with known relationships to the placeholder. For example:
775/// ```ignore (not rust)
776/// for<'a, 'b> where(
777///     'c: 'b, 'd: 'b,
778///     'a: 'e, 'a: 'f,
779/// ) {
780///     'a_u1: 'b_u1
781/// }
782/// ```
783/// will get converted to:
784/// ```ignore (not rust)
785/// OR(
786///     'e: 'c,
787///     'e: 'd,
788///     'f: 'c,
789///     'f: 'd,
790/// )
791/// ```
792/// if we are handling constraints in `u1`.
793{}
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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(793u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("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(NoSpan) | 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, NoSpan) => {
                                                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, NoSpan));
                                                    }
                                                }
                                                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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:793",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(793u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("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)]
794fn pull_region_outlives_constraints_out_of_universe<
795    Infcx: InferCtxtLike<Interner = I>,
796    I: Interner,
797>(
798    infcx: &Infcx,
799    constraint: RegionConstraint<I>,
800    u: UniverseIndex,
801    assumptions: &Assumptions<I>,
802) -> RegionConstraint<I> {
803    assert!(max_universe(infcx, constraint.clone()) <= u);
804
805    // FIXME(-Zassumptions-on-binders): we don't lower universes of region variables when exiting `u`
806    // this seems dubious/potentially wrong? we can't just blindly do this though as if we had something
807    // like `!T_u -> ?x_u -> !U_u` then lowering `?x` to `u-1` when exiting `u` would be wrong.
808    //
809    // I'm not even sure this would be necessary given we filter out region constraints involving regions#
810    // from the current universe and only retain those between placeholders.
811
812    use LeafRegionConstraint::*;
813
814    let pull_and = |and: And<I>| {
815        let mut pulled_constraints = Vec::new();
816        for c in and.0 {
817            match c {
818                Ambiguity(NoSpan) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
819                    assert!(max_universe(infcx, c.clone()) < u);
820                    pulled_constraints.push(Or::new_leaf(c.clone()));
821                }
822                RegionOutlives(region_1, region_2, NoSpan) => {
823                    let region_1_u = max_universe(infcx, region_1);
824                    let region_2_u = max_universe(infcx, region_2);
825
826                    if region_1_u != u && region_2_u != u {
827                        pulled_constraints.push(Or::new_leaf(c));
828                        continue;
829                    }
830
831                    // The constraint may already be entailed by the assumptions of the binder we are
832                    // leaving, e.g. `for<'a, 'b> where 'b: 'a { 'b: 'a }`. There is nothing to lift into
833                    // a smaller universe in that case, and looking for lower universe candidates would
834                    // wrongly result in `Or([])` whenever the placeholders have no lower universe bounds.
835                    if regions_outlived_by(region_1, assumptions).any(|r| r == region_2) {
836                        continue;
837                    }
838
839                    let mut candidates = vec![];
840
841                    for ub in regions_outlived_by(region_1, assumptions)
842                        .filter(|r| max_universe(infcx, *r) < u)
843                    {
844                        // FIXME(-Zassumptions-on-binders): if `region_2` is in a smaller universe there'll be both
845                        // `'region_2` and `'static` as lower bounds which seems... unfortunate and may cause us to
846                        // add a bunch of duplicate `'ub: 'static` candidates the more binders we leave.
847                        for lb in regions_outliving(region_2, assumptions, infcx.cx())
848                            .filter(|r| max_universe(infcx, *r) < u)
849                        {
850                            // As long as any region outlived by `region_1` outlives any region region which
851                            // `region_2` outlives, we know that `region_1: region_2` holds. In other words,
852                            // there exists some set of 4 regions for which `'r1: 'i1` `'i1: 'i2` `'i2: 'r2`
853                            candidates.push(RegionOutlives(ub, lb, NoSpan));
854                        }
855                    }
856
857                    pulled_constraints.push(Or::new(candidates.into_iter().map(|c| And::new([c]))));
858                }
859            };
860        }
861
862        pulled_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
863    };
864
865    let and_constraint = pull_and(constraint.and_constraint);
866    let or_constraint = constraint
867        .or_constraint
868        .0
869        .into_iter()
870        .fold(Or::new_false(), |acc, c| Or::build_or(acc, pull_and(c)));
871    RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
872}
873
874#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::fmt::Debug for
    RootDestructuredConstraints<I, S> where I: Interner, S: ::core::fmt::Debug
    {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            RootDestructuredConstraints {
                constraint: ref __field_constraint,
                failing_leafs: ref __field_failing_leafs } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f,
                        "RootDestructuredConstraints");
                ::core::fmt::DebugStruct::field(&mut __builder, "constraint",
                    __field_constraint);
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "failing_leafs", __field_failing_leafs);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Debug; I: Interner, S)]
875pub struct RootDestructuredConstraints<I: Interner, S: Clone + std::fmt::Debug> {
876    pub constraint: RegionConstraint<I, S>,
877    pub failing_leafs: Vec<LeafRegionConstraint<I, S>>,
878}
879
880/// Converts type outlives constraints into region outlives constraints. This assumes the *complete* set of
881/// assumptions are known. This should not be called until the end of type checking.
882///
883/// The returned region constraint will not have *any* PlaceholderTyOutlives or AliasTyOutlivesViaEnv constraints.
884{}
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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(884u32),
                                ::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:
                                RootDestructuredConstraints<I, S> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        use LeafRegionConstraint::*;
                        let mut failing_leafs: Vec<LeafRegionConstraint<I, S>> =
                            ::alloc::vec::Vec::new();
                        let mut 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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:898",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(898u32),
                                                            ::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) => {
                                                let contents =
                                                    Or::new(regions_outlived_by_placeholder(*ty, assumptions,
                                                                infcx.cx()).map(move |assumption_r|
                                                                {
                                                                    And::new([RegionOutlives(assumption_r, *r, span.clone())])
                                                                }));
                                                if contents.is_false() { failing_leafs.push(c.clone()); }
                                                destructured_constraints.push(contents)
                                            }
                                            AliasTyOutlivesViaEnv(bound_outlives, span) => {
                                                let content =
                                                    alias_outlives_candidates_from_assumptions(infcx,
                                                            *bound_outlives, assumptions).with_spans(span.clone());
                                                if content.is_false() { failing_leafs.push(c.clone()); }
                                                destructured_constraints.push(content);
                                            }
                                        }
                                    }
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:931",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(931u32),
                                                            ::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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:935",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(935u32),
                                                            ::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)));
                        RootDestructuredConstraints {
                            constraint: RegionConstraint::new_from_or(Or::build_and(and_constraint,
                                    or_constraint)),
                            failing_leafs,
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:884",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(884u32),
                        ::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)]
885pub fn destructure_type_outlives_constraints_in_root<
886    Infcx: InferCtxtLike<Interner = I>,
887    I: Interner,
888    S: ConstraintSpan,
889>(
890    infcx: &Infcx,
891    constraint: RegionConstraint<I, S>,
892    assumptions: &Assumptions<I>,
893) -> RootDestructuredConstraints<I, S> {
894    use LeafRegionConstraint::*;
895
896    let mut failing_leafs: Vec<LeafRegionConstraint<I, S>> = vec![];
897    let mut destructure_and = |and: &And<I, S>| {
898        debug!("rewriting and: {:?}", and);
899        let mut destructured_constraints = Vec::new();
900        for c in &and.0 {
901            match c {
902                Ambiguity(_) | RegionOutlives(..) => {
903                    destructured_constraints.push(Or::new_leaf(c.clone()))
904                }
905                PlaceholderTyOutlives(ty, r, span) => {
906                    let contents =
907                        Or::new(regions_outlived_by_placeholder(*ty, assumptions, infcx.cx()).map(
908                            move |assumption_r| {
909                                And::new([RegionOutlives(assumption_r, *r, span.clone())])
910                            },
911                        ));
912                    if contents.is_false() {
913                        failing_leafs.push(c.clone());
914                    }
915                    destructured_constraints.push(contents)
916                }
917                AliasTyOutlivesViaEnv(bound_outlives, span) => {
918                    let content = alias_outlives_candidates_from_assumptions(
919                        infcx,
920                        *bound_outlives,
921                        assumptions,
922                    )
923                    .with_spans(span.clone());
924                    if content.is_false() {
925                        failing_leafs.push(c.clone());
926                    }
927                    destructured_constraints.push(content);
928                }
929            }
930        }
931        debug!(?destructured_constraints);
932        let merged_constraints = destructured_constraints
933            .into_iter()
934            .fold(Or::new_true(), |acc, c| Or::build_and(acc, c));
935        debug!(?merged_constraints);
936        merged_constraints
937    };
938
939    let and_constraint = destructure_and(&constraint.and_constraint);
940    let or_constraint = constraint
941        .or_constraint
942        .0
943        .into_iter()
944        .fold(Or::new_false(), |acc, c| Or::build_or(acc, destructure_and(&c)));
945
946    RootDestructuredConstraints {
947        constraint: RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint)),
948        failing_leafs,
949    }
950}
951
952/// Converts type outlives constraints into either region outlives constraints, or type outlives
953/// constraints which do not contain anything from `u`.
954///
955/// This only works off assumptions associated with the binder corresponding to `u` both for
956/// perf reasons and because the full set of region assumptions is not known during type checking
957/// due to closure signature inference.
958///
959/// This only really causes problems for higher-ranked outlives assumptions, for example if we have
960/// `where for<'a> <T as Trait<'a>>::Assoc: 'b` then we can't use that to prove `<T as Trait<'!c>>::Assoc: 'b`
961/// until we are in the root context. See comments inside this function for more detail.
962{}
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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(962u32),
                                ::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(NoSpan) | RegionOutlives(..) => {
                                                rewritten_constraints.push(Or::new_leaf(c))
                                            }
                                            PlaceholderTyOutlives(ty, region, NoSpan) => {
                                                rewritten_constraints.push(rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
                                                        ty, region, u, assumptions));
                                            }
                                            AliasTyOutlivesViaEnv(bound_outlives, NoSpan) => {
                                                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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:962",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(962u32),
                        ::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)]
963fn rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling<
964    Infcx: InferCtxtLike<Interner = I>,
965    I: Interner,
966>(
967    infcx: &Infcx,
968    constraint: RegionConstraint<I>,
969    u: UniverseIndex,
970    assumptions: &Assumptions<I>,
971) -> RegionConstraint<I> {
972    use LeafRegionConstraint::*;
973
974    assert!(
975        max_universe(infcx, constraint.clone()) <= u,
976        "constraint {:?} contains terms from a larger universe than {:?}",
977        constraint.clone(),
978        u
979    );
980
981    let rewrite_and = |and: And<I>| {
982        let mut rewritten_constraints = Vec::new();
983        for c in and.0 {
984            match c {
985                Ambiguity(NoSpan) | RegionOutlives(..) => {
986                    rewritten_constraints.push(Or::new_leaf(c))
987                }
988                PlaceholderTyOutlives(ty, region, NoSpan) => {
989                    rewritten_constraints.push(rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, ty, region, u, assumptions));
990                }
991                AliasTyOutlivesViaEnv(bound_outlives, NoSpan) => {
992                    rewritten_constraints.push(rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, bound_outlives, u, assumptions));
993                }
994            }
995        }
996        rewritten_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
997    };
998
999    let and_constraint = rewrite_and(constraint.and_constraint);
1000    let or_constraint = constraint
1001        .or_constraint
1002        .0
1003        .into_iter()
1004        .fold(Or::new_false(), |acc, c| Or::build_or(acc, rewrite_and(c)));
1005
1006    RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
1007}
1008
1009{}
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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(1009u32),
                                ::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(&region)
                                                        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,
                                        NoSpan));
                        }
                        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, NoSpan)));
                        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, NoSpan)));
                        }
                        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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:1009",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(1009u32),
                        ::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)]
1010fn rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
1011    Infcx: InferCtxtLike<Interner = I>,
1012    I: Interner,
1013>(
1014    infcx: &Infcx,
1015    ty: I::Ty,
1016    region: Region<I>,
1017    u: UniverseIndex,
1018    assumptions: &Assumptions<I>,
1019) -> Or<I> {
1020    use LeafRegionConstraint::*;
1021
1022    let ty_u = max_universe(infcx, ty);
1023    let region_u = max_universe(infcx, region);
1024
1025    if region_u != u && ty_u != u {
1026        return Or::new_leaf(PlaceholderTyOutlives(ty, region, NoSpan));
1027    }
1028
1029    let mut candidates = vec![];
1030
1031    // There could be `!T: 'region` assumptions in the env even if `!T` is in a
1032    // smaller universe
1033    candidates.extend(
1034        regions_outlived_by_placeholder(ty, assumptions, infcx.cx())
1035            .map(move |assumption_r| RegionOutlives(assumption_r, region, NoSpan)),
1036    );
1037
1038    // We can express `!T: 'region` as `!T: 'r` where `'r: 'region`. This is only necessary
1039    // if the placeholder type is in a smaller universe as otherwise we know all regions which
1040    // the placeholder outlives and can just destructure into an OR of RegionOutlives.
1041    if region_u == u && ty_u < u {
1042        candidates.extend(
1043            regions_outliving::<I>(region, assumptions, infcx.cx())
1044                .filter(|r| max_universe(infcx, *r) < u)
1045                .map(|r| PlaceholderTyOutlives(ty, r, NoSpan)),
1046        );
1047    }
1048
1049    Or::new(candidates.into_iter().map(|c| And::new([c])))
1050}
1051
1052{}
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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(1052u32),
                                ::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,
                                        NoSpan));
                        }
                        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();
                                    let bound_vars =
                                        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(NoSpan);
                                    }
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:1111",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(1111u32),
                                                            ::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, NoSpan))
                                };
                        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(NoSpan)),
                            TypingMode::Typeck { .. } | TypingMode::Reflection |
                                TypingMode::ErasedNotCoherence { .. } |
                                TypingMode::PostTypeckThroughBorrowck { .. } |
                                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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:1052",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(1052u32),
                        ::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)]
1053fn rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
1054    Infcx: InferCtxtLike<Interner = I>,
1055    I: Interner,
1056>(
1057    infcx: &Infcx,
1058    bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
1059    u: UniverseIndex,
1060    assumptions: &Assumptions<I>,
1061) -> Or<I> {
1062    use LeafRegionConstraint::*;
1063
1064    if max_universe(infcx, bound_outlives) != u {
1065        return Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, NoSpan));
1066    }
1067
1068    let mut candidates = Vec::new();
1069
1070    // given there can be higher ranked assumptions, e.g. `for<'a> <T as Trait<'a>>::Assoc: 'c`, that
1071    // means that it's actually *always* possible for an alias outlive to be satisfied in the root universe
1072    // which means there should *always* be atleast one candidate when destructuring alias outlives.
1073    //
1074    // we dont care about this for region outlives as `for<'a> 'a: 'b` can't exist as we don't elaborate
1075    // higher ranked type outlives assumptions into higher ranked region outlives assumptions. similarly,
1076    // we don't care about `for<'a> Foo<'a>: 'b` as we always destructure adts into their components and if
1077    // we dont equivalently elaborate the assumption into assumptions on the adt's components we just drop the
1078    // assumptions
1079    //
1080    // so actually only `for<'a, 'b> Alias<'a>: 'b` and `for<'a> T: 'a` are assumptions we actually need to
1081    // handle.
1082    let higher_ranked_candidate_for_outlived_region = |region| {
1083        let bound_outlives = bound_outlives.map_bound(|(alias, _)| (alias, region));
1084
1085        let mut replacer = MakeHigherRankederer {
1086            cx: infcx,
1087            preexisting_var_count: bound_outlives.bound_vars().len(),
1088            regions: IndexMap::default(),
1089            universe: u,
1090            current_index: DebruijnIndex::ZERO,
1091        };
1092        let escaping_outlives = bound_outlives.skip_binder().fold_with(&mut replacer);
1093        let bound_vars = bound_outlives.bound_vars();
1094        let bound_vars = bound_vars.iter().chain(
1095            core::mem::take(&mut replacer.regions)
1096                .into_iter()
1097                .map(|(_, bound_region)| BoundVariableKind::Region(bound_region.kind)),
1098        );
1099        let bound_outlives = Binder::bind_with_vars(
1100            escaping_outlives,
1101            I::BoundVarKinds::from_vars(infcx.cx(), bound_vars),
1102        );
1103
1104        // `MakeHigherRankederer` only folds regions. A non-lifetime binder can leave
1105        // a placeholder type in `u`, so this type-outlives constraint cannot be
1106        // handled by the region-outlives-only eager placeholder machinery.
1107        if max_universe(infcx, bound_outlives) == u {
1108            return Or::new_ambig(NoSpan);
1109        }
1110
1111        debug!("higher ranked candidate: {bound_outlives:?}");
1112        Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, NoSpan))
1113    };
1114
1115    // We elaborate something like `Alias<'a_u2>: 'b_u2` into alias outlives involving each
1116    // region which is known to outlive `'b_u2`. So e.g. if `'c_u2: 'b_u2` is known to hold
1117    // would wind up looking at `Alias<'a_u2>: 'c_u2` as well as `Alias<'a_u2>: 'b_u2`.
1118    //
1119    // This is important in two cases. First, if the outliving region is in a lower universe then
1120    // we've successfully lowered the universe of one of the terms in our alias outlives constraint.
1121    //
1122    // Secondly, if it's a region in the current universe *and* it's a region in the components of the
1123    // alias then we get a less general constraint after replacing with bound vars compared to if we
1124    // had just replaced the initial region. See `assumptions_on_binders/alias_outlives_with_repeated_placeholder.rs`
1125    let escaping_r = bound_outlives.skip_binder().1;
1126    if max_universe(infcx, escaping_r) < u || escaping_r.has_escaping_bound_vars() {
1127        // we don't know anything about lower universe regions, and we also don't bother
1128        // looking at the assumptions on the `AliasTyOutlivesViaEnv` binder.
1129        candidates.push(higher_ranked_candidate_for_outlived_region(escaping_r))
1130    } else {
1131        for r in regions_outliving(escaping_r, assumptions, infcx.cx()) {
1132            candidates.push(higher_ranked_candidate_for_outlived_region(r));
1133        }
1134    };
1135
1136    // Actually look at the assumptions and matching our higher ranked alias outlives goal
1137    // against potentially higher ranked type outlives assumptions.
1138    candidates.push(alias_outlives_candidates_from_assumptions(infcx, bound_outlives, assumptions));
1139
1140    // I'm not convinced our handling here is *complete* so for now
1141    // let's be conservative and not let alias outlives' cause NoSolution
1142    // in coherence
1143    match infcx.typing_mode_raw() {
1144        TypingMode::Coherence => candidates.push(Or::new_ambig(NoSpan)),
1145        TypingMode::Typeck { .. }
1146        | TypingMode::Reflection
1147        | TypingMode::ErasedNotCoherence { .. }
1148        | TypingMode::PostTypeckThroughBorrowck { .. }
1149        | TypingMode::PostBorrowck { .. }
1150        | TypingMode::PostAnalysis
1151        | TypingMode::Codegen => (),
1152    };
1153
1154    candidates.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c))
1155}
1156
1157/// Returns all regions `r2` for which `r: r2` is known to hold in
1158/// the universe associated with `assumptions`
1159pub fn regions_outlived_by<I: Interner>(
1160    r: Region<I>,
1161    assumptions: &Assumptions<I>,
1162) -> impl Iterator<Item = Region<I>> {
1163    assumptions.region_outlives.reachable_from(r).into_iter().chain([r])
1164}
1165
1166/// Returns all regions `r2` for which `r2: r` is known to hold in
1167/// the universe associated with `assumptions`
1168pub fn regions_outliving<I: Interner>(
1169    r: Region<I>,
1170    assumptions: &Assumptions<I>,
1171    cx: I,
1172) -> impl Iterator<Item = Region<I>> {
1173    assumptions
1174        .inverse_region_outlives
1175        .reachable_from(r)
1176        .into_iter()
1177        // FIXME(-Zassumptions-on-binders): 'static may have been an input region canonicalized to something else is that important?
1178        // FIXME(-Zassumptions-on-binders): do we need to adding the reflexive edge here?
1179        .chain([r, Region::new_static(cx)])
1180}
1181
1182/// Returns all regions `r` for which `!t: r` is known to hold in
1183/// the universe associated with `assumptions`
1184pub fn regions_outlived_by_placeholder<I: Interner>(
1185    t: I::Ty,
1186    assumptions: &Assumptions<I>,
1187    cx: I,
1188) -> impl Iterator<Item = Region<I>> {
1189    match t.kind() {
1190        TyKind::Placeholder(..) | TyKind::Param(..) => (),
1191        _ => {
    ::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:?}"),
1192    }
1193
1194    assumptions.type_outlives.iter().flat_map(move |binder| match binder.no_bound_vars() {
1195        Some(OutlivesClause(ty, r)) => (ty == t).then_some(r),
1196        None => Some(Region::new_static(cx)),
1197    })
1198}
1199
1200pub struct MakeHigherRankederer<'a, I: Interner, Infcx: InferCtxtLike<Interner = I>> {
1201    cx: &'a Infcx,
1202    preexisting_var_count: usize,
1203    regions: IndexMap<Region<I>, BoundRegion<I>>,
1204    universe: UniverseIndex,
1205    current_index: DebruijnIndex,
1206}
1207
1208impl<'a, I: Interner, Infcx: InferCtxtLike<Interner = I>> MakeHigherRankederer<'a, I, Infcx> {
1209    fn existing_var_count(&self) -> usize {
1210        self.preexisting_var_count + self.regions.len()
1211    }
1212}
1213
1214impl<'a, I: Interner, Infcx: InferCtxtLike<Interner = I>> TypeFolder<I>
1215    for MakeHigherRankederer<'a, I, Infcx>
1216{
1217    fn cx(&self) -> I {
1218        self.cx.cx()
1219    }
1220
1221    fn fold_region(&mut self, r: Region<I>) -> Region<I> {
1222        let cx = self.cx();
1223
1224        match r.kind() {
1225            RegionKind::RePlaceholder(p) if p.universe == self.universe => {
1226                let existing_var_count = self.existing_var_count();
1227                let mapped_var = self.regions.entry(r).or_insert(BoundRegion {
1228                    var: BoundVar::from_usize(existing_var_count),
1229                    kind: p.bound.kind,
1230                });
1231                Region::new_bound(cx, self.current_index, *mapped_var)
1232            }
1233            RegionKind::ReVar(inf) => {
1234                let u = self.cx.universe_of_region(inf).unwrap();
1235                if u == self.universe {
1236                    let existing_var_count = self.existing_var_count();
1237                    let mapped_var = self.regions.entry(r).or_insert(BoundRegion {
1238                        var: BoundVar::from_usize(existing_var_count),
1239                        kind: BoundRegionKind::Anon,
1240                    });
1241                    Region::new_bound(cx, self.current_index, *mapped_var)
1242                } else {
1243                    r
1244                }
1245            }
1246            _ => r,
1247        }
1248    }
1249
1250    fn fold_binder<T: TypeFoldable<I>>(&mut self, b: Binder<I, T>) -> Binder<I, T> {
1251        self.current_index.shift_in(1);
1252        let b = b.super_fold_with(self);
1253        self.current_index.shift_out(1);
1254        b
1255    }
1256}
1257
1258/// Converts an `AliasTyOutlivesViaEnv` constraint into an OR of region outlives constraints by
1259/// matching the alias against any `Alias: 'a` assumptions. This is somewhat tricky as we have a
1260/// potentially higher ranked alias being equated with a potentially higher ranked assumption and
1261/// we don't handle it correctly right now (though it is a somewhat reasonable halfway step).
1262{}
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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(1262u32),
                                ::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, NoSpan)])),
                                            };
                                        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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:1296",
                                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                ::tracing_core::__macro_support::Option::Some(1296u32),
                                                ::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/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs:1262",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/3ef0c22cdb86ac42dc6b8f0f1ec36857daa6f2a1/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(1262u32),
                        ::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)]
1263fn alias_outlives_candidates_from_assumptions<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
1264    infcx: &Infcx,
1265    bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
1266    assumptions: &Assumptions<I>,
1267) -> Or<I> {
1268    let mut candidates = Vec::new();
1269
1270    let prev_universe = infcx.universe();
1271
1272    infcx.enter_forall_with_empty_assumptions(bound_outlives, |(alias, r)| {
1273        for bound_type_outlives in assumptions.type_outlives.iter() {
1274            let OutlivesClause(alias2, r2) =
1275                infcx.instantiate_binder_with_infer(*bound_type_outlives);
1276
1277            let mut relation = HigherRankedAliasMatcher {
1278                infcx,
1279                region_constraints: vec![LeafRegionConstraint::RegionOutlives(r2, r, NoSpan)],
1280            };
1281
1282            // FIXME(#155345): Both sides should be rigid in the future.
1283            // Currently we can't guarantee that.
1284            if let Ok(_) = relation.relate(
1285                alias.to_ty(infcx.cx(), IsRigid::No),
1286                set_aliases_to_non_rigid(infcx.cx(), alias2).skip_norm_wip(),
1287            ) {
1288                candidates.push(And::new(relation.region_constraints));
1289            }
1290        }
1291    });
1292
1293    let constraint = RegionConstraint::new_from_or(Or::new(candidates));
1294
1295    let largest_universe = infcx.universe();
1296    debug!(?prev_universe, ?largest_universe);
1297
1298    let canonical_constraint = ((prev_universe.index() + 1)..=largest_universe.index())
1299        .map(|u| UniverseIndex::from_usize(u))
1300        .rev()
1301        .fold(constraint, |constraint, u| {
1302            eagerly_handle_placeholders_in_universe(infcx, constraint, u)
1303        });
1304
1305    canonical_constraint.splatted_and_constraints()
1306}
1307
1308struct HigherRankedAliasMatcher<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> {
1309    infcx: &'a Infcx,
1310    region_constraints: Vec<LeafRegionConstraint<I>>,
1311}
1312
1313impl<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeRelation<I>
1314    for HigherRankedAliasMatcher<'a, Infcx, I>
1315{
1316    fn cx(&self) -> I {
1317        self.infcx.cx()
1318    }
1319
1320    fn relate_ty_args(
1321        &mut self,
1322        a_ty: I::Ty,
1323        _b_ty: I::Ty,
1324        _ty_def_id: I::DefId,
1325        a_args: I::GenericArgs,
1326        b_args: I::GenericArgs,
1327        _mk: impl FnOnce(I::GenericArgs) -> I::Ty,
1328    ) -> RelateResult<I, I::Ty> {
1329        rustc_type_ir::relate::relate_args_invariantly(self, a_args, b_args)?;
1330        Ok(a_ty)
1331    }
1332
1333    fn relate_with_variance<T: Relate<I>>(
1334        &mut self,
1335        _variance: Variance,
1336        _info: VarianceDiagInfo<I>,
1337        a: T,
1338        b: T,
1339    ) -> RelateResult<I, T> {
1340        // FIXME(-Zassumptions-on-binders): bivariance is important for opaque type args so
1341        // we should actually handle variance in some way here.
1342        self.relate(a, b)
1343    }
1344
1345    fn tys(&mut self, a: I::Ty, b: I::Ty) -> RelateResult<I, I::Ty> {
1346        rustc_type_ir::relate::structurally_relate_tys(self, a, b)
1347    }
1348
1349    fn regions(&mut self, a: Region<I>, b: Region<I>) -> RelateResult<I, Region<I>> {
1350        if a != b {
1351            self.region_constraints.push(LeafRegionConstraint::RegionOutlives(a, b, NoSpan));
1352            self.region_constraints.push(LeafRegionConstraint::RegionOutlives(b, a, NoSpan));
1353        }
1354        Ok(a)
1355    }
1356
1357    fn consts(&mut self, a: Const<I>, b: Const<I>) -> RelateResult<I, Const<I>> {
1358        rustc_type_ir::relate::structurally_relate_consts(self, a, b)
1359    }
1360
1361    fn binders<T>(&mut self, a: Binder<I, T>, b: Binder<I, T>) -> RelateResult<I, Binder<I, T>>
1362    where
1363        T: Relate<I>,
1364    {
1365        self.infcx.enter_forall_with_empty_assumptions(a, |a| {
1366            let u = self.infcx.universe();
1367            self.infcx.insert_placeholder_assumptions(u, Assumptions::empty());
1368            let b = self.infcx.instantiate_binder_with_infer(b);
1369            self.relate(a, b)
1370        })?;
1371
1372        self.infcx.enter_forall_with_empty_assumptions(b, |b| {
1373            let u = self.infcx.universe();
1374            self.infcx.insert_placeholder_assumptions(u, Assumptions::empty());
1375            let a = self.infcx.instantiate_binder_with_infer(a);
1376            self.relate(a, b)
1377        })?;
1378
1379        Ok(a)
1380    }
1381}