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#[automatically_derived]
impl<I: Interner, S: Clone> ::core::clone::Clone for
    LeafRegionConstraint<I, S> where I: Interner, S: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            LeafRegionConstraint::Ambiguity(ref __field_0) =>
                LeafRegionConstraint::Ambiguity {
                    0: ::core::clone::Clone::clone(__field_0),
                },
            LeafRegionConstraint::RegionOutlives(ref __field_0, ref __field_1,
                ref __field_2) =>
                LeafRegionConstraint::RegionOutlives {
                    0: ::core::clone::Clone::clone(__field_0),
                    1: ::core::clone::Clone::clone(__field_1),
                    2: ::core::clone::Clone::clone(__field_2),
                },
            LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __field_0,
                ref __field_1) =>
                LeafRegionConstraint::AliasTyOutlivesViaEnv {
                    0: ::core::clone::Clone::clone(__field_0),
                    1: ::core::clone::Clone::clone(__field_1),
                },
            LeafRegionConstraint::PlaceholderTyOutlives(ref __field_0,
                ref __field_1, ref __field_2) =>
                LeafRegionConstraint::PlaceholderTyOutlives {
                    0: ::core::clone::Clone::clone(__field_0),
                    1: ::core::clone::Clone::clone(__field_1),
                    2: ::core::clone::Clone::clone(__field_2),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone> ::core::hash::Hash for LeafRegionConstraint<I, S>
    where I: Interner, S: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            LeafRegionConstraint::Ambiguity(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            LeafRegionConstraint::RegionOutlives(ref __field_0, ref __field_1,
                ref __field_2) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
                ::core::hash::Hash::hash(__field_1, __state);
                ::core::hash::Hash::hash(__field_2, __state);
            }
            LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __field_0,
                ref __field_1) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
                ::core::hash::Hash::hash(__field_1, __state);
            }
            LeafRegionConstraint::PlaceholderTyOutlives(ref __field_0,
                ref __field_1, ref __field_2) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
                ::core::hash::Hash::hash(__field_1, __state);
                ::core::hash::Hash::hash(__field_2, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone> ::core::cmp::PartialEq for
    LeafRegionConstraint<I, S> where I: Interner, S: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        if ::core::mem::discriminant(self) ==
                ::core::mem::discriminant(__other) {
            match (self, __other) {
                (LeafRegionConstraint::Ambiguity(ref __field_0),
                    LeafRegionConstraint::Ambiguity(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (LeafRegionConstraint::RegionOutlives(ref __field_0,
                    ref __field_1, ref __field_2),
                    LeafRegionConstraint::RegionOutlives(ref __other_field_0,
                    ref __other_field_1, ref __other_field_2)) =>
                    true &&
                                ::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
                            ::core::cmp::PartialEq::eq(__field_1, __other_field_1) &&
                        ::core::cmp::PartialEq::eq(__field_2, __other_field_2),
                (LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __field_0,
                    ref __field_1),
                    LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __other_field_0,
                    ref __other_field_1)) =>
                    true &&
                            ::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
                        ::core::cmp::PartialEq::eq(__field_1, __other_field_1),
                (LeafRegionConstraint::PlaceholderTyOutlives(ref __field_0,
                    ref __field_1, ref __field_2),
                    LeafRegionConstraint::PlaceholderTyOutlives(ref __other_field_0,
                    ref __other_field_1, ref __other_field_2)) =>
                    true &&
                                ::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
                            ::core::cmp::PartialEq::eq(__field_1, __other_field_1) &&
                        ::core::cmp::PartialEq::eq(__field_2, __other_field_2),
                _ => unsafe { ::core::hint::unreachable_unchecked() },
            }
        } else { false }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner, S: Clone> DeriveWhereAssertEq for
            LeafRegionConstraint<I, S> where I: Interner, S: ::core::cmp::Eq {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<S>;
                let _: __AssertEq<Region<I>>;
                let _: __AssertEq<Region<I>>;
                let _: __AssertEq<S>;
                let _: __AssertEq<Binder<I, (AliasTy<I>, Region<I>)>>;
                let _: __AssertEq<S>;
                let _: __AssertEq<I::Ty>;
                let _: __AssertEq<Region<I>>;
                let _: __AssertEq<S>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner, S: Clone> ::core::cmp::Eq for LeafRegionConstraint<I, S>
    where I: Interner, S: ::core::cmp::Eq {
}#[derive_where(Clone, Hash, PartialEq, Eq; I: Interner, S)]
172#[derive(const _: () =
    {
        impl<I: Interner, S: Clone> ::rustc_type_ir::TypeVisitable<I> for
            LeafRegionConstraint<I, S> where I: Interner,
            S: ::rustc_type_ir::TypeVisitable<I>,
            Region<I>: ::rustc_type_ir::TypeVisitable<I>,
            Binder<I,
            (AliasTy<I>, Region<I>)>: ::rustc_type_ir::TypeVisitable<I>,
            I::Ty: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    LeafRegionConstraint::Ambiguity(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    LeafRegionConstraint::RegionOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_2,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __binding_0,
                        ref __binding_1) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    LeafRegionConstraint::PlaceholderTyOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_2,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, S: Clone, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            LeafRegionConstraint<I, S> where
            S: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            S: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Binder<I,
            (AliasTy<I>,
            Region<I>)>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            S: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            S: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    LeafRegionConstraint::Ambiguity(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    LeafRegionConstraint::RegionOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
                                __visitor);
                        }
                    }
                    LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __binding_0,
                        ref __binding_1) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                    LeafRegionConstraint::PlaceholderTyOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner, S: Clone> ::rustc_type_ir::TypeFoldable<I> for
            LeafRegionConstraint<I, S> where I: Interner,
            S: ::rustc_type_ir::TypeFoldable<I>,
            S: ::rustc_type_ir::TypeFoldable<I>,
            Region<I>: ::rustc_type_ir::TypeFoldable<I>,
            Binder<I,
            (AliasTy<I>, Region<I>)>: ::rustc_type_ir::TypeFoldable<I>,
            I::Ty: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        LeafRegionConstraint::Ambiguity(__binding_0) => {
                            LeafRegionConstraint::Ambiguity(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                        LeafRegionConstraint::RegionOutlives(__binding_0,
                            __binding_1, __binding_2) => {
                            LeafRegionConstraint::RegionOutlives(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
                                        __folder)?)
                        }
                        LeafRegionConstraint::AliasTyOutlivesViaEnv(__binding_0,
                            __binding_1) => {
                            LeafRegionConstraint::AliasTyOutlivesViaEnv(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?)
                        }
                        LeafRegionConstraint::PlaceholderTyOutlives(__binding_0,
                            __binding_1, __binding_2) => {
                            LeafRegionConstraint::PlaceholderTyOutlives(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    LeafRegionConstraint::Ambiguity(__binding_0) => {
                        LeafRegionConstraint::Ambiguity(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                    LeafRegionConstraint::RegionOutlives(__binding_0,
                        __binding_1, __binding_2) => {
                        LeafRegionConstraint::RegionOutlives(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
                                __folder))
                    }
                    LeafRegionConstraint::AliasTyOutlivesViaEnv(__binding_0,
                        __binding_1) => {
                        LeafRegionConstraint::AliasTyOutlivesViaEnv(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder))
                    }
                    LeafRegionConstraint::PlaceholderTyOutlives(__binding_0,
                        __binding_1, __binding_2) => {
                        LeafRegionConstraint::PlaceholderTyOutlives(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
173#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner, S: Clone>
            ::rustc_data_structures::stable_hash::StableHash for
            LeafRegionConstraint<I, S> where
            S: ::rustc_data_structures::stable_hash::StableHash,
            Region<I>: ::rustc_data_structures::stable_hash::StableHash,
            Binder<I,
            (AliasTy<I>,
            Region<I>)>: ::rustc_data_structures::stable_hash::StableHash,
            I::Ty: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    LeafRegionConstraint::Ambiguity(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    LeafRegionConstraint::RegionOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                    LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __binding_0,
                        ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    LeafRegionConstraint::PlaceholderTyOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
174pub enum LeafRegionConstraint<I: Interner, S: Clone = ()> {
175    Ambiguity(S),
176    RegionOutlives(Region<I>, Region<I>, S),
177    /// Requirement that a (potentially higher ranked) alias outlives some (potentially higher ranked)
178    /// region due to an assumption in the environment. This cannot be satisfied via component outlives
179    /// or item bounds.
180    ///
181    /// We cannot eagerly look at assumptions as we are usually working with an incomplete set of assumptions
182    /// and there may wind up being assumptions we can use to prove this when we're in a smaller universe.
183    ///
184    /// We eagerly destructure alias outlives requirements into region outlives requirements corresponding to
185    /// component outlives & item bound outlives rules, leaving only param env candidates.
186    AliasTyOutlivesViaEnv(Binder<I, (AliasTy<I>, Region<I>)>, S),
187    /// This is an `I::Ty` for two reasons:
188    /// 1. We need the type visitable impl to be able to `visit_ty` on this so canonicalization
189    ///    knows about the placeholder
190    /// 2. When exiting the trait solver there may be placeholder outlives corresponding to params
191    ///    from the root universe. These need to be changed from a `Placeholder` to the original
192    ///    `Param`.
193    ///
194    /// We cannot eagerly look at assumptions as we are usually working with an incomplete set of assumptions
195    /// and there may wind up being assumptions we can use to prove this when we're in a smaller universe.
196    PlaceholderTyOutlives(I::Ty, Region<I>, S),
197}
198
199impl<I: Interner, S: Clone> std::fmt::Debug for LeafRegionConstraint<I, S> {
200    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
201        match self {
202            Self::Ambiguity(_span) => f.write_str("ambiguity"),
203            Self::RegionOutlives(r1, r2, _span) => {
204                r1.fmt(f)?;
205                f.write_str(": ")?;
206                r2.fmt(f)
207            }
208            Self::AliasTyOutlivesViaEnv(bound_outlives, _span) => {
209                f.write_str("for<")?;
210                bound_outlives.bound_vars().fmt(f)?;
211                f.write_str(">")?;
212                let (ty, r) = bound_outlives.skip_binder();
213                ty.fmt(f)?;
214                f.write_str(": ")?;
215                r.fmt(f)
216            }
217            Self::PlaceholderTyOutlives(ty, r, _span) => {
218                ty.fmt(f)?;
219                f.write_str(": ")?;
220                r.fmt(f)
221            }
222        }
223    }
224}
225
226impl<I: Interner> LeafRegionConstraint<I> {
227    pub fn with_span<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
228        self,
229        span: S,
230    ) -> LeafRegionConstraint<I, S> {
231        use LeafRegionConstraint::*;
232
233        match self {
234            Ambiguity(()) => Ambiguity(span),
235            RegionOutlives(r1, r2, ()) => RegionOutlives(r1, r2, span),
236            AliasTyOutlivesViaEnv(bound_outlives, ()) => {
237                AliasTyOutlivesViaEnv(bound_outlives, span)
238            }
239            PlaceholderTyOutlives(ty, r, ()) => PlaceholderTyOutlives(ty, r, span),
240        }
241    }
242}
243
244impl<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash> LeafRegionConstraint<I, S> {
245    pub fn without_span(self) -> LeafRegionConstraint<I> {
246        use LeafRegionConstraint::*;
247
248        match self {
249            Ambiguity(_) => Ambiguity(()),
250            RegionOutlives(r1, r2, _) => RegionOutlives(r1, r2, ()),
251            AliasTyOutlivesViaEnv(bound_outlives, _) => AliasTyOutlivesViaEnv(bound_outlives, ()),
252            PlaceholderTyOutlives(ty, r, _) => PlaceholderTyOutlives(ty, r, ()),
253        }
254    }
255
256    pub fn span(&self) -> S {
257        use LeafRegionConstraint::*;
258
259        let (Ambiguity(s)
260        | RegionOutlives(_, _, s)
261        | AliasTyOutlivesViaEnv(_, s)
262        | PlaceholderTyOutlives(_, _, s)) = self;
263        s.clone()
264    }
265}
266
267#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::clone::Clone for
    Or<I, S> where I: Interner, S: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            Or(ref __field_0) =>
                Or { 0: ::core::clone::Clone::clone(__field_0) },
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::hash::Hash for Or<I, S>
    where I: Interner, S: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            Or(ref __field_0) => {
                ::core::hash::Hash::hash(__field_0, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::PartialEq for
    Or<I, S> where I: Interner, S: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (Or(ref __field_0), Or(ref __other_field_0)) =>
                true &&
                    ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
        }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner, S: Clone + std::fmt::Debug> DeriveWhereAssertEq for
            Or<I, S> where I: Interner, S: ::core::cmp::Eq {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<SmallVec<[And<I, S>; 1]>>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::Eq for Or<I, S>
    where I: Interner, S: ::core::cmp::Eq {
}#[derive_where(Clone, Hash, PartialEq, Eq; I: Interner, S)]
268#[derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeVisitable<I> for Or<I, S> where I: Interner,
            SmallVec<[And<I, S>; 1]>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    Or(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, S: Clone + std::fmt::Debug, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for Or<I, S> where
            SmallVec<[And<I,
            S>; 1]>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    Or(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeFoldable<I> for Or<I, S> where I: Interner,
            S: ::rustc_type_ir::TypeFoldable<I>,
            SmallVec<[And<I, S>; 1]>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        Or(__binding_0) => {
                            Or(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    Or(__binding_0) => {
                        Or(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
269#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_data_structures::stable_hash::StableHash for Or<I, S>
            where
            SmallVec<[And<I,
            S>; 1]>: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Or(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
270/// An OR of AND of LEAF constraints. Always in "canonical form" meaning:
271/// - No two ANDs are equivalent
272/// - All ANDs are in canonical form
273/// - If any AND is empty, i.e. trivially true, it is the only AND
274///
275/// FIXME(-Zassumptions-on-binders): We should consider a more general canonical form which also
276/// drops any AND that is a superset of another AND. Proving the superset requires strictly more
277/// than proving the subset, so it can never be the candidate which makes the OR hold. E.g.
278/// `OR(AND('a: 'b), AND('a: 'b, 'b: 'c))` really ought to just be `OR(AND('a: 'b))`. Only keeping
279/// an empty AND is the degenerate case of that rule.
280pub struct Or<I: Interner, S: Clone + std::fmt::Debug = ()>(pub SmallVec<[And<I, S>; 1]>);
281impl<I: Interner> Or<I> {
282    pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
283        self,
284        span: S,
285    ) -> Or<I, S> {
286        Or(self.0.into_iter().map(|and| and.with_spans(span.clone())).collect())
287    }
288}
289impl<I: Interner, S: Clone + std::hash::Hash + std::fmt::Debug + Eq> Or<I, S> {
290    pub fn new_true() -> Self {
291        Self(SmallVec::from_buf([And::new_true()]))
292    }
293
294    pub fn is_true(&self) -> bool {
295        // OR([AND([])])
296        if let [and] = &*self.0
297            && and.0.is_empty()
298        {
299            true
300        } else {
301            false
302        }
303    }
304
305    pub fn new_false() -> Self {
306        Self(SmallVec::new())
307    }
308
309    pub fn is_false(&self) -> bool {
310        // OR([])
311        self.0.is_empty()
312    }
313
314    pub fn new(i: impl IntoIterator<Item = And<I, S>>) -> Self {
315        let mut new_ands: SmallVec<[And<I, S>; _]> = SmallVec::new();
316
317        for and in i {
318            // An empty AND is trivially true, which makes the whole OR true no matter what the
319            // other candidates are. `And::new` discards leaf constraints which are trivially
320            // true, so this is how e.g. a reflexive `'a: 'a` candidate discharges an OR.
321            if and.0.is_empty() {
322                return Self::new_true();
323            }
324
325            // FIXME(-Zassumptions-on-binders): We only discard an AND which is equivalent to one
326            // we already have. More generally we should discard any AND which is a superset of
327            // another, as it requires strictly more to hold. E.g. the second AND in
328            // `OR(AND('a: 'b), AND('a: 'b, 'b: 'c))` is never the one which makes the OR true.
329            if new_ands.iter().all(|c| !c.is_and_equivalent_to(&and)) {
330                new_ands.push(and)
331            }
332        }
333
334        Self(new_ands)
335    }
336
337    pub fn new_ambig(s: S) -> Self {
338        Or::new_leaf(LeafRegionConstraint::Ambiguity(s))
339    }
340
341    pub fn new_leaf(l: LeafRegionConstraint<I, S>) -> Self {
342        Or::new([And::new([l])])
343    }
344
345    pub fn build_and(a: Or<I, S>, b: Or<I, S>) -> Self {
346        // FIXME(-Zassumptions-on-binders): probably bad for perf, doing a lot of reallocating
347        // and whatnot here :3
348
349        // Important: keeps `ands` empty if either `b_and` or `a_and` is empty
350        let mut ands = Vec::new();
351        for b_and in b.0 {
352            for a_and in a.0.clone().into_iter() {
353                ands.push(And::new(a_and.0.into_iter().chain(b_and.0.clone())))
354            }
355        }
356
357        Or::new(ands)
358    }
359
360    pub fn build_or(a: Or<I, S>, b: Or<I, S>) -> Self {
361        Or::new(a.0.into_iter().chain(b.0))
362    }
363
364    pub fn without_spans(self) -> Or<I> {
365        Or(self.0.into_iter().map(|and| and.without_spans()).collect())
366    }
367}
368
369impl<I: Interner, S: Clone + std::fmt::Debug> std::fmt::Debug for Or<I, S> {
370    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
371        if self.0.is_empty() {
372            f.write_str("false")
373        } else if let [single] = &*self.0 {
374            single.fmt(f)
375        } else {
376            f.write_str("or ")?;
377            f.debug_set().entries(&self.0).finish()
378        }
379    }
380}
381
382#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::clone::Clone for
    And<I, S> where I: Interner, S: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            And(ref __field_0) =>
                And { 0: ::core::clone::Clone::clone(__field_0) },
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::hash::Hash for And<I, S>
    where I: Interner, S: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            And(ref __field_0) => {
                ::core::hash::Hash::hash(__field_0, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::PartialEq for
    And<I, S> where I: Interner, S: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (And(ref __field_0), And(ref __other_field_0)) =>
                true &&
                    ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
        }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner, S: Clone + std::fmt::Debug> DeriveWhereAssertEq for
            And<I, S> where I: Interner, S: ::core::cmp::Eq {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<SmallVec<[LeafRegionConstraint<I, S>; 1]>>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::Eq for And<I, S>
    where I: Interner, S: ::core::cmp::Eq {
}#[derive_where(Clone, Hash, PartialEq, Eq; I: Interner, S)]
383#[derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeVisitable<I> for And<I, S> where I: Interner,
            SmallVec<[LeafRegionConstraint<I,
            S>; 1]>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    And(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, S: Clone + std::fmt::Debug, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for And<I, S> where
            SmallVec<[LeafRegionConstraint<I,
            S>; 1]>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    And(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeFoldable<I> for And<I, S> where I: Interner,
            S: ::rustc_type_ir::TypeFoldable<I>,
            SmallVec<[LeafRegionConstraint<I,
            S>; 1]>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        And(__binding_0) => {
                            And(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    And(__binding_0) => {
                        And(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
384#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_data_structures::stable_hash::StableHash for And<I, S>
            where
            SmallVec<[LeafRegionConstraint<I,
            S>; 1]>: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    And(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
385/// An AND of leaf constraints. Always in "canonical form", meaning:
386/// - No leaf constraints are present twice in this AND
387/// - No leaf constraint is trivially true, i.e. a reflexive `'a: 'a`
388pub struct And<I: Interner, S: Clone + std::fmt::Debug = ()>(
389    pub SmallVec<[LeafRegionConstraint<I, S>; 1]>,
390);
391impl<I: Interner> And<I> {
392    pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
393        self,
394        span: S,
395    ) -> And<I, S> {
396        And(self.0.into_iter().map(|leaf| leaf.with_span(span.clone())).collect())
397    }
398}
399impl<I: Interner, S: Clone + std::hash::Hash + std::fmt::Debug + Eq> And<I, S> {
400    pub fn new_true() -> Self {
401        Self(SmallVec::new())
402    }
403
404    pub fn new(i: impl IntoIterator<Item = LeafRegionConstraint<I, S>>) -> Self {
405        let mut seen = IndexSet::new();
406        And(i
407            .into_iter()
408            .filter(|leaf| {
409                // Outlives is reflexive so a `'a: 'a` leaf is always true and carries no
410                // information. Dropping it here keeps the rest of the code from having to special
411                // case it, and is what lets an OR with a reflexive candidate be recognized as true.
412                if let LeafRegionConstraint::RegionOutlives(r1, r2, _) = leaf
413                    && r1 == r2
414                {
415                    return false;
416                }
417
418                if seen.contains(&leaf.clone().without_span()) {
419                    false
420                } else {
421                    seen.insert(leaf.clone().without_span());
422                    true
423                }
424            })
425            .collect())
426    }
427
428    fn is_and_equivalent_to(&self, other: &And<I, S>) -> bool {
429        let this = self.clone().0;
430        let other = other.clone().0;
431
432        this.iter()
433            .all(|c1| other.iter().any(|c2| c1.clone().without_span() == c2.clone().without_span()))
434            && other.iter().all(|c2| {
435                this.iter().any(|c1| c1.clone().without_span() == c2.clone().without_span())
436            })
437    }
438
439    pub fn without_spans(self) -> And<I> {
440        And(self.0.into_iter().map(|leaf| leaf.without_span()).collect())
441    }
442}
443
444impl<I: Interner, S: Clone + std::fmt::Debug> std::fmt::Debug for And<I, S> {
445    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
446        if self.0.is_empty() {
447            f.write_str("true")
448        } else if let [single] = &*self.0 {
449            single.fmt(f)
450        } else {
451            f.write_str("and ")?;
452            f.debug_set().entries(&self.0).finish()
453        }
454    }
455}
456
457#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::clone::Clone for
    RegionConstraint<I, S> where I: Interner, S: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            RegionConstraint {
                and_constraint: ref __field_and_constraint,
                or_constraint: ref __field_or_constraint } =>
                RegionConstraint {
                    and_constraint: ::core::clone::Clone::clone(__field_and_constraint),
                    or_constraint: ::core::clone::Clone::clone(__field_or_constraint),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::hash::Hash for
    RegionConstraint<I, S> where I: Interner, S: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            RegionConstraint {
                and_constraint: ref __field_and_constraint,
                or_constraint: ref __field_or_constraint } => {
                ::core::hash::Hash::hash(__field_and_constraint, __state);
                ::core::hash::Hash::hash(__field_or_constraint, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::PartialEq for
    RegionConstraint<I, S> where I: Interner, S: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (RegionConstraint {
                and_constraint: ref __field_and_constraint,
                or_constraint: ref __field_or_constraint }, RegionConstraint {
                and_constraint: ref __other_field_and_constraint,
                or_constraint: ref __other_field_or_constraint }) =>
                true &&
                        ::core::cmp::PartialEq::eq(__field_and_constraint,
                            __other_field_and_constraint) &&
                    ::core::cmp::PartialEq::eq(__field_or_constraint,
                        __other_field_or_constraint),
        }
    }
}#[derive_where(Clone, Hash, PartialEq; I: Interner, S)]
458#[derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeVisitable<I> for RegionConstraint<I, S> where
            I: Interner, And<I, S>: ::rustc_type_ir::TypeVisitable<I>,
            Or<I, S>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    RegionConstraint {
                        and_constraint: ref __binding_0,
                        or_constraint: ref __binding_1 } => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, S: Clone + std::fmt::Debug, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            RegionConstraint<I, S> where
            And<I, S>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Or<I, S>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    RegionConstraint {
                        and_constraint: ref __binding_0,
                        or_constraint: ref __binding_1 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeFoldable<I> for RegionConstraint<I, S> where
            I: Interner, S: ::rustc_type_ir::TypeFoldable<I>,
            And<I, S>: ::rustc_type_ir::TypeFoldable<I>,
            Or<I, S>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        RegionConstraint {
                            and_constraint: __binding_0, or_constraint: __binding_1 } =>
                            {
                            RegionConstraint {
                                and_constraint: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                or_constraint: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    RegionConstraint {
                        and_constraint: __binding_0, or_constraint: __binding_1 } =>
                        {
                        RegionConstraint {
                            and_constraint: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            or_constraint: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
459#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_data_structures::stable_hash::StableHash for
            RegionConstraint<I, S> where
            And<I, S>: ::rustc_data_structures::stable_hash::StableHash,
            Or<I, S>: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    RegionConstraint {
                        and_constraint: ref __binding_0,
                        or_constraint: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
460/// An `And` and an `Or` constraint both in canonical forms, with two additional constraints:
461/// - If the `or_constraint` is false then the `and_constraint` is empty
462/// - The `or_constraint` does not have any constraints present in all of its inner `And`s
463///    - i.e. `OR ( AND ('a: 'b, 'b: 'c), AND ('a: 'b, 'b: 'd))` is not a thing
464/// - The OR constraint is in canonical form
465/// - The AND constraint is in canonical form
466///
467/// This should be thought of as an AND consisting of a set of LEAF constraints as well
468/// as a single OR constraint.
469pub struct RegionConstraint<I: Interner, S: Clone + std::fmt::Debug = ()> {
470    pub and_constraint: And<I, S>,
471    pub or_constraint: Or<I, S>,
472}
473
474impl<I: Interner> RegionConstraint<I> {
475    pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
476        self,
477        span: S,
478    ) -> RegionConstraint<I, S> {
479        RegionConstraint {
480            and_constraint: self.and_constraint.with_spans(span.clone()),
481            or_constraint: self.or_constraint.with_spans(span.clone()),
482        }
483    }
484}
485impl<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash> RegionConstraint<I, S> {
486    pub fn new_from_or(or: Or<I, S>) -> Self {
487        let Some(fst) = or.0.get(0).clone() else {
488            return RegionConstraint::new_false();
489        };
490        let mut and_constraint = fst.0.to_vec();
491
492        for and in or.0.split_first().unwrap().1 {
493            and_constraint.retain(|c| {
494                and.0.iter().any(|c2| c.clone().without_span() == c2.clone().without_span())
495            });
496        }
497        let and_constraint = And::new(and_constraint);
498
499        let or_constraint = Or::new(or.0.into_iter().map(|and| {
500            And::new(and.0.into_iter().filter(|c| {
501                and_constraint
502                    .0
503                    .iter()
504                    .all(|s_c| c.clone().without_span() != s_c.clone().without_span())
505            }))
506        }));
507
508        Self {
509            and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
510            or_constraint,
511        }
512    }
513
514    pub fn splatted_and_constraints(&self) -> Or<I, S> {
515        Or::new(self.or_constraint.0.iter().map(|and| {
516            And::new(and.0.iter().cloned().chain(self.and_constraint.0.iter().cloned()))
517        }))
518    }
519
520    pub fn build_and(a: RegionConstraint<I, S>, b: RegionConstraint<I, S>) -> Self {
521        let and_constraint = And::new(a.and_constraint.0.into_iter().chain(b.and_constraint.0));
522        let or_constraint = Or::build_and(a.or_constraint, b.or_constraint);
523
524        Self {
525            and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
526            or_constraint,
527        }
528    }
529
530    pub fn build_or(a: RegionConstraint<I, S>, b: RegionConstraint<I, S>) -> Self {
531        Self::new_from_or(Or::build_or(a.splatted_and_constraints(), b.splatted_and_constraints()))
532    }
533
534    pub fn new_true() -> Self {
535        Self { and_constraint: And::new_true(), or_constraint: Or::new_true() }
536    }
537
538    pub fn is_true(&self) -> bool {
539        self.and_constraint.0.is_empty() && self.or_constraint.is_true()
540    }
541
542    pub fn new_false() -> Self {
543        Self { and_constraint: And::new_true(), or_constraint: Or::new_false() }
544    }
545
546    pub fn is_false(&self) -> bool {
547        self.or_constraint.is_false()
548    }
549
550    pub fn new_ambig(span: S) -> Self {
551        Self {
552            and_constraint: And::new([LeafRegionConstraint::Ambiguity(span)]),
553            or_constraint: Or::new_true(),
554        }
555    }
556
557    pub fn is_ambig(&self) -> bool {
558        if let [c] = &*self.and_constraint.0
559            && c.is_ambig()
560            && self.or_constraint.is_true()
561        {
562            true
563        } else {
564            false
565        }
566    }
567
568    pub fn without_spans(self) -> RegionConstraint<I> {
569        RegionConstraint {
570            and_constraint: self.and_constraint.without_spans(),
571            or_constraint: self.or_constraint.without_spans(),
572        }
573    }
574
575    pub fn new_leaf(l: LeafRegionConstraint<I, S>) -> Self {
576        RegionConstraint { and_constraint: And::new([l]), or_constraint: Or::new_true() }
577    }
578}
579
580impl<I: Interner, S: Clone + std::fmt::Debug> std::fmt::Debug for RegionConstraint<I, S> {
581    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
582        if let [single_or] = &*self.or_constraint.0
583            && single_or.0.is_empty()
584        {
585            self.and_constraint.fmt(f)
586        } else if self.and_constraint.0.is_empty() {
587            self.or_constraint.fmt(f)
588        } else {
589            f.write_str("and ")?;
590            f.debug_set().entries(&self.and_constraint.0).entry(&self.or_constraint).finish()
591        }
592    }
593}
594
595impl<I: Interner, S: Clone + std::fmt::Debug> LeafRegionConstraint<I, S> {
596    pub fn is_ambig(&self) -> bool {
597        #[allow(non_exhaustive_omitted_patterns)] match self {
    Self::Ambiguity(_) => true,
    _ => false,
}matches!(self, Self::Ambiguity(_))
598    }
599}
600
601/// Takes any constraints involving placeholders from the current universe and eagerly checks them.
602/// This can be done a few ways:
603/// - There's an assumption on the binder introducing the placeholder which means the constraint is satisfied (true)
604/// - There's assumptions on the binder introducing the placeholder which allow us to rewrite the constraint in
605///    terms of lower universe variables. For example given `for<'a> where('b: 'a) { prove(T: '!a_u1) }` we can
606///    convert this constraint to `T: 'b` which no longer references anything from `u1`.
607/// - There are no relevant assumptions so we can neither rewrite the constraint nor consider it satisfied (false)
608/// - We failed to compute the full set of assumptions when entering the binder corresponding to `u`. (ambiguity)
609///
610/// After handling all of the region constraints in `u` we then evaluate the entire constraint as much as possible,
611/// propagating true/false/ambiguity as close to the root of the constraint as we can. The returned constraint should
612/// be checked for whether it is true/false/ambiguous as that should affect the result of whatever operation required
613/// entering the binder corresponding to `u`.
614{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("eagerly_handle_placeholders_in_universe",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(614u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if !(u > UniverseIndex::ROOT) {
                            {
                                ::core::panicking::panic_fmt(format_args!("eagerly handle placeholders called for root universe"));
                            }
                        };
                        let assumptions = infcx.get_placeholder_assumptions(u);
                        let constraint =
                            rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
                                constraint, u, &assumptions);
                        let constraint =
                            compute_new_region_constraints(infcx, constraint, u);
                        let constraint =
                            pull_region_outlives_constraints_out_of_universe(infcx,
                                constraint, u, &assumptions);
                        constraint
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:614",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(614u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
615pub fn eagerly_handle_placeholders_in_universe<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
616    infcx: &Infcx,
617    constraint: RegionConstraint<I>,
618    u: UniverseIndex,
619) -> RegionConstraint<I> {
620    assert!(u > UniverseIndex::ROOT, "eagerly handle placeholders called for root universe");
621
622    let assumptions = infcx.get_placeholder_assumptions(u);
623
624    // 1. rewrite type outlives constraints involving things from `u` into either region constraints
625    //     involving things from `u` or type outlives constraints not involving things from `u`
626    //
627    //    IOW, we only want to encounter things from `u` as part of region out lives constraints.
628    let constraint = rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling(
629        infcx,
630        constraint,
631        u,
632        &assumptions,
633    );
634
635    // 2. compute transitive region outlives and get a new set of region outlives constraints by
636    //     looking for every region which either a placeholder_u flows into it, or it flows into
637    //     the placeholder.
638    let constraint = compute_new_region_constraints(infcx, constraint, u);
639
640    // 3. rewrite region outlives constraints (potentially to false/true)
641    let constraint =
642        pull_region_outlives_constraints_out_of_universe(infcx, constraint, u, &assumptions);
643
644    constraint
645}
646
647/// Filter our region constraints to not include constraints between region variables from `u` and
648/// other regions as those are always satisfied. This requires some care to handle correctly for example:
649/// `'!a_u1: '?x_u1: '!b_u1` should result in us requiring `'!a_u1: '!b_u1` rather than dropping the two
650/// constraints entirely.
651///
652/// The only constraints involving things from `u` should be region outlives constraints at this point. Type
653/// outlives constraints should have been handled already either by destructuring into region outlives or by
654/// being rewritten in terms of smaller universe variables.
655{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("compute_new_region_constraints",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(655u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        use LeafRegionConstraint::*;
                        let extend_from_and =
                            |builder: &mut TransitiveRelationBuilder<_>,
                                regions: &mut IndexSet<_>, constraints: &mut Vec<_>,
                                and: &And<I>|
                                {
                                    for c in &and.0 {
                                        match c {
                                            Ambiguity(()) | PlaceholderTyOutlives(..) |
                                                AliasTyOutlivesViaEnv(..) => {
                                                constraints.push(c.clone())
                                            }
                                            RegionOutlives(r1, r2, ()) => {
                                                regions.insert(*r1);
                                                regions.insert(*r2);
                                                builder.add(*r2, *r1);
                                            }
                                        }
                                    }
                                };
                        let mut base_region_flows_builder =
                            TransitiveRelationBuilder::default();
                        let mut base_regions = IndexSet::new();
                        let mut base_constraints = Vec::new();
                        extend_from_and(&mut base_region_flows_builder,
                            &mut base_regions, &mut base_constraints,
                            &constraint.and_constraint);
                        let mut new_ands = Vec::new();
                        for and in &constraint.or_constraint.0 {
                            let mut region_flows_builder =
                                base_region_flows_builder.clone();
                            let mut regions = base_regions.clone();
                            let mut constraints = base_constraints.clone();
                            extend_from_and(&mut region_flows_builder, &mut regions,
                                &mut constraints, and);
                            let region_flow = region_flows_builder.freeze();
                            for r in regions.into_iter() {
                                for ub in region_flow.reachable_from(r) {
                                    let is_placeholder_like =
                                        |r: Region<I>|
                                            match r.kind() {
                                                RegionKind::ReLateParam(..) | RegionKind::ReEarlyParam(..) |
                                                    RegionKind::RePlaceholder(..) | RegionKind::ReStatic =>
                                                    true,
                                                RegionKind::ReVar(..) => max_universe(infcx, r) < u,
                                                RegionKind::ReError(..) => false,
                                                RegionKind::ReErased | RegionKind::ReBound(..) =>
                                                    ::core::panicking::panic("internal error: entered unreachable code"),
                                            };
                                    if is_placeholder_like(r) && is_placeholder_like(ub) {
                                        constraints.push(RegionOutlives(ub, r, ()));
                                    }
                                }
                            }
                            new_ands.push(Or::new([And::new(constraints)]))
                        }
                        RegionConstraint::new_from_or(new_ands.into_iter().fold(Or::new_false(),
                                |acc, c| Or::build_or(acc, c)))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:655",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(655u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
656fn compute_new_region_constraints<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
657    infcx: &Infcx,
658    constraint: RegionConstraint<I>,
659    u: UniverseIndex,
660) -> RegionConstraint<I> {
661    use LeafRegionConstraint::*;
662
663    let extend_from_and = |builder: &mut TransitiveRelationBuilder<_>,
664                           regions: &mut IndexSet<_>,
665                           constraints: &mut Vec<_>,
666                           and: &And<I>| {
667        for c in &and.0 {
668            match c {
669                Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
670                    constraints.push(c.clone())
671                }
672                RegionOutlives(r1, r2, ()) => {
673                    regions.insert(*r1);
674                    regions.insert(*r2);
675                    builder.add(*r2, *r1);
676                }
677            }
678        }
679    };
680
681    let mut base_region_flows_builder = TransitiveRelationBuilder::default();
682    let mut base_regions = IndexSet::new();
683    let mut base_constraints = Vec::new();
684    extend_from_and(
685        &mut base_region_flows_builder,
686        &mut base_regions,
687        &mut base_constraints,
688        &constraint.and_constraint,
689    );
690
691    let mut new_ands = Vec::new();
692    for and in &constraint.or_constraint.0 {
693        let mut region_flows_builder = base_region_flows_builder.clone();
694        let mut regions = base_regions.clone();
695        let mut constraints = base_constraints.clone();
696        extend_from_and(&mut region_flows_builder, &mut regions, &mut constraints, and);
697
698        let region_flow = region_flows_builder.freeze();
699        for r in regions.into_iter() {
700            for ub in region_flow.reachable_from(r) {
701                // we want to retain any region constraints between two "placeholder-likes" where for our
702                // purposes a placeholder-like is either a placeholder or variable in a lower universe
703                let is_placeholder_like = |r: Region<I>| match r.kind() {
704                    RegionKind::ReLateParam(..)
705                    | RegionKind::ReEarlyParam(..)
706                    | RegionKind::RePlaceholder(..)
707                    | RegionKind::ReStatic => true,
708                    RegionKind::ReVar(..) => max_universe(infcx, r) < u,
709                    RegionKind::ReError(..) => false,
710                    RegionKind::ReErased | RegionKind::ReBound(..) => unreachable!(),
711                };
712
713                if is_placeholder_like(r) && is_placeholder_like(ub) {
714                    constraints.push(RegionOutlives(ub, r, ()));
715                }
716            }
717        }
718
719        new_ands.push(Or::new([And::new(constraints)]))
720    }
721
722    // FIXME(-Zassumptions-on-binders): probably bad for perf!
723    RegionConstraint::new_from_or(
724        new_ands.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c)),
725    )
726}
727
728/// Handles converting region outlives constraints involving placeholders from `u` into OR constraints
729/// involving regions from smaller universes with known relationships to the placeholder. For example:
730/// ```ignore (not rust)
731/// for<'a, 'b> where(
732///     'c: 'b, 'd: 'b,
733///     'a: 'e, 'a: 'f,
734/// ) {
735///     'a_u1: 'b_u1
736/// }
737/// ```
738/// will get converted to:
739/// ```ignore (not rust)
740/// OR(
741///     'e: 'c,
742///     'e: 'd,
743///     'f: 'c,
744///     'f: 'd,
745/// )
746/// ```
747/// if we are handling constraints in `u1`.
748{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("pull_region_outlives_constraints_out_of_universe",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(748u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assumptions")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assumptions");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if !(max_universe(infcx, constraint.clone()) <= u) {
                            ::core::panicking::panic("assertion failed: max_universe(infcx, constraint.clone()) <= u")
                        };
                        use LeafRegionConstraint::*;
                        let pull_and =
                            |and: And<I>|
                                {
                                    let mut pulled_constraints = Vec::new();
                                    for c in and.0 {
                                        match c {
                                            Ambiguity(()) | PlaceholderTyOutlives(..) |
                                                AliasTyOutlivesViaEnv(..) => {
                                                if !(max_universe(infcx, c.clone()) < u) {
                                                    ::core::panicking::panic("assertion failed: max_universe(infcx, c.clone()) < u")
                                                };
                                                pulled_constraints.push(Or::new_leaf(c.clone()));
                                            }
                                            RegionOutlives(region_1, region_2, ()) => {
                                                let region_1_u = max_universe(infcx, region_1);
                                                let region_2_u = max_universe(infcx, region_2);
                                                if region_1_u != u && region_2_u != u {
                                                    pulled_constraints.push(Or::new_leaf(c));
                                                    continue;
                                                }
                                                if regions_outlived_by(region_1,
                                                            assumptions).any(|r| r == region_2) {
                                                    continue;
                                                }
                                                let mut candidates = ::alloc::vec::Vec::new();
                                                for ub in
                                                    regions_outlived_by(region_1,
                                                            assumptions).filter(|r| max_universe(infcx, *r) < u) {
                                                    for lb in
                                                        regions_outliving(region_2, assumptions,
                                                                infcx.cx()).filter(|r| max_universe(infcx, *r) < u) {
                                                        candidates.push(RegionOutlives(ub, lb, ()));
                                                    }
                                                }
                                                pulled_constraints.push(Or::new(candidates.into_iter().map(|c|
                                                                And::new([c]))));
                                            }
                                        };
                                    }
                                    pulled_constraints.into_iter().fold(Or::new_true(),
                                        |acc, c| Or::build_and(acc, c))
                                };
                        let and_constraint = pull_and(constraint.and_constraint);
                        let or_constraint =
                            constraint.or_constraint.0.into_iter().fold(Or::new_false(),
                                |acc, c| Or::build_or(acc, pull_and(c)));
                        RegionConstraint::new_from_or(Or::build_and(and_constraint,
                                or_constraint))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:748",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(748u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
749fn pull_region_outlives_constraints_out_of_universe<
750    Infcx: InferCtxtLike<Interner = I>,
751    I: Interner,
752>(
753    infcx: &Infcx,
754    constraint: RegionConstraint<I>,
755    u: UniverseIndex,
756    assumptions: &Assumptions<I>,
757) -> RegionConstraint<I> {
758    assert!(max_universe(infcx, constraint.clone()) <= u);
759
760    // FIXME(-Zassumptions-on-binders): we don't lower universes of region variables when exiting `u`
761    // this seems dubious/potentially wrong? we can't just blindly do this though as if we had something
762    // like `!T_u -> ?x_u -> !U_u` then lowering `?x` to `u-1` when exiting `u` would be wrong.
763    //
764    // I'm not even sure this would be necessary given we filter out region constraints involving regions#
765    // from the current universe and only retain those between placeholders.
766
767    use LeafRegionConstraint::*;
768
769    let pull_and = |and: And<I>| {
770        let mut pulled_constraints = Vec::new();
771        for c in and.0 {
772            match c {
773                Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
774                    assert!(max_universe(infcx, c.clone()) < u);
775                    pulled_constraints.push(Or::new_leaf(c.clone()));
776                }
777                RegionOutlives(region_1, region_2, ()) => {
778                    let region_1_u = max_universe(infcx, region_1);
779                    let region_2_u = max_universe(infcx, region_2);
780
781                    if region_1_u != u && region_2_u != u {
782                        pulled_constraints.push(Or::new_leaf(c));
783                        continue;
784                    }
785
786                    // The constraint may already be entailed by the assumptions of the binder we are
787                    // leaving, e.g. `for<'a, 'b> where 'b: 'a { 'b: 'a }`. There is nothing to lift into
788                    // a smaller universe in that case, and looking for lower universe candidates would
789                    // wrongly result in `Or([])` whenever the placeholders have no lower universe bounds.
790                    if regions_outlived_by(region_1, assumptions).any(|r| r == region_2) {
791                        continue;
792                    }
793
794                    let mut candidates = vec![];
795
796                    for ub in regions_outlived_by(region_1, assumptions)
797                        .filter(|r| max_universe(infcx, *r) < u)
798                    {
799                        // FIXME(-Zassumptions-on-binders): if `region_2` is in a smaller universe there'll be both
800                        // `'region_2` and `'static` as lower bounds which seems... unfortunate and may cause us to
801                        // add a bunch of duplicate `'ub: 'static` candidates the more binders we leave.
802                        for lb in regions_outliving(region_2, assumptions, infcx.cx())
803                            .filter(|r| max_universe(infcx, *r) < u)
804                        {
805                            // As long as any region outlived by `region_1` outlives any region region which
806                            // `region_2` outlives, we know that `region_1: region_2` holds. In other words,
807                            // there exists some set of 4 regions for which `'r1: 'i1` `'i1: 'i2` `'i2: 'r2`
808                            candidates.push(RegionOutlives(ub, lb, ()));
809                        }
810                    }
811
812                    pulled_constraints.push(Or::new(candidates.into_iter().map(|c| And::new([c]))));
813                }
814            };
815        }
816
817        pulled_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
818    };
819
820    let and_constraint = pull_and(constraint.and_constraint);
821    let or_constraint = constraint
822        .or_constraint
823        .0
824        .into_iter()
825        .fold(Or::new_false(), |acc, c| Or::build_or(acc, pull_and(c)));
826    RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
827}
828
829/// Converts type outlives constraints into region outlives constraints. This assumes the *complete* set of
830/// assumptions are known. This should not be called until the end of type checking.
831///
832/// The returned region constraint will not have *any* PlaceholderTyOutlives or AliasTyOutlivesViaEnv constraints.
833{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("destructure_type_outlives_constraints_in_root",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(833u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assumptions")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assumptions");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I, S> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        use LeafRegionConstraint::*;
                        let destructure_and =
                            |and: &And<I, S>|
                                {
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:846",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(846u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                                            ::tracing_core::field::FieldSet::new(&["message"],
                                                                ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                            ::tracing::metadata::Kind::EVENT)
                                                    };
                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                            };
                                        let enabled =
                                            ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                    ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                {
                                                    let interest = __CALLSITE.interest();
                                                    !interest.is_never() &&
                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                            interest)
                                                };
                                        if enabled {
                                            (|value_set: ::tracing::field::ValueSet|
                                                        {
                                                            let meta = __CALLSITE.metadata();
                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                            ;
                                                        })({
                                                    #[allow(unused_imports)]
                                                    use ::tracing::field::{debug, display, Value};
                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("rewriting and: {0:?}",
                                                                                        and) as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    let mut destructured_constraints = Vec::new();
                                    for c in &and.0 {
                                        match c {
                                            Ambiguity(_) | RegionOutlives(..) => {
                                                destructured_constraints.push(Or::new_leaf(c.clone()))
                                            }
                                            PlaceholderTyOutlives(ty, r, span) =>
                                                destructured_constraints.push(Or::new(regions_outlived_by_placeholder(*ty,
                                                                assumptions,
                                                                infcx.cx()).map(move |assumption_r|
                                                                {
                                                                    And::new([RegionOutlives(assumption_r, *r, span.clone())])
                                                                }))),
                                            AliasTyOutlivesViaEnv(bound_outlives, span) => {
                                                destructured_constraints.push(alias_outlives_candidates_from_assumptions(infcx,
                                                            *bound_outlives, assumptions).with_spans(span.clone()));
                                            }
                                        }
                                    }
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:872",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(872u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                                            ::tracing_core::field::FieldSet::new(&[{
                                                                                const NAME:
                                                                                    ::tracing::__macro_support::FieldName<{
                                                                                        ::tracing::__macro_support::FieldName::len("destructured_constraints")
                                                                                    }> =
                                                                                    ::tracing::__macro_support::FieldName::new("destructured_constraints");
                                                                                NAME.as_str()
                                                                            }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                            ::tracing::metadata::Kind::EVENT)
                                                    };
                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                            };
                                        let enabled =
                                            ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                    ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                {
                                                    let interest = __CALLSITE.interest();
                                                    !interest.is_never() &&
                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                            interest)
                                                };
                                        if enabled {
                                            (|value_set: ::tracing::field::ValueSet|
                                                        {
                                                            let meta = __CALLSITE.metadata();
                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                            ;
                                                        })({
                                                    #[allow(unused_imports)]
                                                    use ::tracing::field::{debug, display, Value};
                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&destructured_constraints)
                                                                                as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    let merged_constraints =
                                        destructured_constraints.into_iter().fold(Or::new_true(),
                                            |acc, c| Or::build_and(acc, c));
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:876",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(876u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                                            ::tracing_core::field::FieldSet::new(&[{
                                                                                const NAME:
                                                                                    ::tracing::__macro_support::FieldName<{
                                                                                        ::tracing::__macro_support::FieldName::len("merged_constraints")
                                                                                    }> =
                                                                                    ::tracing::__macro_support::FieldName::new("merged_constraints");
                                                                                NAME.as_str()
                                                                            }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                            ::tracing::metadata::Kind::EVENT)
                                                    };
                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                            };
                                        let enabled =
                                            ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                    ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                {
                                                    let interest = __CALLSITE.interest();
                                                    !interest.is_never() &&
                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                            interest)
                                                };
                                        if enabled {
                                            (|value_set: ::tracing::field::ValueSet|
                                                        {
                                                            let meta = __CALLSITE.metadata();
                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                            ;
                                                        })({
                                                    #[allow(unused_imports)]
                                                    use ::tracing::field::{debug, display, Value};
                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&merged_constraints)
                                                                                as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    merged_constraints
                                };
                        let and_constraint =
                            destructure_and(&constraint.and_constraint);
                        let or_constraint =
                            constraint.or_constraint.0.into_iter().fold(Or::new_false(),
                                |acc, c| Or::build_or(acc, destructure_and(&c)));
                        RegionConstraint::new_from_or(Or::build_and(and_constraint,
                                or_constraint))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:833",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(833u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
834pub fn destructure_type_outlives_constraints_in_root<
835    Infcx: InferCtxtLike<Interner = I>,
836    I: Interner,
837    S: Clone + std::fmt::Debug + Eq + std::hash::Hash,
838>(
839    infcx: &Infcx,
840    constraint: RegionConstraint<I, S>,
841    assumptions: &Assumptions<I>,
842) -> RegionConstraint<I, S> {
843    use LeafRegionConstraint::*;
844
845    let destructure_and = |and: &And<I, S>| {
846        debug!("rewriting and: {:?}", and);
847        let mut destructured_constraints = Vec::new();
848        for c in &and.0 {
849            match c {
850                Ambiguity(_) | RegionOutlives(..) => {
851                    destructured_constraints.push(Or::new_leaf(c.clone()))
852                }
853                PlaceholderTyOutlives(ty, r, span) => destructured_constraints.push(Or::new(
854                    regions_outlived_by_placeholder(*ty, assumptions, infcx.cx()).map(
855                        move |assumption_r| {
856                            And::new([RegionOutlives(assumption_r, *r, span.clone())])
857                        },
858                    ),
859                )),
860                AliasTyOutlivesViaEnv(bound_outlives, span) => {
861                    destructured_constraints.push(
862                        alias_outlives_candidates_from_assumptions(
863                            infcx,
864                            *bound_outlives,
865                            assumptions,
866                        )
867                        .with_spans(span.clone()),
868                    );
869                }
870            }
871        }
872        debug!(?destructured_constraints);
873        let merged_constraints = destructured_constraints
874            .into_iter()
875            .fold(Or::new_true(), |acc, c| Or::build_and(acc, c));
876        debug!(?merged_constraints);
877        merged_constraints
878    };
879
880    let and_constraint = destructure_and(&constraint.and_constraint);
881    let or_constraint = constraint
882        .or_constraint
883        .0
884        .into_iter()
885        .fold(Or::new_false(), |acc, c| Or::build_or(acc, destructure_and(&c)));
886
887    RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
888}
889
890/// Converts type outlives constraints into either region outlives constraints, or type outlives
891/// constraints which do not contain anything from `u`.
892///
893/// This only works off assumptions associated with the binder corresponding to `u` both for
894/// perf reasons and because the full set of region assumptions is not known during type checking
895/// due to closure signature inference.
896///
897/// This only really causes problems for higher-ranked outlives assumptions, for example if we have
898/// `where for<'a> <T as Trait<'a>>::Assoc: 'b` then we can't use that to prove `<T as Trait<'!c>>::Assoc: 'b`
899/// until we are in the root context. See comments inside this function for more detail.
900{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(900u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assumptions")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assumptions");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        use LeafRegionConstraint::*;
                        if !(max_universe(infcx, constraint.clone()) <= u) {
                            {
                                ::core::panicking::panic_fmt(format_args!("constraint {0:?} contains terms from a larger universe than {1:?}",
                                        constraint.clone(), u));
                            }
                        };
                        let rewrite_and =
                            |and: And<I>|
                                {
                                    let mut rewritten_constraints = Vec::new();
                                    for c in and.0 {
                                        match c {
                                            Ambiguity(()) | RegionOutlives(..) =>
                                                rewritten_constraints.push(Or::new_leaf(c)),
                                            PlaceholderTyOutlives(ty, region, ()) => {
                                                rewritten_constraints.push(rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
                                                        ty, region, u, assumptions));
                                            }
                                            AliasTyOutlivesViaEnv(bound_outlives, ()) => {
                                                rewritten_constraints.push(rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
                                                        bound_outlives, u, assumptions));
                                            }
                                        }
                                    }
                                    rewritten_constraints.into_iter().fold(Or::new_true(),
                                        |acc, c| Or::build_and(acc, c))
                                };
                        let and_constraint = rewrite_and(constraint.and_constraint);
                        let or_constraint =
                            constraint.or_constraint.0.into_iter().fold(Or::new_false(),
                                |acc, c| Or::build_or(acc, rewrite_and(c)));
                        RegionConstraint::new_from_or(Or::build_and(and_constraint,
                                or_constraint))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:900",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(900u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
901fn rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling<
902    Infcx: InferCtxtLike<Interner = I>,
903    I: Interner,
904>(
905    infcx: &Infcx,
906    constraint: RegionConstraint<I>,
907    u: UniverseIndex,
908    assumptions: &Assumptions<I>,
909) -> RegionConstraint<I> {
910    use LeafRegionConstraint::*;
911
912    assert!(
913        max_universe(infcx, constraint.clone()) <= u,
914        "constraint {:?} contains terms from a larger universe than {:?}",
915        constraint.clone(),
916        u
917    );
918
919    let rewrite_and = |and: And<I>| {
920        let mut rewritten_constraints = Vec::new();
921        for c in and.0 {
922            match c {
923                Ambiguity(()) | RegionOutlives(..) => rewritten_constraints.push(Or::new_leaf(c)),
924                PlaceholderTyOutlives(ty, region, ()) => {
925                    rewritten_constraints.push(rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, ty, region, u, assumptions));
926                }
927                AliasTyOutlivesViaEnv(bound_outlives, ()) => {
928                    rewritten_constraints.push(rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, bound_outlives, u, assumptions));
929                }
930            }
931        }
932        rewritten_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
933    };
934
935    let and_constraint = rewrite_and(constraint.and_constraint);
936    let or_constraint = constraint
937        .or_constraint
938        .0
939        .into_iter()
940        .fold(Or::new_false(), |acc, c| Or::build_or(acc, rewrite_and(c)));
941
942    RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
943}
944
945{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(945u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("ty")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("ty");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("region")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("region");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assumptions")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assumptions");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&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, ()));
                        }
                        let mut candidates = ::alloc::vec::Vec::new();
                        candidates.extend(regions_outlived_by_placeholder(ty,
                                    assumptions,
                                    infcx.cx()).map(move |assumption_r|
                                    RegionOutlives(assumption_r, region, ())));
                        if region_u == u && ty_u < u {
                            candidates.extend(regions_outliving::<I>(region,
                                            assumptions,
                                            infcx.cx()).filter(|r|
                                            max_universe(infcx, *r) <
                                                u).map(|r| PlaceholderTyOutlives(ty, r, ())));
                        }
                        Or::new(candidates.into_iter().map(|c| And::new([c])))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:945",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(945u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
946fn rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
947    Infcx: InferCtxtLike<Interner = I>,
948    I: Interner,
949>(
950    infcx: &Infcx,
951    ty: I::Ty,
952    region: Region<I>,
953    u: UniverseIndex,
954    assumptions: &Assumptions<I>,
955) -> Or<I> {
956    use LeafRegionConstraint::*;
957
958    let ty_u = max_universe(infcx, ty);
959    let region_u = max_universe(infcx, region);
960
961    if region_u != u && ty_u != u {
962        return Or::new_leaf(PlaceholderTyOutlives(ty, region, ()));
963    }
964
965    let mut candidates = vec![];
966
967    // There could be `!T: 'region` assumptions in the env even if `!T` is in a
968    // smaller universe
969    candidates.extend(
970        regions_outlived_by_placeholder(ty, assumptions, infcx.cx())
971            .map(move |assumption_r| RegionOutlives(assumption_r, region, ())),
972    );
973
974    // We can express `!T: 'region` as `!T: 'r` where `'r: 'region`. This is only necessary
975    // if the placeholder type is in a smaller universe as otherwise we know all regions which
976    // the placeholder outlives and can just destructure into an OR of RegionOutlives.
977    if region_u == u && ty_u < u {
978        candidates.extend(
979            regions_outliving::<I>(region, assumptions, infcx.cx())
980                .filter(|r| max_universe(infcx, *r) < u)
981                .map(|r| PlaceholderTyOutlives(ty, r, ())),
982        );
983    }
984
985    Or::new(candidates.into_iter().map(|c| And::new([c])))
986}
987
988{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(988u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("bound_outlives")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("bound_outlives");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assumptions")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assumptions");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bound_outlives)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: Or<I> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        use LeafRegionConstraint::*;
                        if max_universe(infcx, bound_outlives) != u {
                            return Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives,
                                        ()));
                        }
                        let mut candidates = Vec::new();
                        let higher_ranked_candidate_for_outlived_region =
                            |region|
                                {
                                    let bound_outlives =
                                        bound_outlives.map_bound(|(alias, _)| (alias, region));
                                    let mut replacer =
                                        MakeHigherRankederer {
                                            cx: infcx,
                                            preexisting_var_count: bound_outlives.bound_vars().len(),
                                            regions: IndexMap::default(),
                                            universe: u,
                                            current_index: DebruijnIndex::ZERO,
                                        };
                                    let escaping_outlives =
                                        bound_outlives.skip_binder().fold_with(&mut replacer);
                                    let bound_vars =
                                        bound_outlives.bound_vars().iter().chain(core::mem::take(&mut replacer.regions).into_iter().map(|(_,
                                                        bound_region)|
                                                    BoundVariableKind::Region(bound_region.kind)));
                                    let bound_outlives =
                                        Binder::bind_with_vars(escaping_outlives,
                                            I::BoundVarKinds::from_vars(infcx.cx(), bound_vars));
                                    if max_universe(infcx, bound_outlives) == u {
                                        return Or::new_ambig(());
                                    }
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:1046",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(1046u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                                            ::tracing_core::field::FieldSet::new(&["message"],
                                                                ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                            ::tracing::metadata::Kind::EVENT)
                                                    };
                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                            };
                                        let enabled =
                                            ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                    ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                {
                                                    let interest = __CALLSITE.interest();
                                                    !interest.is_never() &&
                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                            interest)
                                                };
                                        if enabled {
                                            (|value_set: ::tracing::field::ValueSet|
                                                        {
                                                            let meta = __CALLSITE.metadata();
                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                            ;
                                                        })({
                                                    #[allow(unused_imports)]
                                                    use ::tracing::field::{debug, display, Value};
                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("higher ranked candidate: {0:?}",
                                                                                        bound_outlives) as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, ()))
                                };
                        let escaping_r = bound_outlives.skip_binder().1;
                        if max_universe(infcx, escaping_r) < u ||
                                escaping_r.has_escaping_bound_vars() {
                            candidates.push(higher_ranked_candidate_for_outlived_region(escaping_r))
                        } else {
                            for r in
                                regions_outliving(escaping_r, assumptions, infcx.cx()) {
                                candidates.push(higher_ranked_candidate_for_outlived_region(r));
                            }
                        };
                        candidates.push(alias_outlives_candidates_from_assumptions(infcx,
                                bound_outlives, assumptions));
                        match infcx.typing_mode_raw() {
                            TypingMode::Coherence => candidates.push(Or::new_ambig(())),
                            TypingMode::Typeck { .. } | TypingMode::Reflection |
                                TypingMode::ErasedNotCoherence { .. } |
                                TypingMode::PostTypeckUntilBorrowck { .. } |
                                TypingMode::PostBorrowck { .. } | TypingMode::PostAnalysis |
                                TypingMode::Codegen => (),
                        };
                        candidates.into_iter().fold(Or::new_false(),
                            |acc, c| Or::build_or(acc, c))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:988",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(988u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
989fn rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
990    Infcx: InferCtxtLike<Interner = I>,
991    I: Interner,
992>(
993    infcx: &Infcx,
994    bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
995    u: UniverseIndex,
996    assumptions: &Assumptions<I>,
997) -> Or<I> {
998    use LeafRegionConstraint::*;
999
1000    if max_universe(infcx, bound_outlives) != u {
1001        return Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, ()));
1002    }
1003
1004    let mut candidates = Vec::new();
1005
1006    // given there can be higher ranked assumptions, e.g. `for<'a> <T as Trait<'a>>::Assoc: 'c`, that
1007    // means that it's actually *always* possible for an alias outlive to be satisfied in the root universe
1008    // which means there should *always* be atleast one candidate when destructuring alias outlives.
1009    //
1010    // we dont care about this for region outlives as `for<'a> 'a: 'b` can't exist as we don't elaborate
1011    // higher ranked type outlives assumptions into higher ranked region outlives assumptions. similarly,
1012    // we don't care about `for<'a> Foo<'a>: 'b` as we always destructure adts into their components and if
1013    // we dont equivalently elaborate the assumption into assumptions on the adt's components we just drop the
1014    // assumptions
1015    //
1016    // so actually only `for<'a, 'b> Alias<'a>: 'b` and `for<'a> T: 'a` are assumptions we actually need to
1017    // handle.
1018    let higher_ranked_candidate_for_outlived_region = |region| {
1019        let bound_outlives = bound_outlives.map_bound(|(alias, _)| (alias, region));
1020
1021        let mut replacer = MakeHigherRankederer {
1022            cx: infcx,
1023            preexisting_var_count: bound_outlives.bound_vars().len(),
1024            regions: IndexMap::default(),
1025            universe: u,
1026            current_index: DebruijnIndex::ZERO,
1027        };
1028        let escaping_outlives = bound_outlives.skip_binder().fold_with(&mut replacer);
1029        let bound_vars = bound_outlives.bound_vars().iter().chain(
1030            core::mem::take(&mut replacer.regions)
1031                .into_iter()
1032                .map(|(_, bound_region)| BoundVariableKind::Region(bound_region.kind)),
1033        );
1034        let bound_outlives = Binder::bind_with_vars(
1035            escaping_outlives,
1036            I::BoundVarKinds::from_vars(infcx.cx(), bound_vars),
1037        );
1038
1039        // `MakeHigherRankederer` only folds regions. A non-lifetime binder can leave
1040        // a placeholder type in `u`, so this type-outlives constraint cannot be
1041        // handled by the region-outlives-only eager placeholder machinery.
1042        if max_universe(infcx, bound_outlives) == u {
1043            return Or::new_ambig(());
1044        }
1045
1046        debug!("higher ranked candidate: {bound_outlives:?}");
1047        Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, ()))
1048    };
1049
1050    // We elaborate something like `Alias<'a_u2>: 'b_u2` into alias outlives involving each
1051    // region which is known to outlive `'b_u2`. So e.g. if `'c_u2: 'b_u2` is known to hold
1052    // would wind up looking at `Alias<'a_u2>: 'c_u2` as well as `Alias<'a_u2>: 'b_u2`.
1053    //
1054    // This is important in two cases. First, if the outliving region is in a lower universe then
1055    // we've successfully lowered the universe of one of the terms in our alias outlives constraint.
1056    //
1057    // Secondly, if it's a region in the current universe *and* it's a region in the components of the
1058    // alias then we get a less general constraint after replacing with bound vars compared to if we
1059    // had just replaced the initial region. See `assumptions_on_binders/alias_outlives_with_repeated_placeholder.rs`
1060    let escaping_r = bound_outlives.skip_binder().1;
1061    if max_universe(infcx, escaping_r) < u || escaping_r.has_escaping_bound_vars() {
1062        // we don't know anything about lower universe regions, and we also don't bother
1063        // looking at the assumptions on the `AliasTyOutlivesViaEnv` binder.
1064        candidates.push(higher_ranked_candidate_for_outlived_region(escaping_r))
1065    } else {
1066        for r in regions_outliving(escaping_r, assumptions, infcx.cx()) {
1067            candidates.push(higher_ranked_candidate_for_outlived_region(r));
1068        }
1069    };
1070
1071    // Actually look at the assumptions and matching our higher ranked alias outlives goal
1072    // against potentially higher ranked type outlives assumptions.
1073    candidates.push(alias_outlives_candidates_from_assumptions(infcx, bound_outlives, assumptions));
1074
1075    // I'm not convinced our handling here is *complete* so for now
1076    // let's be conservative and not let alias outlives' cause NoSolution
1077    // in coherence
1078    match infcx.typing_mode_raw() {
1079        TypingMode::Coherence => candidates.push(Or::new_ambig(())),
1080        TypingMode::Typeck { .. }
1081        | TypingMode::Reflection
1082        | TypingMode::ErasedNotCoherence { .. }
1083        | TypingMode::PostTypeckUntilBorrowck { .. }
1084        | TypingMode::PostBorrowck { .. }
1085        | TypingMode::PostAnalysis
1086        | TypingMode::Codegen => (),
1087    };
1088
1089    candidates.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c))
1090}
1091
1092/// Returns all regions `r2` for which `r: r2` is known to hold in
1093/// the universe associated with `assumptions`
1094pub fn regions_outlived_by<I: Interner>(
1095    r: Region<I>,
1096    assumptions: &Assumptions<I>,
1097) -> impl Iterator<Item = Region<I>> {
1098    assumptions.region_outlives.reachable_from(r).into_iter().chain([r])
1099}
1100
1101/// Returns all regions `r2` for which `r2: r` is known to hold in
1102/// the universe associated with `assumptions`
1103pub fn regions_outliving<I: Interner>(
1104    r: Region<I>,
1105    assumptions: &Assumptions<I>,
1106    cx: I,
1107) -> impl Iterator<Item = Region<I>> {
1108    assumptions
1109        .inverse_region_outlives
1110        .reachable_from(r)
1111        .into_iter()
1112        // FIXME(-Zassumptions-on-binders): 'static may have been an input region canonicalized to something else is that important?
1113        // FIXME(-Zassumptions-on-binders): do we need to adding the reflexive edge here?
1114        .chain([r, Region::new_static(cx)])
1115}
1116
1117/// Returns all regions `r` for which `!t: r` is known to hold in
1118/// the universe associated with `assumptions`
1119pub fn regions_outlived_by_placeholder<I: Interner>(
1120    t: I::Ty,
1121    assumptions: &Assumptions<I>,
1122    cx: I,
1123) -> impl Iterator<Item = Region<I>> {
1124    match t.kind() {
1125        TyKind::Placeholder(..) | TyKind::Param(..) => (),
1126        _ => {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("non-placeholder in `regions_outlived_by_placeholder`: {0:?}",
                t)));
}unreachable!("non-placeholder in `regions_outlived_by_placeholder`: {t:?}"),
1127    }
1128
1129    assumptions.type_outlives.iter().flat_map(move |binder| match binder.no_bound_vars() {
1130        Some(OutlivesClause(ty, r)) => (ty == t).then_some(r),
1131        None => Some(Region::new_static(cx)),
1132    })
1133}
1134
1135pub struct MakeHigherRankederer<'a, I: Interner, Infcx: InferCtxtLike<Interner = I>> {
1136    cx: &'a Infcx,
1137    preexisting_var_count: usize,
1138    regions: IndexMap<Region<I>, BoundRegion<I>>,
1139    universe: UniverseIndex,
1140    current_index: DebruijnIndex,
1141}
1142
1143impl<'a, I: Interner, Infcx: InferCtxtLike<Interner = I>> MakeHigherRankederer<'a, I, Infcx> {
1144    fn existing_var_count(&self) -> usize {
1145        self.preexisting_var_count + self.regions.len()
1146    }
1147}
1148
1149impl<'a, I: Interner, Infcx: InferCtxtLike<Interner = I>> TypeFolder<I>
1150    for MakeHigherRankederer<'a, I, Infcx>
1151{
1152    fn cx(&self) -> I {
1153        self.cx.cx()
1154    }
1155
1156    fn fold_region(&mut self, r: Region<I>) -> Region<I> {
1157        let cx = self.cx();
1158
1159        match r.kind() {
1160            RegionKind::RePlaceholder(p) if p.universe == self.universe => {
1161                let existing_var_count = self.existing_var_count();
1162                let mapped_var = self.regions.entry(r).or_insert(BoundRegion {
1163                    var: BoundVar::from_usize(existing_var_count),
1164                    kind: p.bound.kind,
1165                });
1166                Region::new_bound(cx, self.current_index, *mapped_var)
1167            }
1168            RegionKind::ReVar(inf) => {
1169                let u = self.cx.universe_of_region(inf).unwrap();
1170                if u == self.universe {
1171                    let existing_var_count = self.existing_var_count();
1172                    let mapped_var = self.regions.entry(r).or_insert(BoundRegion {
1173                        var: BoundVar::from_usize(existing_var_count),
1174                        kind: BoundRegionKind::Anon,
1175                    });
1176                    Region::new_bound(cx, self.current_index, *mapped_var)
1177                } else {
1178                    r
1179                }
1180            }
1181            _ => r,
1182        }
1183    }
1184
1185    fn fold_binder<T: TypeFoldable<I>>(&mut self, b: Binder<I, T>) -> Binder<I, T> {
1186        self.current_index.shift_in(1);
1187        let b = b.super_fold_with(self);
1188        self.current_index.shift_out(1);
1189        b
1190    }
1191}
1192
1193/// Converts an `AliasTyOutlivesViaEnv` constraint into an OR of region outlives constraints by
1194/// matching the alias against any `Alias: 'a` assumptions. This is somewhat tricky as we have a
1195/// potentially higher ranked alias being equated with a potentially higher ranked assumption and
1196/// we don't handle it correctly right now (though it is a somewhat reasonable halfway step).
1197{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("alias_outlives_candidates_from_assumptions",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(1197u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("bound_outlives")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("bound_outlives");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assumptions")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assumptions");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bound_outlives)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: Or<I> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let mut candidates = Vec::new();
                        let prev_universe = infcx.universe();
                        infcx.enter_forall_with_empty_assumptions(bound_outlives,
                            |(alias, r)|
                                {
                                    for bound_type_outlives in assumptions.type_outlives.iter()
                                        {
                                        let OutlivesClause(alias2, r2) =
                                            infcx.instantiate_binder_with_infer(*bound_type_outlives);
                                        let mut relation =
                                            HigherRankedAliasMatcher {
                                                infcx,
                                                region_constraints: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                        [LeafRegionConstraint::RegionOutlives(r2, r, ())])),
                                            };
                                        if let Ok(_) =
                                                relation.relate(alias.to_ty(infcx.cx(), IsRigid::No),
                                                    set_aliases_to_non_rigid(infcx.cx(),
                                                            alias2).skip_norm_wip()) {
                                            candidates.push(And::new(relation.region_constraints));
                                        }
                                    }
                                });
                        let constraint =
                            RegionConstraint::new_from_or(Or::new(candidates));
                        let largest_universe = infcx.universe();
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:1231",
                                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                ::tracing_core::__macro_support::Option::Some(1231u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("prev_universe")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("prev_universe");
                                                                    NAME.as_str()
                                                                },
                                                                {
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("largest_universe")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("largest_universe");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&prev_universe)
                                                                    as &dyn ::tracing::field::Value)),
                                                        (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&largest_universe)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let canonical_constraint =
                            ((prev_universe.index() +
                                                        1)..=largest_universe.index()).map(|u|
                                            UniverseIndex::from_usize(u)).rev().fold(constraint,
                                |constraint, u|
                                    {
                                        eagerly_handle_placeholders_in_universe(infcx, constraint,
                                            u)
                                    });
                        canonical_constraint.splatted_and_constraints()
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs:1197",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/1a2c4797ef2570bd76ca5dee34449169bc7dc457/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(1197u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
1198fn alias_outlives_candidates_from_assumptions<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
1199    infcx: &Infcx,
1200    bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
1201    assumptions: &Assumptions<I>,
1202) -> Or<I> {
1203    let mut candidates = Vec::new();
1204
1205    let prev_universe = infcx.universe();
1206
1207    infcx.enter_forall_with_empty_assumptions(bound_outlives, |(alias, r)| {
1208        for bound_type_outlives in assumptions.type_outlives.iter() {
1209            let OutlivesClause(alias2, r2) =
1210                infcx.instantiate_binder_with_infer(*bound_type_outlives);
1211
1212            let mut relation = HigherRankedAliasMatcher {
1213                infcx,
1214                region_constraints: vec![LeafRegionConstraint::RegionOutlives(r2, r, ())],
1215            };
1216
1217            // FIXME(#155345): Both sides should be rigid in the future.
1218            // Currently we can't guarantee that.
1219            if let Ok(_) = relation.relate(
1220                alias.to_ty(infcx.cx(), IsRigid::No),
1221                set_aliases_to_non_rigid(infcx.cx(), alias2).skip_norm_wip(),
1222            ) {
1223                candidates.push(And::new(relation.region_constraints));
1224            }
1225        }
1226    });
1227
1228    let constraint = RegionConstraint::new_from_or(Or::new(candidates));
1229
1230    let largest_universe = infcx.universe();
1231    debug!(?prev_universe, ?largest_universe);
1232
1233    let canonical_constraint = ((prev_universe.index() + 1)..=largest_universe.index())
1234        .map(|u| UniverseIndex::from_usize(u))
1235        .rev()
1236        .fold(constraint, |constraint, u| {
1237            eagerly_handle_placeholders_in_universe(infcx, constraint, u)
1238        });
1239
1240    canonical_constraint.splatted_and_constraints()
1241}
1242
1243struct HigherRankedAliasMatcher<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> {
1244    infcx: &'a Infcx,
1245    region_constraints: Vec<LeafRegionConstraint<I>>,
1246}
1247
1248impl<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeRelation<I>
1249    for HigherRankedAliasMatcher<'a, Infcx, I>
1250{
1251    fn cx(&self) -> I {
1252        self.infcx.cx()
1253    }
1254
1255    fn relate_ty_args(
1256        &mut self,
1257        a_ty: I::Ty,
1258        _b_ty: I::Ty,
1259        _ty_def_id: I::DefId,
1260        a_args: I::GenericArgs,
1261        b_args: I::GenericArgs,
1262        _mk: impl FnOnce(I::GenericArgs) -> I::Ty,
1263    ) -> RelateResult<I, I::Ty> {
1264        rustc_type_ir::relate::relate_args_invariantly(self, a_args, b_args)?;
1265        Ok(a_ty)
1266    }
1267
1268    fn relate_with_variance<T: Relate<I>>(
1269        &mut self,
1270        _variance: Variance,
1271        _info: VarianceDiagInfo<I>,
1272        a: T,
1273        b: T,
1274    ) -> RelateResult<I, T> {
1275        // FIXME(-Zassumptions-on-binders): bivariance is important for opaque type args so
1276        // we should actually handle variance in some way here.
1277        self.relate(a, b)
1278    }
1279
1280    fn tys(&mut self, a: I::Ty, b: I::Ty) -> RelateResult<I, I::Ty> {
1281        rustc_type_ir::relate::structurally_relate_tys(self, a, b)
1282    }
1283
1284    fn regions(&mut self, a: Region<I>, b: Region<I>) -> RelateResult<I, Region<I>> {
1285        if a != b {
1286            self.region_constraints.push(LeafRegionConstraint::RegionOutlives(a, b, ()));
1287            self.region_constraints.push(LeafRegionConstraint::RegionOutlives(b, a, ()));
1288        }
1289        Ok(a)
1290    }
1291
1292    fn consts(&mut self, a: Const<I>, b: Const<I>) -> RelateResult<I, Const<I>> {
1293        rustc_type_ir::relate::structurally_relate_consts(self, a, b)
1294    }
1295
1296    fn binders<T>(&mut self, a: Binder<I, T>, b: Binder<I, T>) -> RelateResult<I, Binder<I, T>>
1297    where
1298        T: Relate<I>,
1299    {
1300        self.infcx.enter_forall_with_empty_assumptions(a, |a| {
1301            let u = self.infcx.universe();
1302            self.infcx.insert_placeholder_assumptions(u, Assumptions::empty());
1303            let b = self.infcx.instantiate_binder_with_infer(b);
1304            self.relate(a, b)
1305        })?;
1306
1307        self.infcx.enter_forall_with_empty_assumptions(b, |b| {
1308            let u = self.infcx.universe();
1309            self.infcx.insert_placeholder_assumptions(u, Assumptions::empty());
1310            let a = self.infcx.instantiate_binder_with_infer(a);
1311            self.relate(a, b)
1312        })?;
1313
1314        Ok(a)
1315    }
1316}