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 crate::data_structures::IndexMap;
52use crate::fold::TypeSuperFoldable;
53use crate::inherent::*;
54use crate::relate::{Relate, RelateResult, TypeRelation, VarianceDiagInfo};
55use crate::{
56    AliasTy, Binder, BoundRegion, BoundVar, BoundVariableKind, ClauseKind, DebruijnIndex,
57    InferCtxtLike, Interner, IsRigid, OutlivesClause, Region, RegionKind, TyKind, TypeFoldable,
58    TypeFolder, TypingMode, UniverseIndex, Variance, elaborate, max_universe,
59    set_aliases_to_non_rigid,
60};
61
62#[automatically_derived]
impl<I: Interner> ::core::clone::Clone for Assumptions<I> where I: Interner {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            Assumptions {
                type_outlives: ref __field_type_outlives,
                region_outlives: ref __field_region_outlives,
                inverse_region_outlives: ref __field_inverse_region_outlives }
                =>
                Assumptions {
                    type_outlives: ::core::clone::Clone::clone(__field_type_outlives),
                    region_outlives: ::core::clone::Clone::clone(__field_region_outlives),
                    inverse_region_outlives: ::core::clone::Clone::clone(__field_inverse_region_outlives),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for Assumptions<I> where I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            Assumptions {
                type_outlives: ref __field_type_outlives,
                region_outlives: ref __field_region_outlives,
                inverse_region_outlives: ref __field_inverse_region_outlives }
                => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "Assumptions");
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "type_outlives", __field_type_outlives);
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "region_outlives", __field_region_outlives);
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "inverse_region_outlives", __field_inverse_region_outlives);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Debug; I: Interner)]
63pub struct Assumptions<I: Interner> {
64    pub type_outlives: Vec<Binder<I, OutlivesClause<I, I::Ty>>>,
65    /// Known `'a: 'b` assumptions, stored as an edge from the outliving region to the
66    /// outlived one, i.e. an edge `('a, 'b)` means `'a: 'b`. Constructors expect a relation
67    /// with this direction, see [`regions_outlived_by`] and [`regions_outliving`] for how it
68    /// is consumed.
69    pub region_outlives: TransitiveRelation<Region<I>>,
70    pub inverse_region_outlives: TransitiveRelation<Region<I>>,
71}
72
73impl<I: Interner> Assumptions<I> {
74    pub fn empty() -> Self {
75        Self {
76            type_outlives: Vec::new(),
77            region_outlives: TransitiveRelationBuilder::default().freeze(),
78            inverse_region_outlives: TransitiveRelationBuilder::default().freeze(),
79        }
80    }
81
82    /// Builds assumptions from `clauses`, elaborating them and keeping the outlives ones.
83    ///
84    /// Callers hand us their clauses straight from the environment, so we have to elaborate
85    /// here to get at the implied outlives bounds:
86    /// - a `Ty: 'a` clause tells us that every region component of `Ty` outlives `'a`, e.g.
87    ///   `&'b u8: 'a` implies `'b: 'a`. Without it we'd fail to prove `'b: 'a` when leaving
88    ///   the binder these assumptions belong to.
89    /// - it also gives us the components as type outlives, e.g. `Vec<T>: 'a` implies `T: 'a`,
90    ///   which we need for placeholder and alias outlives.
91    /// - trait clauses imply their supertraits, so `T: Bound<'a>` where `trait Bound<'c>: 'c`
92    ///   gives us `T: 'a`. This is why we take clauses rather than just the outlives ones:
93    ///   filtering down to outlives before elaborating would throw those away.
94    ///
95    /// Only the clauses whose max universe is exactly `universe` are kept, which is what the
96    /// solver wants when computing the assumptions of a single binder. This happens after
97    /// elaboration on purpose, so a clause whose regions live in more than one universe still
98    /// contributes its implied bounds to each of them: `(&'b u8, &'c u8): 'a` gives us
99    /// `'c: 'a` in `'c`s universe even though the clause itself is in `'b`s.
100    ///
101    /// Use [`Assumptions::new_unelaborated`] when the caller needs the assumptions to be
102    /// exactly the clauses it passed in.
103    pub fn new(
104        infcx: &impl InferCtxtLike<Interner = I>,
105        clauses: impl IntoIterator<Item = I::Clause>,
106        region_outlives: TransitiveRelation<Region<I>>,
107        universe: UniverseIndex,
108    ) -> Self {
109        let mut type_outlives = ::alloc::vec::Vec::new()vec![];
110        let mut region_outlives_builder = TransitiveRelationBuilder::default();
111        for (r1, r2) in region_outlives.base_edges() {
112            region_outlives_builder.add(r1, r2);
113        }
114
115        let clauses = elaborate::elaborate(infcx.cx(), clauses)
116            .filter(|clause| max_universe(infcx, *clause) == universe);
117        for clause in clauses {
118            match clause.kind().skip_binder() {
119                // The type outlives assumptions are kept around as they are required for
120                // proving placeholder and alias outlives.
121                ClauseKind::TypeOutlives(_) => {
122                    type_outlives.push(clause.as_type_outlives_clause().unwrap());
123                }
124                ClauseKind::RegionOutlives(OutlivesClause(r1, r2)) => {
125                    // `elaborate` drops the components which are bound inside of the type and
126                    // bails on `for<'a> Ty: 'a`, so both regions here are free even though the
127                    // clause itself may still be under a binder.
128                    if true {
    if !(!r1.is_bound() && !r2.is_bound()) {
        ::core::panicking::panic("assertion failed: !r1.is_bound() && !r2.is_bound()")
    };
};debug_assert!(!r1.is_bound() && !r2.is_bound());
129                    region_outlives_builder.add(r1, r2);
130                }
131                // Anything else can't be used as an outlives assumption.
132                _ => (),
133            }
134        }
135
136        Self::new_unelaborated(type_outlives, region_outlives_builder.freeze())
137    }
138
139    /// Builds assumptions from exactly the given clauses, see [`Assumptions::new`] for when
140    /// the clauses should get elaborated instead.
141    pub fn new_unelaborated(
142        type_outlives: Vec<Binder<I, OutlivesClause<I, I::Ty>>>,
143        region_outlives: TransitiveRelation<Region<I>>,
144    ) -> Self {
145        Self {
146            inverse_region_outlives: {
147                let mut builder = TransitiveRelationBuilder::default();
148                for (r1, r2) in region_outlives.base_edges() {
149                    builder.add(r2, r1);
150                }
151                builder.freeze()
152            },
153            type_outlives,
154            region_outlives,
155        }
156    }
157}
158
159#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::clone::Clone for
    LeafRegionConstraint<I, S> where I: Interner, S: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            LeafRegionConstraint::Ambiguity(ref __field_0) =>
                LeafRegionConstraint::Ambiguity {
                    0: ::core::clone::Clone::clone(__field_0),
                },
            LeafRegionConstraint::RegionOutlives(ref __field_0, ref __field_1,
                ref __field_2) =>
                LeafRegionConstraint::RegionOutlives {
                    0: ::core::clone::Clone::clone(__field_0),
                    1: ::core::clone::Clone::clone(__field_1),
                    2: ::core::clone::Clone::clone(__field_2),
                },
            LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __field_0,
                ref __field_1) =>
                LeafRegionConstraint::AliasTyOutlivesViaEnv {
                    0: ::core::clone::Clone::clone(__field_0),
                    1: ::core::clone::Clone::clone(__field_1),
                },
            LeafRegionConstraint::PlaceholderTyOutlives(ref __field_0,
                ref __field_1, ref __field_2) =>
                LeafRegionConstraint::PlaceholderTyOutlives {
                    0: ::core::clone::Clone::clone(__field_0),
                    1: ::core::clone::Clone::clone(__field_1),
                    2: ::core::clone::Clone::clone(__field_2),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::hash::Hash for
    LeafRegionConstraint<I, S> where I: Interner, S: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            LeafRegionConstraint::Ambiguity(ref __field_0) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
            }
            LeafRegionConstraint::RegionOutlives(ref __field_0, ref __field_1,
                ref __field_2) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
                ::core::hash::Hash::hash(__field_1, __state);
                ::core::hash::Hash::hash(__field_2, __state);
            }
            LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __field_0,
                ref __field_1) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
                ::core::hash::Hash::hash(__field_1, __state);
            }
            LeafRegionConstraint::PlaceholderTyOutlives(ref __field_0,
                ref __field_1, ref __field_2) => {
                ::core::hash::Hash::hash(&::core::mem::discriminant(self),
                    __state);
                ::core::hash::Hash::hash(__field_0, __state);
                ::core::hash::Hash::hash(__field_1, __state);
                ::core::hash::Hash::hash(__field_2, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::PartialEq for
    LeafRegionConstraint<I, S> where I: Interner, S: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        if ::core::mem::discriminant(self) ==
                ::core::mem::discriminant(__other) {
            match (self, __other) {
                (LeafRegionConstraint::Ambiguity(ref __field_0),
                    LeafRegionConstraint::Ambiguity(ref __other_field_0)) =>
                    true &&
                        ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
                (LeafRegionConstraint::RegionOutlives(ref __field_0,
                    ref __field_1, ref __field_2),
                    LeafRegionConstraint::RegionOutlives(ref __other_field_0,
                    ref __other_field_1, ref __other_field_2)) =>
                    true &&
                                ::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
                            ::core::cmp::PartialEq::eq(__field_1, __other_field_1) &&
                        ::core::cmp::PartialEq::eq(__field_2, __other_field_2),
                (LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __field_0,
                    ref __field_1),
                    LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __other_field_0,
                    ref __other_field_1)) =>
                    true &&
                            ::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
                        ::core::cmp::PartialEq::eq(__field_1, __other_field_1),
                (LeafRegionConstraint::PlaceholderTyOutlives(ref __field_0,
                    ref __field_1, ref __field_2),
                    LeafRegionConstraint::PlaceholderTyOutlives(ref __other_field_0,
                    ref __other_field_1, ref __other_field_2)) =>
                    true &&
                                ::core::cmp::PartialEq::eq(__field_0, __other_field_0) &&
                            ::core::cmp::PartialEq::eq(__field_1, __other_field_1) &&
                        ::core::cmp::PartialEq::eq(__field_2, __other_field_2),
                _ => unsafe { ::core::hint::unreachable_unchecked() },
            }
        } else { false }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner, S: Clone + std::fmt::Debug> DeriveWhereAssertEq for
            LeafRegionConstraint<I, S> where I: Interner, S: ::core::cmp::Eq {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<S>;
                let _: __AssertEq<Region<I>>;
                let _: __AssertEq<Region<I>>;
                let _: __AssertEq<S>;
                let _: __AssertEq<Binder<I, (AliasTy<I>, Region<I>)>>;
                let _: __AssertEq<S>;
                let _: __AssertEq<I::Ty>;
                let _: __AssertEq<Region<I>>;
                let _: __AssertEq<S>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::Eq for
    LeafRegionConstraint<I, S> where I: Interner, S: ::core::cmp::Eq {
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::fmt::Debug for
    LeafRegionConstraint<I, S> where I: Interner, S: ::core::fmt::Debug {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            LeafRegionConstraint::Ambiguity(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Ambiguity");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            LeafRegionConstraint::RegionOutlives(ref __field_0, ref __field_1,
                ref __field_2) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "RegionOutlives");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::field(&mut __builder, __field_1);
                ::core::fmt::DebugTuple::field(&mut __builder, __field_2);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __field_0,
                ref __field_1) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f,
                        "AliasTyOutlivesViaEnv");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::field(&mut __builder, __field_1);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
            LeafRegionConstraint::PlaceholderTyOutlives(ref __field_0,
                ref __field_1, ref __field_2) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f,
                        "PlaceholderTyOutlives");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::field(&mut __builder, __field_1);
                ::core::fmt::DebugTuple::field(&mut __builder, __field_2);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Hash, PartialEq, Eq, Debug; I: Interner, S)]
160#[derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeVisitable<I> for LeafRegionConstraint<I, S>
            where I: Interner, S: ::rustc_type_ir::TypeVisitable<I>,
            Region<I>: ::rustc_type_ir::TypeVisitable<I>,
            Binder<I,
            (AliasTy<I>, Region<I>)>: ::rustc_type_ir::TypeVisitable<I>,
            I::Ty: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    LeafRegionConstraint::Ambiguity(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    LeafRegionConstraint::RegionOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_2,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __binding_0,
                        ref __binding_1) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                    LeafRegionConstraint::PlaceholderTyOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_2,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, S: Clone + std::fmt::Debug, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            LeafRegionConstraint<I, S> where
            S: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            S: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Binder<I,
            (AliasTy<I>,
            Region<I>)>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            S: ::rustc_type_ir::GenericTypeVisitable<__V>,
            I::Ty: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Region<I>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            S: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    LeafRegionConstraint::Ambiguity(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                    LeafRegionConstraint::RegionOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
                                __visitor);
                        }
                    }
                    LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __binding_0,
                        ref __binding_1) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                    LeafRegionConstraint::PlaceholderTyOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_2,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeFoldable<I> for LeafRegionConstraint<I, S>
            where I: Interner, S: ::rustc_type_ir::TypeFoldable<I>,
            S: ::rustc_type_ir::TypeFoldable<I>,
            Region<I>: ::rustc_type_ir::TypeFoldable<I>,
            Binder<I,
            (AliasTy<I>, Region<I>)>: ::rustc_type_ir::TypeFoldable<I>,
            I::Ty: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        LeafRegionConstraint::Ambiguity(__binding_0) => {
                            LeafRegionConstraint::Ambiguity(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                        LeafRegionConstraint::RegionOutlives(__binding_0,
                            __binding_1, __binding_2) => {
                            LeafRegionConstraint::RegionOutlives(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
                                        __folder)?)
                        }
                        LeafRegionConstraint::AliasTyOutlivesViaEnv(__binding_0,
                            __binding_1) => {
                            LeafRegionConstraint::AliasTyOutlivesViaEnv(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?)
                        }
                        LeafRegionConstraint::PlaceholderTyOutlives(__binding_0,
                            __binding_1, __binding_2) => {
                            LeafRegionConstraint::PlaceholderTyOutlives(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                                ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_2,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    LeafRegionConstraint::Ambiguity(__binding_0) => {
                        LeafRegionConstraint::Ambiguity(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                    LeafRegionConstraint::RegionOutlives(__binding_0,
                        __binding_1, __binding_2) => {
                        LeafRegionConstraint::RegionOutlives(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
                                __folder))
                    }
                    LeafRegionConstraint::AliasTyOutlivesViaEnv(__binding_0,
                        __binding_1) => {
                        LeafRegionConstraint::AliasTyOutlivesViaEnv(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder))
                    }
                    LeafRegionConstraint::PlaceholderTyOutlives(__binding_0,
                        __binding_1, __binding_2) => {
                        LeafRegionConstraint::PlaceholderTyOutlives(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                            ::rustc_type_ir::TypeFoldable::fold_with(__binding_2,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
161#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_data_structures::stable_hash::StableHash for
            LeafRegionConstraint<I, S> where
            S: ::rustc_data_structures::stable_hash::StableHash,
            Region<I>: ::rustc_data_structures::stable_hash::StableHash,
            Binder<I,
            (AliasTy<I>,
            Region<I>)>: ::rustc_data_structures::stable_hash::StableHash,
            I::Ty: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    LeafRegionConstraint::Ambiguity(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    LeafRegionConstraint::RegionOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                    LeafRegionConstraint::AliasTyOutlivesViaEnv(ref __binding_0,
                        ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    LeafRegionConstraint::PlaceholderTyOutlives(ref __binding_0,
                        ref __binding_1, ref __binding_2) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
162pub enum LeafRegionConstraint<I: Interner, S: Clone + std::fmt::Debug = ()> {
163    Ambiguity(S),
164    RegionOutlives(Region<I>, Region<I>, S),
165    /// Requirement that a (potentially higher ranked) alias outlives some (potentially higher ranked)
166    /// region due to an assumption in the environment. This cannot be satisfied via component outlives
167    /// or item bounds.
168    ///
169    /// We cannot eagerly look at assumptions as we are usually working with an incomplete set of assumptions
170    /// and there may wind up being assumptions we can use to prove this when we're in a smaller universe.
171    ///
172    /// We eagerly destructure alias outlives requirements into region outlives requirements corresponding to
173    /// component outlives & item bound outlives rules, leaving only param env candidates.
174    AliasTyOutlivesViaEnv(Binder<I, (AliasTy<I>, Region<I>)>, S),
175    /// This is an `I::Ty` for two reasons:
176    /// 1. We need the type visitable impl to be able to `visit_ty` on this so canonicalization
177    ///    knows about the placeholder
178    /// 2. When exiting the trait solver there may be placeholder outlives corresponding to params
179    ///    from the root universe. These need to be changed from a `Placeholder` to the original
180    ///    `Param`.
181    ///
182    /// We cannot eagerly look at assumptions as we are usually working with an incomplete set of assumptions
183    /// and there may wind up being assumptions we can use to prove this when we're in a smaller universe.
184    PlaceholderTyOutlives(I::Ty, Region<I>, S),
185}
186
187impl<I: Interner> LeafRegionConstraint<I> {
188    pub fn with_span<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
189        self,
190        span: S,
191    ) -> LeafRegionConstraint<I, S> {
192        use LeafRegionConstraint::*;
193
194        match self {
195            Ambiguity(()) => Ambiguity(span),
196            RegionOutlives(r1, r2, ()) => RegionOutlives(r1, r2, span),
197            AliasTyOutlivesViaEnv(bound_outlives, ()) => {
198                AliasTyOutlivesViaEnv(bound_outlives, span)
199            }
200            PlaceholderTyOutlives(ty, r, ()) => PlaceholderTyOutlives(ty, r, span),
201        }
202    }
203}
204
205impl<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash> LeafRegionConstraint<I, S> {
206    pub fn without_span(self) -> LeafRegionConstraint<I> {
207        use LeafRegionConstraint::*;
208
209        match self {
210            Ambiguity(_) => Ambiguity(()),
211            RegionOutlives(r1, r2, _) => RegionOutlives(r1, r2, ()),
212            AliasTyOutlivesViaEnv(bound_outlives, _) => AliasTyOutlivesViaEnv(bound_outlives, ()),
213            PlaceholderTyOutlives(ty, r, _) => PlaceholderTyOutlives(ty, r, ()),
214        }
215    }
216
217    pub fn span(&self) -> S {
218        use LeafRegionConstraint::*;
219
220        let (Ambiguity(s)
221        | RegionOutlives(_, _, s)
222        | AliasTyOutlivesViaEnv(_, s)
223        | PlaceholderTyOutlives(_, _, s)) = self;
224        s.clone()
225    }
226}
227
228#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::clone::Clone for
    Or<I, S> where I: Interner, S: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            Or(ref __field_0) =>
                Or { 0: ::core::clone::Clone::clone(__field_0) },
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::hash::Hash for Or<I, S>
    where I: Interner, S: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            Or(ref __field_0) => {
                ::core::hash::Hash::hash(__field_0, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::PartialEq for
    Or<I, S> where I: Interner, S: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (Or(ref __field_0), Or(ref __other_field_0)) =>
                true &&
                    ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
        }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner, S: Clone + std::fmt::Debug> DeriveWhereAssertEq for
            Or<I, S> where I: Interner, S: ::core::cmp::Eq {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<Box<[And<I, S>]>>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::Eq for Or<I, S>
    where I: Interner, S: ::core::cmp::Eq {
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::fmt::Debug for Or<I, S>
    where I: Interner, S: ::core::fmt::Debug {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            Or(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "Or");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Hash, PartialEq, Eq, Debug; I: Interner, S)]
229#[derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeVisitable<I> for Or<I, S> where I: Interner,
            Box<[And<I, S>]>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    Or(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, S: Clone + std::fmt::Debug, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for Or<I, S> where
            Box<[And<I, S>]>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    Or(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeFoldable<I> for Or<I, S> where I: Interner,
            S: ::rustc_type_ir::TypeFoldable<I>,
            Box<[And<I, S>]>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        Or(__binding_0) => {
                            Or(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    Or(__binding_0) => {
                        Or(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
230#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_data_structures::stable_hash::StableHash for Or<I, S>
            where
            Box<[And<I, S>]>: ::rustc_data_structures::stable_hash::StableHash
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Or(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
231/// An OR of AND of LEAF constraints. Always in "canonical form" meaning:
232/// - No two ANDs are equivalent
233/// - All ANDs are in canonical form
234/// - If any AND is empty, i.e. trivially true, it is the only AND
235///
236/// FIXME(-Zassumptions-on-binders): We should consider a more general canonical form which also
237/// drops any AND that is a superset of another AND. Proving the superset requires strictly more
238/// than proving the subset, so it can never be the candidate which makes the OR hold. E.g.
239/// `OR(AND('a: 'b), AND('a: 'b, 'b: 'c))` really ought to just be `OR(AND('a: 'b))`. Only keeping
240/// an empty AND is the degenerate case of that rule.
241pub struct Or<I: Interner, S: Clone + std::fmt::Debug = ()>(pub Box<[And<I, S>]>);
242impl<I: Interner> Or<I> {
243    pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
244        self,
245        span: S,
246    ) -> Or<I, S> {
247        Or(self.0.into_iter().map(|and| and.with_spans(span.clone())).collect())
248    }
249}
250impl<I: Interner, S: Clone + std::hash::Hash + std::fmt::Debug + Eq> Or<I, S> {
251    pub fn new_true() -> Self {
252        Self(Box::new([And::new_true()]))
253    }
254
255    pub fn is_true(&self) -> bool {
256        // OR([AND([])])
257        if let [and] = &*self.0
258            && and.0.len() == 0
259        {
260            true
261        } else {
262            false
263        }
264    }
265
266    pub fn new_false() -> Self {
267        Self(Box::new([]))
268    }
269
270    pub fn is_false(&self) -> bool {
271        // OR([])
272        self.0.len() == 0
273    }
274
275    pub fn new(i: impl IntoIterator<Item = And<I, S>>) -> Self {
276        let ands = i.into_iter().collect::<Vec<_>>().into_boxed_slice();
277        let mut new_ands: Vec<And<I, S>> = Vec::new();
278
279        for and in ands {
280            // An empty AND is trivially true, which makes the whole OR true no matter what the
281            // other candidates are. `And::new` discards leaf constraints which are trivially
282            // true, so this is how e.g. a reflexive `'a: 'a` candidate discharges an OR.
283            if and.0.is_empty() {
284                return Self::new_true();
285            }
286
287            // FIXME(-Zassumptions-on-binders): We only discard an AND which is equivalent to one
288            // we already have. More generally we should discard any AND which is a superset of
289            // another, as it requires strictly more to hold. E.g. the second AND in
290            // `OR(AND('a: 'b), AND('a: 'b, 'b: 'c))` is never the one which makes the OR true.
291            if new_ands.iter().all(|c| !c.is_and_equivalent_to(&and)) {
292                new_ands.push(and)
293            }
294        }
295
296        Self(new_ands.into_boxed_slice())
297    }
298
299    pub fn new_ambig(s: S) -> Self {
300        Or::new_leaf(LeafRegionConstraint::Ambiguity(s))
301    }
302
303    pub fn new_leaf(l: LeafRegionConstraint<I, S>) -> Self {
304        Or::new([And::new([l])])
305    }
306
307    pub fn build_and(a: Or<I, S>, b: Or<I, S>) -> Self {
308        // FIXME(-Zassumptions-on-binders): probably bad for perf, doing a lot of reallocating
309        // and whatnot here :3
310
311        // Important: keeps `ands` empty if either `b_and` or `a_and` is empty
312        let mut ands = Vec::new();
313        for b_and in b.0 {
314            for a_and in a.0.clone().into_iter() {
315                ands.push(And::new(a_and.0.into_iter().chain(b_and.0.clone())))
316            }
317        }
318
319        Or::new(ands)
320    }
321
322    pub fn build_or(a: Or<I, S>, b: Or<I, S>) -> Self {
323        Or::new(a.0.into_iter().chain(b.0))
324    }
325
326    pub fn without_spans(self) -> Or<I> {
327        Or(self.0.into_iter().map(|and| and.without_spans()).collect())
328    }
329}
330
331#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::clone::Clone for
    And<I, S> where I: Interner, S: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            And(ref __field_0) =>
                And { 0: ::core::clone::Clone::clone(__field_0) },
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::hash::Hash for And<I, S>
    where I: Interner, S: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            And(ref __field_0) => {
                ::core::hash::Hash::hash(__field_0, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::PartialEq for
    And<I, S> where I: Interner, S: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (And(ref __field_0), And(ref __other_field_0)) =>
                true &&
                    ::core::cmp::PartialEq::eq(__field_0, __other_field_0),
        }
    }
}
const _: () =
    {
        trait DeriveWhereAssertEq {
            fn assert(&self);
        }
        impl<I: Interner, S: Clone + std::fmt::Debug> DeriveWhereAssertEq for
            And<I, S> where I: Interner, S: ::core::cmp::Eq {
            fn assert(&self) {
                struct __AssertEq<__T: ::core::cmp::Eq +
                    ?::core::marker::Sized>(::core::marker::PhantomData<__T>);
                let _: __AssertEq<Box<[LeafRegionConstraint<I, S>]>>;
            }
        }
    };
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::Eq for And<I, S>
    where I: Interner, S: ::core::cmp::Eq {
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::fmt::Debug for And<I, S>
    where I: Interner, S: ::core::fmt::Debug {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            And(ref __field_0) => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_tuple(__f, "And");
                ::core::fmt::DebugTuple::field(&mut __builder, __field_0);
                ::core::fmt::DebugTuple::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Hash, PartialEq, Eq, Debug; I: Interner, S)]
332#[derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeVisitable<I> for And<I, S> where I: Interner,
            Box<[LeafRegionConstraint<I,
            S>]>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    And(ref __binding_0) => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, S: Clone + std::fmt::Debug, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for And<I, S> where
            Box<[LeafRegionConstraint<I,
            S>]>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    And(ref __binding_0) => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeFoldable<I> for And<I, S> where I: Interner,
            S: ::rustc_type_ir::TypeFoldable<I>,
            Box<[LeafRegionConstraint<I,
            S>]>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        And(__binding_0) => {
                            And(::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?)
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    And(__binding_0) => {
                        And(::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder))
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
333#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_data_structures::stable_hash::StableHash for And<I, S>
            where
            Box<[LeafRegionConstraint<I,
            S>]>: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    And(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
334/// An AND of leaf constraints. Always in "canonical form", meaning:
335/// - No leaf constraints are present twice in this AND
336/// - No leaf constraint is trivially true, i.e. a reflexive `'a: 'a`
337pub struct And<I: Interner, S: Clone + std::fmt::Debug = ()>(pub Box<[LeafRegionConstraint<I, S>]>);
338impl<I: Interner> And<I> {
339    pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
340        self,
341        span: S,
342    ) -> And<I, S> {
343        And(self.0.into_iter().map(|leaf| leaf.with_span(span.clone())).collect())
344    }
345}
346impl<I: Interner, S: Clone + std::hash::Hash + std::fmt::Debug + Eq> And<I, S> {
347    pub fn new_true() -> Self {
348        Self(Box::new([]))
349    }
350
351    pub fn new(i: impl IntoIterator<Item = LeafRegionConstraint<I, S>>) -> Self {
352        let mut seen = IndexSet::new();
353        And(i
354            .into_iter()
355            .filter(|leaf| {
356                // Outlives is reflexive so a `'a: 'a` leaf is always true and carries no
357                // information. Dropping it here keeps the rest of the code from having to special
358                // case it, and is what lets an OR with a reflexive candidate be recognized as true.
359                if let LeafRegionConstraint::RegionOutlives(r1, r2, _) = leaf
360                    && r1 == r2
361                {
362                    return false;
363                }
364
365                if seen.contains(&leaf.clone().without_span()) {
366                    false
367                } else {
368                    seen.insert(leaf.clone().without_span());
369                    true
370                }
371            })
372            .collect())
373    }
374
375    fn is_and_equivalent_to(&self, other: &And<I, S>) -> bool {
376        let this = self.clone().0;
377        let other = other.clone().0;
378
379        this.iter()
380            .all(|c1| other.iter().any(|c2| c1.clone().without_span() == c2.clone().without_span()))
381            && other.iter().all(|c2| {
382                this.iter().any(|c1| c1.clone().without_span() == c2.clone().without_span())
383            })
384    }
385
386    pub fn without_spans(self) -> And<I> {
387        And(self.0.into_iter().map(|leaf| leaf.without_span()).collect())
388    }
389}
390
391#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::clone::Clone for
    RegionConstraint<I, S> where I: Interner, S: ::core::clone::Clone {
    #[inline]
    fn clone(&self) -> Self {
        match self {
            RegionConstraint {
                and_constraint: ref __field_and_constraint,
                or_constraint: ref __field_or_constraint } =>
                RegionConstraint {
                    and_constraint: ::core::clone::Clone::clone(__field_and_constraint),
                    or_constraint: ::core::clone::Clone::clone(__field_or_constraint),
                },
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::hash::Hash for
    RegionConstraint<I, S> where I: Interner, S: ::core::hash::Hash {
    fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
        match self {
            RegionConstraint {
                and_constraint: ref __field_and_constraint,
                or_constraint: ref __field_or_constraint } => {
                ::core::hash::Hash::hash(__field_and_constraint, __state);
                ::core::hash::Hash::hash(__field_or_constraint, __state);
            }
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::cmp::PartialEq for
    RegionConstraint<I, S> where I: Interner, S: ::core::cmp::PartialEq {
    #[inline]
    fn eq(&self, __other: &Self) -> ::core::primitive::bool {
        match (self, __other) {
            (RegionConstraint {
                and_constraint: ref __field_and_constraint,
                or_constraint: ref __field_or_constraint }, RegionConstraint {
                and_constraint: ref __other_field_and_constraint,
                or_constraint: ref __other_field_or_constraint }) =>
                true &&
                        ::core::cmp::PartialEq::eq(__field_and_constraint,
                            __other_field_and_constraint) &&
                    ::core::cmp::PartialEq::eq(__field_or_constraint,
                        __other_field_or_constraint),
        }
    }
}
#[automatically_derived]
impl<I: Interner, S: Clone + std::fmt::Debug> ::core::fmt::Debug for
    RegionConstraint<I, S> where I: Interner, S: ::core::fmt::Debug {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            RegionConstraint {
                and_constraint: ref __field_and_constraint,
                or_constraint: ref __field_or_constraint } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f,
                        "RegionConstraint");
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "and_constraint", __field_and_constraint);
                ::core::fmt::DebugStruct::field(&mut __builder,
                    "or_constraint", __field_or_constraint);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Clone, Hash, PartialEq, Debug; I: Interner, S)]
392#[derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeVisitable<I> for RegionConstraint<I, S> where
            I: Interner, And<I, S>: ::rustc_type_ir::TypeVisitable<I>,
            Or<I, S>: ::rustc_type_ir::TypeVisitable<I> {
            fn visit_with<__V: ::rustc_type_ir::TypeVisitor<I>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    RegionConstraint {
                        and_constraint: ref __binding_0,
                        or_constraint: ref __binding_1 } => {
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_type_ir::VisitorResult::branch(::rustc_type_ir::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_type_ir::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_type_ir::VisitorResult>::output()
            }
        }
    };TypeVisitable_Generic, const _: () =
    {
        unsafe impl<I: Interner, S: Clone + std::fmt::Debug, __V>
            ::rustc_type_ir::GenericTypeVisitable<__V> for
            RegionConstraint<I, S> where
            And<I, S>: ::rustc_type_ir::GenericTypeVisitable<__V>,
            Or<I, S>: ::rustc_type_ir::GenericTypeVisitable<__V> {
            fn generic_visit_with(&self, __visitor: &mut __V) {
                match *self {
                    RegionConstraint {
                        and_constraint: ref __binding_0,
                        or_constraint: ref __binding_1 } => {
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_0,
                                __visitor);
                        }
                        {
                            ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(__binding_1,
                                __visitor);
                        }
                    }
                }
            }
        }
    };GenericTypeVisitable, const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_type_ir::TypeFoldable<I> for RegionConstraint<I, S> where
            I: Interner, S: ::rustc_type_ir::TypeFoldable<I>,
            And<I, S>: ::rustc_type_ir::TypeFoldable<I>,
            Or<I, S>: ::rustc_type_ir::TypeFoldable<I> {
            fn try_fold_with<__F: ::rustc_type_ir::FallibleTypeFolder<I>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        RegionConstraint {
                            and_constraint: __binding_0, or_constraint: __binding_1 } =>
                            {
                            RegionConstraint {
                                and_constraint: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                or_constraint: ::rustc_type_ir::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_type_ir::TypeFolder<I>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    RegionConstraint {
                        and_constraint: __binding_0, or_constraint: __binding_1 } =>
                        {
                        RegionConstraint {
                            and_constraint: ::rustc_type_ir::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            or_constraint: ::rustc_type_ir::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable_Generic)]
393#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl<I: Interner, S: Clone + std::fmt::Debug>
            ::rustc_data_structures::stable_hash::StableHash for
            RegionConstraint<I, S> where
            And<I, S>: ::rustc_data_structures::stable_hash::StableHash,
            Or<I, S>: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    RegionConstraint {
                        and_constraint: ref __binding_0,
                        or_constraint: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash_NoContext))]
394/// An `And` and an `Or` constraint both in canonical forms, with two additional constraints:
395/// - If the `or_constraint` is false then the `and_constraint` is empty
396/// - The `or_constraint` does not have any constraints present in all of its inner `And`s
397///    - i.e. `OR ( AND ('a: 'b, 'b: 'c), AND ('a: 'b, 'b: 'd))` is not a thing
398/// - The OR constraint is in canonical form
399/// - The AND constraint is in canonical form
400///
401/// This should be thought of as an AND consisting of a set of LEAF constraints as well
402/// as a single OR constraint.
403pub struct RegionConstraint<I: Interner, S: Clone + std::fmt::Debug = ()> {
404    pub and_constraint: And<I, S>,
405    pub or_constraint: Or<I, S>,
406}
407
408impl<I: Interner> RegionConstraint<I> {
409    pub fn with_spans<S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
410        self,
411        span: S,
412    ) -> RegionConstraint<I, S> {
413        RegionConstraint {
414            and_constraint: self.and_constraint.with_spans(span.clone()),
415            or_constraint: self.or_constraint.with_spans(span.clone()),
416        }
417    }
418}
419impl<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash> RegionConstraint<I, S> {
420    pub fn new_from_or(or: Or<I, S>) -> Self {
421        let Some(fst) = or.0.get(0).clone() else {
422            return RegionConstraint::new_false();
423        };
424        let mut and_constraint = fst.0.to_vec();
425
426        for and in or.0.split_first().unwrap().1 {
427            and_constraint.retain(|c| {
428                and.0.iter().any(|c2| c.clone().without_span() == c2.clone().without_span())
429            });
430        }
431        let and_constraint = And::new(and_constraint);
432
433        let or_constraint = Or::new(or.0.into_iter().map(|and| {
434            And::new(and.0.into_iter().filter(|c| {
435                and_constraint
436                    .0
437                    .iter()
438                    .all(|s_c| c.clone().without_span() != s_c.clone().without_span())
439            }))
440        }));
441
442        Self {
443            and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
444            or_constraint,
445        }
446    }
447
448    pub fn splatted_and_constraints(&self) -> Or<I, S> {
449        Or::new(self.or_constraint.0.iter().map(|and| {
450            And::new(and.0.iter().cloned().chain(self.and_constraint.0.iter().cloned()))
451        }))
452    }
453
454    pub fn build_and(a: RegionConstraint<I, S>, b: RegionConstraint<I, S>) -> Self {
455        let and_constraint = And::new(a.and_constraint.0.into_iter().chain(b.and_constraint.0));
456        let or_constraint = Or::build_and(a.or_constraint, b.or_constraint);
457
458        Self {
459            and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
460            or_constraint,
461        }
462    }
463
464    pub fn build_or(a: RegionConstraint<I, S>, b: RegionConstraint<I, S>) -> Self {
465        Self::new_from_or(Or::build_or(a.splatted_and_constraints(), b.splatted_and_constraints()))
466    }
467
468    pub fn new_true() -> Self {
469        Self { and_constraint: And::new_true(), or_constraint: Or::new_true() }
470    }
471
472    pub fn is_true(&self) -> bool {
473        self.and_constraint.0.is_empty() && self.or_constraint.is_true()
474    }
475
476    pub fn new_false() -> Self {
477        Self { and_constraint: And::new_true(), or_constraint: Or::new_false() }
478    }
479
480    pub fn is_false(&self) -> bool {
481        self.or_constraint.is_false()
482    }
483
484    pub fn new_ambig(span: S) -> Self {
485        Self {
486            and_constraint: And::new([LeafRegionConstraint::Ambiguity(span)]),
487            or_constraint: Or::new_true(),
488        }
489    }
490
491    pub fn is_ambig(&self) -> bool {
492        if let [c] = &*self.and_constraint.0
493            && c.is_ambig()
494            && self.or_constraint.is_true()
495        {
496            true
497        } else {
498            false
499        }
500    }
501
502    pub fn without_spans(self) -> RegionConstraint<I> {
503        RegionConstraint {
504            and_constraint: self.and_constraint.without_spans(),
505            or_constraint: self.or_constraint.without_spans(),
506        }
507    }
508
509    pub fn new_leaf(l: LeafRegionConstraint<I, S>) -> Self {
510        RegionConstraint { and_constraint: And::new([l]), or_constraint: Or::new_true() }
511    }
512}
513
514impl<I: Interner, S: Clone + std::fmt::Debug> LeafRegionConstraint<I, S> {
515    pub fn is_ambig(&self) -> bool {
516        #[allow(non_exhaustive_omitted_patterns)] match self {
    Self::Ambiguity(_) => true,
    _ => false,
}matches!(self, Self::Ambiguity(_))
517    }
518}
519
520/// Takes any constraints involving placeholders from the current universe and eagerly checks them.
521/// This can be done a few ways:
522/// - There's an assumption on the binder introducing the placeholder which means the constraint is satisfied (true)
523/// - There's assumptions on the binder introducing the placeholder which allow us to rewrite the constraint in
524///    terms of lower universe variables. For example given `for<'a> where('b: 'a) { prove(T: '!a_u1) }` we can
525///    convert this constraint to `T: 'b` which no longer references anything from `u1`.
526/// - There are no relevant assumptions so we can neither rewrite the constraint nor consider it satisfied (false)
527/// - We failed to compute the full set of assumptions when entering the binder corresponding to `u`. (ambiguity)
528///
529/// After handling all of the region constraints in `u` we then evaluate the entire constraint as much as possible,
530/// propagating true/false/ambiguity as close to the root of the constraint as we can. The returned constraint should
531/// be checked for whether it is true/false/ambiguous as that should affect the result of whatever operation required
532/// entering the binder corresponding to `u`.
533{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("eagerly_handle_placeholders_in_universe",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(533u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let assumptions = infcx.get_placeholder_assumptions(u);
                        let constraint =
                            rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
                                constraint, u, &assumptions);
                        let constraint =
                            compute_new_region_constraints(infcx, constraint, u);
                        let constraint =
                            pull_region_outlives_constraints_out_of_universe(infcx,
                                constraint, u, &assumptions);
                        constraint
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:533",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(533u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
534pub fn eagerly_handle_placeholders_in_universe<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
535    infcx: &Infcx,
536    constraint: RegionConstraint<I>,
537    u: UniverseIndex,
538) -> RegionConstraint<I> {
539    let assumptions = infcx.get_placeholder_assumptions(u);
540
541    // 1. rewrite type outlives constraints involving things from `u` into either region constraints
542    //     involving things from `u` or type outlives constraints not involving things from `u`
543    //
544    //    IOW, we only want to encounter things from `u` as part of region out lives constraints.
545    let constraint = rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling(
546        infcx,
547        constraint,
548        u,
549        &assumptions,
550    );
551
552    // 2. compute transitive region outlives and get a new set of region outlives constraints by
553    //     looking for every region which either a placeholder_u flows into it, or it flows into
554    //     the placeholder.
555    let constraint = compute_new_region_constraints(infcx, constraint, u);
556
557    // 3. rewrite region outlives constraints (potentially to false/true)
558    let constraint =
559        pull_region_outlives_constraints_out_of_universe(infcx, constraint, u, &assumptions);
560
561    constraint
562}
563
564/// Filter our region constraints to not include constraints between region variables from `u` and
565/// other regions as those are always satisfied. This requires some care to handle correctly for example:
566/// `'!a_u1: '?x_u1: '!b_u1` should result in us requiring `'!a_u1: '!b_u1` rather than dropping the two
567/// constraints entirely.
568///
569/// The only constraints involving things from `u` should be region outlives constraints at this point. Type
570/// outlives constraints should have been handled already either by destructuring into region outlives or by
571/// being rewritten in terms of smaller universe variables.
572{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("compute_new_region_constraints",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(572u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        use LeafRegionConstraint::*;
                        let extend_from_and =
                            |builder: &mut TransitiveRelationBuilder<_>,
                                regions: &mut IndexSet<_>, constraints: &mut Vec<_>,
                                and: &And<I>|
                                {
                                    for c in &and.0 {
                                        match c {
                                            Ambiguity(()) | PlaceholderTyOutlives(..) |
                                                AliasTyOutlivesViaEnv(..) => {
                                                constraints.push(c.clone())
                                            }
                                            RegionOutlives(r1, r2, ()) => {
                                                regions.insert(*r1);
                                                regions.insert(*r2);
                                                builder.add(*r2, *r1);
                                            }
                                        }
                                    }
                                };
                        let mut base_region_flows_builder =
                            TransitiveRelationBuilder::default();
                        let mut base_regions = IndexSet::new();
                        let mut base_constraints = Vec::new();
                        extend_from_and(&mut base_region_flows_builder,
                            &mut base_regions, &mut base_constraints,
                            &constraint.and_constraint);
                        let mut new_ands = Vec::new();
                        for and in &constraint.or_constraint.0 {
                            let mut region_flows_builder =
                                base_region_flows_builder.clone();
                            let mut regions = base_regions.clone();
                            let mut constraints = base_constraints.clone();
                            extend_from_and(&mut region_flows_builder, &mut regions,
                                &mut constraints, and);
                            let region_flow = region_flows_builder.freeze();
                            for r in regions.into_iter() {
                                for ub in region_flow.reachable_from(r) {
                                    let is_placeholder_like =
                                        |r: Region<I>|
                                            match r.kind() {
                                                RegionKind::ReLateParam(..) | RegionKind::ReEarlyParam(..) |
                                                    RegionKind::RePlaceholder(..) | RegionKind::ReStatic =>
                                                    true,
                                                RegionKind::ReVar(..) => max_universe(infcx, r) < u,
                                                RegionKind::ReError(..) => false,
                                                RegionKind::ReErased | RegionKind::ReBound(..) =>
                                                    ::core::panicking::panic("internal error: entered unreachable code"),
                                            };
                                    if is_placeholder_like(r) && is_placeholder_like(ub) {
                                        constraints.push(RegionOutlives(ub, r, ()));
                                    }
                                }
                            }
                            new_ands.push(Or::new([And::new(constraints)]))
                        }
                        RegionConstraint::new_from_or(new_ands.into_iter().fold(Or::new_false(),
                                |acc, c| Or::build_or(acc, c)))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:572",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(572u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
573fn compute_new_region_constraints<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
574    infcx: &Infcx,
575    constraint: RegionConstraint<I>,
576    u: UniverseIndex,
577) -> RegionConstraint<I> {
578    use LeafRegionConstraint::*;
579
580    let extend_from_and = |builder: &mut TransitiveRelationBuilder<_>,
581                           regions: &mut IndexSet<_>,
582                           constraints: &mut Vec<_>,
583                           and: &And<I>| {
584        for c in &and.0 {
585            match c {
586                Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
587                    constraints.push(c.clone())
588                }
589                RegionOutlives(r1, r2, ()) => {
590                    regions.insert(*r1);
591                    regions.insert(*r2);
592                    builder.add(*r2, *r1);
593                }
594            }
595        }
596    };
597
598    let mut base_region_flows_builder = TransitiveRelationBuilder::default();
599    let mut base_regions = IndexSet::new();
600    let mut base_constraints = Vec::new();
601    extend_from_and(
602        &mut base_region_flows_builder,
603        &mut base_regions,
604        &mut base_constraints,
605        &constraint.and_constraint,
606    );
607
608    let mut new_ands = Vec::new();
609    for and in &constraint.or_constraint.0 {
610        let mut region_flows_builder = base_region_flows_builder.clone();
611        let mut regions = base_regions.clone();
612        let mut constraints = base_constraints.clone();
613        extend_from_and(&mut region_flows_builder, &mut regions, &mut constraints, and);
614
615        let region_flow = region_flows_builder.freeze();
616        for r in regions.into_iter() {
617            for ub in region_flow.reachable_from(r) {
618                // we want to retain any region constraints between two "placeholder-likes" where for our
619                // purposes a placeholder-like is either a placeholder or variable in a lower universe
620                let is_placeholder_like = |r: Region<I>| match r.kind() {
621                    RegionKind::ReLateParam(..)
622                    | RegionKind::ReEarlyParam(..)
623                    | RegionKind::RePlaceholder(..)
624                    | RegionKind::ReStatic => true,
625                    RegionKind::ReVar(..) => max_universe(infcx, r) < u,
626                    RegionKind::ReError(..) => false,
627                    RegionKind::ReErased | RegionKind::ReBound(..) => unreachable!(),
628                };
629
630                if is_placeholder_like(r) && is_placeholder_like(ub) {
631                    constraints.push(RegionOutlives(ub, r, ()));
632                }
633            }
634        }
635
636        new_ands.push(Or::new([And::new(constraints)]))
637    }
638
639    // FIXME(-Zassumptions-on-binders): probably bad for perf!
640    RegionConstraint::new_from_or(
641        new_ands.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c)),
642    )
643}
644
645/// Handles converting region outlives constraints involving placeholders from `u` into OR constraints
646/// involving regions from smaller universes with known relationships to the placeholder. For example:
647/// ```ignore (not rust)
648/// for<'a, 'b> where(
649///     'c: 'b, 'd: 'b,
650///     'a: 'e, 'a: 'f,
651/// ) {
652///     'a_u1: 'b_u1
653/// }
654/// ```
655/// will get converted to:
656/// ```ignore (not rust)
657/// OR(
658///     'e: 'c,
659///     'e: 'd,
660///     'f: 'c,
661///     'f: 'd,
662/// )
663/// ```
664/// if we are handling constraints in `u1`.
665{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("pull_region_outlives_constraints_out_of_universe",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(665u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assumptions")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assumptions");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if !(max_universe(infcx, constraint.clone()) <= u) {
                            ::core::panicking::panic("assertion failed: max_universe(infcx, constraint.clone()) <= u")
                        };
                        use LeafRegionConstraint::*;
                        let pull_and =
                            |and: And<I>|
                                {
                                    let mut pulled_constraints = Vec::new();
                                    for c in and.0 {
                                        match c {
                                            Ambiguity(()) | PlaceholderTyOutlives(..) |
                                                AliasTyOutlivesViaEnv(..) => {
                                                if !(max_universe(infcx, c.clone()) < u) {
                                                    ::core::panicking::panic("assertion failed: max_universe(infcx, c.clone()) < u")
                                                };
                                                pulled_constraints.push(Or::new_leaf(c.clone()));
                                            }
                                            RegionOutlives(region_1, region_2, ()) => {
                                                let region_1_u = max_universe(infcx, region_1);
                                                let region_2_u = max_universe(infcx, region_2);
                                                if region_1_u != u && region_2_u != u {
                                                    pulled_constraints.push(Or::new_leaf(c));
                                                    continue;
                                                }
                                                if regions_outlived_by(region_1,
                                                            assumptions).any(|r| r == region_2) {
                                                    continue;
                                                }
                                                let mut candidates = ::alloc::vec::Vec::new();
                                                for ub in
                                                    regions_outlived_by(region_1,
                                                            assumptions).filter(|r| max_universe(infcx, *r) < u) {
                                                    for lb in
                                                        regions_outliving(region_2, assumptions,
                                                                infcx.cx()).filter(|r| max_universe(infcx, *r) < u) {
                                                        candidates.push(RegionOutlives(ub, lb, ()));
                                                    }
                                                }
                                                pulled_constraints.push(Or::new(candidates.into_iter().map(|c|
                                                                And::new([c]))));
                                            }
                                        };
                                    }
                                    pulled_constraints.into_iter().fold(Or::new_true(),
                                        |acc, c| Or::build_and(acc, c))
                                };
                        let and_constraint = pull_and(constraint.and_constraint);
                        let or_constraint =
                            constraint.or_constraint.0.into_iter().fold(Or::new_false(),
                                |acc, c| Or::build_or(acc, pull_and(c)));
                        RegionConstraint::new_from_or(Or::build_and(and_constraint,
                                or_constraint))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:665",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(665u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
666fn pull_region_outlives_constraints_out_of_universe<
667    Infcx: InferCtxtLike<Interner = I>,
668    I: Interner,
669>(
670    infcx: &Infcx,
671    constraint: RegionConstraint<I>,
672    u: UniverseIndex,
673    assumptions: &Assumptions<I>,
674) -> RegionConstraint<I> {
675    assert!(max_universe(infcx, constraint.clone()) <= u);
676
677    // FIXME(-Zassumptions-on-binders): we don't lower universes of region variables when exiting `u`
678    // this seems dubious/potentially wrong? we can't just blindly do this though as if we had something
679    // like `!T_u -> ?x_u -> !U_u` then lowering `?x` to `u-1` when exiting `u` would be wrong.
680    //
681    // I'm not even sure this would be necessary given we filter out region constraints involving regions#
682    // from the current universe and only retain those between placeholders.
683
684    use LeafRegionConstraint::*;
685
686    let pull_and = |and: And<I>| {
687        let mut pulled_constraints = Vec::new();
688        for c in and.0 {
689            match c {
690                Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
691                    assert!(max_universe(infcx, c.clone()) < u);
692                    pulled_constraints.push(Or::new_leaf(c.clone()));
693                }
694                RegionOutlives(region_1, region_2, ()) => {
695                    let region_1_u = max_universe(infcx, region_1);
696                    let region_2_u = max_universe(infcx, region_2);
697
698                    if region_1_u != u && region_2_u != u {
699                        pulled_constraints.push(Or::new_leaf(c));
700                        continue;
701                    }
702
703                    // The constraint may already be entailed by the assumptions of the binder we are
704                    // leaving, e.g. `for<'a, 'b> where 'b: 'a { 'b: 'a }`. There is nothing to lift into
705                    // a smaller universe in that case, and looking for lower universe candidates would
706                    // wrongly result in `Or([])` whenever the placeholders have no lower universe bounds.
707                    if regions_outlived_by(region_1, assumptions).any(|r| r == region_2) {
708                        continue;
709                    }
710
711                    let mut candidates = vec![];
712
713                    for ub in regions_outlived_by(region_1, assumptions)
714                        .filter(|r| max_universe(infcx, *r) < u)
715                    {
716                        // FIXME(-Zassumptions-on-binders): if `region_2` is in a smaller universe there'll be both
717                        // `'region_2` and `'static` as lower bounds which seems... unfortunate and may cause us to
718                        // add a bunch of duplicate `'ub: 'static` candidates the more binders we leave.
719                        for lb in regions_outliving(region_2, assumptions, infcx.cx())
720                            .filter(|r| max_universe(infcx, *r) < u)
721                        {
722                            // As long as any region outlived by `region_1` outlives any region region which
723                            // `region_2` outlives, we know that `region_1: region_2` holds. In other words,
724                            // there exists some set of 4 regions for which `'r1: 'i1` `'i1: 'i2` `'i2: 'r2`
725                            candidates.push(RegionOutlives(ub, lb, ()));
726                        }
727                    }
728
729                    pulled_constraints.push(Or::new(candidates.into_iter().map(|c| And::new([c]))));
730                }
731            };
732        }
733
734        pulled_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
735    };
736
737    let and_constraint = pull_and(constraint.and_constraint);
738    let or_constraint = constraint
739        .or_constraint
740        .0
741        .into_iter()
742        .fold(Or::new_false(), |acc, c| Or::build_or(acc, pull_and(c)));
743    RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
744}
745
746/// Converts type outlives constraints into region outlives constraints. This assumes the *complete* set of
747/// assumptions are known. This should not be called until the end of type checking.
748///
749/// The returned region constraint will not have *any* PlaceholderTyOutlives or AliasTyOutlivesViaEnv constraints.
750{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("destructure_type_outlives_constraints_in_root",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(750u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assumptions")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assumptions");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I, S> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        use LeafRegionConstraint::*;
                        let destructure_and =
                            |and: &And<I, S>|
                                {
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:763",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(763u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                                            ::tracing_core::field::FieldSet::new(&["message"],
                                                                ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                            ::tracing::metadata::Kind::EVENT)
                                                    };
                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                            };
                                        let enabled =
                                            ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                    ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                {
                                                    let interest = __CALLSITE.interest();
                                                    !interest.is_never() &&
                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                            interest)
                                                };
                                        if enabled {
                                            (|value_set: ::tracing::field::ValueSet|
                                                        {
                                                            let meta = __CALLSITE.metadata();
                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                            ;
                                                        })({
                                                    #[allow(unused_imports)]
                                                    use ::tracing::field::{debug, display, Value};
                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("rewriting and: {0:?}",
                                                                                        and) as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    let mut destructured_constraints = Vec::new();
                                    for c in &and.0 {
                                        match c {
                                            Ambiguity(_) | RegionOutlives(..) => {
                                                destructured_constraints.push(Or::new_leaf(c.clone()))
                                            }
                                            PlaceholderTyOutlives(ty, r, span) =>
                                                destructured_constraints.push(Or::new(regions_outlived_by_placeholder(*ty,
                                                                assumptions,
                                                                infcx.cx()).map(move |assumption_r|
                                                                {
                                                                    And::new([RegionOutlives(assumption_r, *r, span.clone())])
                                                                }))),
                                            AliasTyOutlivesViaEnv(bound_outlives, span) => {
                                                destructured_constraints.push(alias_outlives_candidates_from_assumptions(infcx,
                                                            *bound_outlives, assumptions).with_spans(span.clone()));
                                            }
                                        }
                                    }
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:789",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(789u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                                            ::tracing_core::field::FieldSet::new(&[{
                                                                                const NAME:
                                                                                    ::tracing::__macro_support::FieldName<{
                                                                                        ::tracing::__macro_support::FieldName::len("destructured_constraints")
                                                                                    }> =
                                                                                    ::tracing::__macro_support::FieldName::new("destructured_constraints");
                                                                                NAME.as_str()
                                                                            }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                            ::tracing::metadata::Kind::EVENT)
                                                    };
                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                            };
                                        let enabled =
                                            ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                    ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                {
                                                    let interest = __CALLSITE.interest();
                                                    !interest.is_never() &&
                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                            interest)
                                                };
                                        if enabled {
                                            (|value_set: ::tracing::field::ValueSet|
                                                        {
                                                            let meta = __CALLSITE.metadata();
                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                            ;
                                                        })({
                                                    #[allow(unused_imports)]
                                                    use ::tracing::field::{debug, display, Value};
                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&destructured_constraints)
                                                                                as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    let merged_constraints =
                                        destructured_constraints.into_iter().fold(Or::new_true(),
                                            |acc, c| Or::build_and(acc, c));
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:793",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(793u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                                            ::tracing_core::field::FieldSet::new(&[{
                                                                                const NAME:
                                                                                    ::tracing::__macro_support::FieldName<{
                                                                                        ::tracing::__macro_support::FieldName::len("merged_constraints")
                                                                                    }> =
                                                                                    ::tracing::__macro_support::FieldName::new("merged_constraints");
                                                                                NAME.as_str()
                                                                            }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                            ::tracing::metadata::Kind::EVENT)
                                                    };
                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                            };
                                        let enabled =
                                            ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                    ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                {
                                                    let interest = __CALLSITE.interest();
                                                    !interest.is_never() &&
                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                            interest)
                                                };
                                        if enabled {
                                            (|value_set: ::tracing::field::ValueSet|
                                                        {
                                                            let meta = __CALLSITE.metadata();
                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                            ;
                                                        })({
                                                    #[allow(unused_imports)]
                                                    use ::tracing::field::{debug, display, Value};
                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&merged_constraints)
                                                                                as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    merged_constraints
                                };
                        let and_constraint =
                            destructure_and(&constraint.and_constraint);
                        let or_constraint =
                            constraint.or_constraint.0.into_iter().fold(Or::new_false(),
                                |acc, c| Or::build_or(acc, destructure_and(&c)));
                        RegionConstraint::new_from_or(Or::build_and(and_constraint,
                                or_constraint))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:750",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(750u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
751pub fn destructure_type_outlives_constraints_in_root<
752    Infcx: InferCtxtLike<Interner = I>,
753    I: Interner,
754    S: Clone + std::fmt::Debug + Eq + std::hash::Hash,
755>(
756    infcx: &Infcx,
757    constraint: RegionConstraint<I, S>,
758    assumptions: &Assumptions<I>,
759) -> RegionConstraint<I, S> {
760    use LeafRegionConstraint::*;
761
762    let destructure_and = |and: &And<I, S>| {
763        debug!("rewriting and: {:?}", and);
764        let mut destructured_constraints = Vec::new();
765        for c in &and.0 {
766            match c {
767                Ambiguity(_) | RegionOutlives(..) => {
768                    destructured_constraints.push(Or::new_leaf(c.clone()))
769                }
770                PlaceholderTyOutlives(ty, r, span) => destructured_constraints.push(Or::new(
771                    regions_outlived_by_placeholder(*ty, assumptions, infcx.cx()).map(
772                        move |assumption_r| {
773                            And::new([RegionOutlives(assumption_r, *r, span.clone())])
774                        },
775                    ),
776                )),
777                AliasTyOutlivesViaEnv(bound_outlives, span) => {
778                    destructured_constraints.push(
779                        alias_outlives_candidates_from_assumptions(
780                            infcx,
781                            *bound_outlives,
782                            assumptions,
783                        )
784                        .with_spans(span.clone()),
785                    );
786                }
787            }
788        }
789        debug!(?destructured_constraints);
790        let merged_constraints = destructured_constraints
791            .into_iter()
792            .fold(Or::new_true(), |acc, c| Or::build_and(acc, c));
793        debug!(?merged_constraints);
794        merged_constraints
795    };
796
797    let and_constraint = destructure_and(&constraint.and_constraint);
798    let or_constraint = constraint
799        .or_constraint
800        .0
801        .into_iter()
802        .fold(Or::new_false(), |acc, c| Or::build_or(acc, destructure_and(&c)));
803
804    RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
805}
806
807/// Converts type outlives constraints into either region outlives constraints, or type outlives
808/// constraints which do not contain anything from `u`.
809///
810/// This only works off assumptions associated with the binder corresponding to `u` both for
811/// perf reasons and because the full set of region assumptions is not known during type checking
812/// due to closure signature inference.
813///
814/// This only really causes problems for higher-ranked outlives assumptions, for example if we have
815/// `where for<'a> <T as Trait<'a>>::Assoc: 'b` then we can't use that to prove `<T as Trait<'!c>>::Assoc: 'b`
816/// until we are in the root context. See comments inside this function for more detail.
817{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(817u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assumptions")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assumptions");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        use LeafRegionConstraint::*;
                        if !(max_universe(infcx, constraint.clone()) <= u) {
                            {
                                ::core::panicking::panic_fmt(format_args!("constraint {0:?} contains terms from a larger universe than {1:?}",
                                        constraint.clone(), u));
                            }
                        };
                        let rewrite_and =
                            |and: And<I>|
                                {
                                    let mut rewritten_constraints = Vec::new();
                                    for c in and.0 {
                                        match c {
                                            Ambiguity(()) | RegionOutlives(..) =>
                                                rewritten_constraints.push(Or::new_leaf(c)),
                                            PlaceholderTyOutlives(ty, region, ()) => {
                                                rewritten_constraints.push(rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
                                                        ty, region, u, assumptions));
                                            }
                                            AliasTyOutlivesViaEnv(bound_outlives, ()) => {
                                                rewritten_constraints.push(rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
                                                        bound_outlives, u, assumptions));
                                            }
                                        }
                                    }
                                    rewritten_constraints.into_iter().fold(Or::new_true(),
                                        |acc, c| Or::build_and(acc, c))
                                };
                        let and_constraint = rewrite_and(constraint.and_constraint);
                        let or_constraint =
                            constraint.or_constraint.0.into_iter().fold(Or::new_false(),
                                |acc, c| Or::build_or(acc, rewrite_and(c)));
                        RegionConstraint::new_from_or(Or::build_and(and_constraint,
                                or_constraint))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:817",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(817u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
818fn rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling<
819    Infcx: InferCtxtLike<Interner = I>,
820    I: Interner,
821>(
822    infcx: &Infcx,
823    constraint: RegionConstraint<I>,
824    u: UniverseIndex,
825    assumptions: &Assumptions<I>,
826) -> RegionConstraint<I> {
827    use LeafRegionConstraint::*;
828
829    assert!(
830        max_universe(infcx, constraint.clone()) <= u,
831        "constraint {:?} contains terms from a larger universe than {:?}",
832        constraint.clone(),
833        u
834    );
835
836    let rewrite_and = |and: And<I>| {
837        let mut rewritten_constraints = Vec::new();
838        for c in and.0 {
839            match c {
840                Ambiguity(()) | RegionOutlives(..) => rewritten_constraints.push(Or::new_leaf(c)),
841                PlaceholderTyOutlives(ty, region, ()) => {
842                    rewritten_constraints.push(rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, ty, region, u, assumptions));
843                }
844                AliasTyOutlivesViaEnv(bound_outlives, ()) => {
845                    rewritten_constraints.push(rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, bound_outlives, u, assumptions));
846                }
847            }
848        }
849        rewritten_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
850    };
851
852    let and_constraint = rewrite_and(constraint.and_constraint);
853    let or_constraint = constraint
854        .or_constraint
855        .0
856        .into_iter()
857        .fold(Or::new_false(), |acc, c| Or::build_or(acc, rewrite_and(c)));
858
859    RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
860}
861
862fn rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
863    Infcx: InferCtxtLike<Interner = I>,
864    I: Interner,
865>(
866    infcx: &Infcx,
867    ty: I::Ty,
868    region: Region<I>,
869    u: UniverseIndex,
870    assumptions: &Assumptions<I>,
871) -> Or<I> {
872    use LeafRegionConstraint::*;
873
874    let ty_u = max_universe(infcx, ty);
875    let region_u = max_universe(infcx, region);
876
877    if region_u != u && ty_u != u {
878        return Or::new_leaf(PlaceholderTyOutlives(ty, region, ()));
879    }
880
881    let mut candidates = ::alloc::vec::Vec::new()vec![];
882
883    // There could be `!T: 'region` assumptions in the env even if `!T` is in a
884    // smaller universe
885    candidates.extend(
886        regions_outlived_by_placeholder(ty, assumptions, infcx.cx())
887            .map(move |assumption_r| RegionOutlives(assumption_r, region, ())),
888    );
889
890    // We can express `!T: 'region` as `!T: 'r` where `'r: 'region`. This is only necessary
891    // if the placeholder type is in a smaller universe as otherwise we know all regions which
892    // the placeholder outlives and can just destructure into an OR of RegionOutlives.
893    if region_u == u && ty_u < u {
894        candidates.extend(
895            regions_outliving::<I>(region, assumptions, infcx.cx())
896                .filter(|r| max_universe(infcx, *r) < u)
897                .map(|r| PlaceholderTyOutlives(ty, r, ())),
898        );
899    }
900
901    Or::new(candidates.into_iter().map(|c| And::new([c])))
902}
903
904fn rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
905    Infcx: InferCtxtLike<Interner = I>,
906    I: Interner,
907>(
908    infcx: &Infcx,
909    bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
910    u: UniverseIndex,
911    assumptions: &Assumptions<I>,
912) -> Or<I> {
913    use LeafRegionConstraint::*;
914
915    let mut candidates = Vec::new();
916
917    // given there can be higher ranked assumptions, e.g. `for<'a> <T as Trait<'a>>::Assoc: 'c`, that
918    // means that it's actually *always* possible for an alias outlive to be satisfied in the root universe
919    // which means there should *always* be atleast two candidates when destructuring alias outlives. The
920    // two candidates being component outlives and then a higher ranked alias outlives.
921    //
922    // we dont care about this for region outlives as `for<'a> 'a: 'b` can't exist as we don't elaborate
923    // higher ranked type outlives assumptions into higher ranked region outlives assumptions. similarly,
924    // we don't care about `for<'a> Foo<'a>: 'b` as we always destructure adts into their components and if
925    // we dont equivalently elaborate the assumption into assumptions on the adt's components we just drop the
926    // assumptions
927    //
928    // so actually only `for<'a, 'b> Alias<'a>: 'b` and `for<'a> T: 'a` are assumptions we actually need to
929    // handle.
930    //
931    // we don't care about this when rewriting in the root universe as we know the complete set of assumptions
932    if max_universe(infcx, bound_outlives) == u {
933        let mut replacer = PlaceholderReplacer {
934            cx: infcx.cx(),
935            existing_var_count: bound_outlives.bound_vars().len(),
936            bound_vars: IndexMap::default(),
937            universe: u,
938            current_index: DebruijnIndex::ZERO,
939        };
940        let escaping_outlives = bound_outlives.skip_binder().fold_with(&mut replacer);
941        let bound_vars = bound_outlives.bound_vars().iter().chain(
942            core::mem::take(&mut replacer.bound_vars)
943                .into_iter()
944                .map(|(_, bound_region)| BoundVariableKind::Region(bound_region.kind)),
945        );
946        let bound_outlives = Binder::bind_with_vars(
947            escaping_outlives,
948            I::BoundVarKinds::from_vars(infcx.cx(), bound_vars),
949        );
950        let candidate = Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, ()));
951        if max_universe(infcx, candidate.clone()) < u {
952            candidates.push(candidate);
953        } else {
954            // `PlaceholderReplacer` only folds regions. A non-lifetime binder can leave
955            // a placeholder type in `u`, so this type-outlives constraint cannot be
956            // handled by the region-outlives-only eager placeholder machinery.
957            candidates.push(Or::new_ambig(()));
958        }
959    }
960
961    // Actually look at the assumptions and matching our higher ranked alias outlives goal
962    // against potentially higher ranked type outlives assumptions.
963    candidates.push(alias_outlives_candidates_from_assumptions(infcx, bound_outlives, assumptions));
964
965    // we can rewrite `Alias_u1: 'u2` into `Or(Alias_u1: 'u1)`
966    // given a list of regions which outlive `'u2`
967    //
968    // we don't care about this when rewriting in the root universe as we know the complete set of assumptions
969    let (escaping_alias, escaping_r) = bound_outlives.skip_binder();
970    if max_universe(infcx, escaping_r) == u {
971        let mut replacer = PlaceholderReplacer {
972            cx: infcx.cx(),
973            existing_var_count: bound_outlives.bound_vars().len(),
974            bound_vars: IndexMap::default(),
975            universe: u,
976            current_index: DebruijnIndex::ZERO,
977        };
978        let escaping_alias = escaping_alias.fold_with(&mut replacer);
979        let bound_vars = bound_outlives.bound_vars().iter().chain(
980            core::mem::take(&mut replacer.bound_vars)
981                .into_iter()
982                .map(|(_, bound_region)| BoundVariableKind::Region(bound_region.kind)),
983        );
984        let bound_alias = Binder::bind_with_vars(
985            escaping_alias,
986            I::BoundVarKinds::from_vars(infcx.cx(), bound_vars),
987        );
988
989        // while we did skip the binder, bound vars aren't in any universe so
990        // this can't be an escaping bound var
991        candidates.push(Or::new(
992            regions_outliving(escaping_r, assumptions, infcx.cx())
993                .filter(|r2| max_universe(infcx, *r2) < u)
994                .map(|r2| {
995                    let candidate =
996                        AliasTyOutlivesViaEnv(bound_alias.map_bound(|alias| (alias, r2)), ());
997                    if max_universe(infcx, candidate.clone()) < u {
998                        And::new([candidate])
999                    } else {
1000                        And::new([Ambiguity(())])
1001                    }
1002                }),
1003        ));
1004    }
1005
1006    // I'm not convinced our handling here is *complete* so for now
1007    // let's be conservative and not let alias outlives' cause NoSolution
1008    // in coherence
1009    match infcx.typing_mode_raw() {
1010        TypingMode::Coherence => candidates.push(Or::new_ambig(())),
1011        TypingMode::Typeck { .. }
1012        | TypingMode::Reflection
1013        | TypingMode::ErasedNotCoherence { .. }
1014        | TypingMode::PostTypeckUntilBorrowck { .. }
1015        | TypingMode::PostBorrowck { .. }
1016        | TypingMode::PostAnalysis
1017        | TypingMode::Codegen => (),
1018    };
1019
1020    candidates.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c))
1021}
1022
1023/// Returns all regions `r2` for which `r: r2` is known to hold in
1024/// the universe associated with `assumptions`
1025pub fn regions_outlived_by<I: Interner>(
1026    r: Region<I>,
1027    assumptions: &Assumptions<I>,
1028) -> impl Iterator<Item = Region<I>> {
1029    assumptions.region_outlives.reachable_from(r).into_iter().chain([r])
1030}
1031
1032/// Returns all regions `r2` for which `r2: r` is known to hold in
1033/// the universe associated with `assumptions`
1034pub fn regions_outliving<I: Interner>(
1035    r: Region<I>,
1036    assumptions: &Assumptions<I>,
1037    cx: I,
1038) -> impl Iterator<Item = Region<I>> {
1039    assumptions
1040        .inverse_region_outlives
1041        .reachable_from(r)
1042        .into_iter()
1043        // FIXME(-Zassumptions-on-binders): 'static may have been an input region canonicalized to something else is that important?
1044        // FIXME(-Zassumptions-on-binders): do we need to adding the reflexive edge here?
1045        .chain([r, Region::new_static(cx)])
1046}
1047
1048/// Returns all regions `r` for which `!t: r` is known to hold in
1049/// the universe associated with `assumptions`
1050pub fn regions_outlived_by_placeholder<I: Interner>(
1051    t: I::Ty,
1052    assumptions: &Assumptions<I>,
1053    cx: I,
1054) -> impl Iterator<Item = Region<I>> {
1055    match t.kind() {
1056        TyKind::Placeholder(..) | TyKind::Param(..) => (),
1057        _ => {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("non-placeholder in `regions_outlived_by_placeholder`: {0:?}",
                t)));
}unreachable!("non-placeholder in `regions_outlived_by_placeholder`: {t:?}"),
1058    }
1059
1060    assumptions.type_outlives.iter().flat_map(move |binder| match binder.no_bound_vars() {
1061        Some(OutlivesClause(ty, r)) => (ty == t).then_some(r),
1062        None => Some(Region::new_static(cx)),
1063    })
1064}
1065
1066pub struct PlaceholderReplacer<I: Interner> {
1067    cx: I,
1068    existing_var_count: usize,
1069    bound_vars: IndexMap<BoundVar, BoundRegion<I>>,
1070    universe: UniverseIndex,
1071    current_index: DebruijnIndex,
1072}
1073
1074impl<I: Interner> TypeFolder<I> for PlaceholderReplacer<I> {
1075    fn cx(&self) -> I {
1076        self.cx
1077    }
1078
1079    fn fold_region(&mut self, r: Region<I>) -> Region<I> {
1080        match r.kind() {
1081            RegionKind::RePlaceholder(p) if p.universe == self.universe => {
1082                let bound_vars_len = self.bound_vars.len();
1083                let mapped_var = self.bound_vars.entry(p.bound.var).or_insert(BoundRegion {
1084                    var: BoundVar::from_usize(self.existing_var_count + bound_vars_len),
1085                    kind: p.bound.kind,
1086                });
1087                Region::new_bound(self.cx, self.current_index, *mapped_var)
1088            }
1089            // FIXME(-Zassumptions-on-binders): We should be handling region variables here somehow
1090            _ => r,
1091        }
1092    }
1093
1094    fn fold_binder<T: TypeFoldable<I>>(&mut self, b: Binder<I, T>) -> Binder<I, T> {
1095        self.current_index.shift_in(1);
1096        let b = b.super_fold_with(self);
1097        self.current_index.shift_out(1);
1098        b
1099    }
1100}
1101
1102/// Converts an `AliasTyOutlivesViaEnv` constraint into an OR of region outlives constraints by
1103/// matching the alias against any `Alias: 'a` assumptions. This is somewhat tricky as we have a
1104/// potentially higher ranked alias being equated with a potentially higher ranked assumption and
1105/// we don't handle it correctly right now (though it is a somewhat reasonable halfway step).
1106{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("alias_outlives_candidates_from_assumptions",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(1106u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("bound_outlives")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("bound_outlives");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assumptions")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assumptions");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bound_outlives)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: Or<I> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let mut candidates = Vec::new();
                        let prev_universe = infcx.universe();
                        infcx.enter_forall_with_empty_assumptions(bound_outlives,
                            |(alias, r)|
                                {
                                    for bound_type_outlives in assumptions.type_outlives.iter()
                                        {
                                        let OutlivesClause(alias2, r2) =
                                            infcx.instantiate_binder_with_infer(*bound_type_outlives);
                                        let mut relation =
                                            HigherRankedAliasMatcher {
                                                infcx,
                                                region_constraints: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                        [LeafRegionConstraint::RegionOutlives(r2, r, ())])),
                                            };
                                        if let Ok(_) =
                                                relation.relate(alias.to_ty(infcx.cx(), IsRigid::No),
                                                    set_aliases_to_non_rigid(infcx.cx(),
                                                            alias2).skip_norm_wip()) {
                                            candidates.push(And::new(relation.region_constraints));
                                        }
                                    }
                                });
                        let constraint =
                            RegionConstraint::new_from_or(Or::new(candidates));
                        let largest_universe = infcx.universe();
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:1140",
                                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                ::tracing_core::__macro_support::Option::Some(1140u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("prev_universe")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("prev_universe");
                                                                    NAME.as_str()
                                                                },
                                                                {
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("largest_universe")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("largest_universe");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&prev_universe)
                                                                    as &dyn ::tracing::field::Value)),
                                                        (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&largest_universe)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let canonical_constraint =
                            ((prev_universe.index() +
                                                        1)..=largest_universe.index()).map(|u|
                                            UniverseIndex::from_usize(u)).rev().fold(constraint,
                                |constraint, u|
                                    {
                                        eagerly_handle_placeholders_in_universe(infcx, constraint,
                                            u)
                                    });
                        canonical_constraint.splatted_and_constraints()
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs:1106",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c36f1457196e315bc204b9564a6a5a7fe7f5a51f/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(1106u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(infcx), ret)]
1107fn alias_outlives_candidates_from_assumptions<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
1108    infcx: &Infcx,
1109    bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
1110    assumptions: &Assumptions<I>,
1111) -> Or<I> {
1112    let mut candidates = Vec::new();
1113
1114    let prev_universe = infcx.universe();
1115
1116    infcx.enter_forall_with_empty_assumptions(bound_outlives, |(alias, r)| {
1117        for bound_type_outlives in assumptions.type_outlives.iter() {
1118            let OutlivesClause(alias2, r2) =
1119                infcx.instantiate_binder_with_infer(*bound_type_outlives);
1120
1121            let mut relation = HigherRankedAliasMatcher {
1122                infcx,
1123                region_constraints: vec![LeafRegionConstraint::RegionOutlives(r2, r, ())],
1124            };
1125
1126            // FIXME(#155345): Both sides should be rigid in the future.
1127            // Currently we can't guarantee that.
1128            if let Ok(_) = relation.relate(
1129                alias.to_ty(infcx.cx(), IsRigid::No),
1130                set_aliases_to_non_rigid(infcx.cx(), alias2).skip_norm_wip(),
1131            ) {
1132                candidates.push(And::new(relation.region_constraints));
1133            }
1134        }
1135    });
1136
1137    let constraint = RegionConstraint::new_from_or(Or::new(candidates));
1138
1139    let largest_universe = infcx.universe();
1140    debug!(?prev_universe, ?largest_universe);
1141
1142    let canonical_constraint = ((prev_universe.index() + 1)..=largest_universe.index())
1143        .map(|u| UniverseIndex::from_usize(u))
1144        .rev()
1145        .fold(constraint, |constraint, u| {
1146            eagerly_handle_placeholders_in_universe(infcx, constraint, u)
1147        });
1148
1149    canonical_constraint.splatted_and_constraints()
1150}
1151
1152struct HigherRankedAliasMatcher<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> {
1153    infcx: &'a Infcx,
1154    region_constraints: Vec<LeafRegionConstraint<I>>,
1155}
1156
1157impl<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeRelation<I>
1158    for HigherRankedAliasMatcher<'a, Infcx, I>
1159{
1160    fn cx(&self) -> I {
1161        self.infcx.cx()
1162    }
1163
1164    fn relate_ty_args(
1165        &mut self,
1166        a_ty: I::Ty,
1167        _b_ty: I::Ty,
1168        _ty_def_id: I::DefId,
1169        a_args: I::GenericArgs,
1170        b_args: I::GenericArgs,
1171        _mk: impl FnOnce(I::GenericArgs) -> I::Ty,
1172    ) -> RelateResult<I, I::Ty> {
1173        rustc_type_ir::relate::relate_args_invariantly(self, a_args, b_args)?;
1174        Ok(a_ty)
1175    }
1176
1177    fn relate_with_variance<T: Relate<I>>(
1178        &mut self,
1179        _variance: Variance,
1180        _info: VarianceDiagInfo<I>,
1181        a: T,
1182        b: T,
1183    ) -> RelateResult<I, T> {
1184        // FIXME(-Zassumptions-on-binders): bivariance is important for opaque type args so
1185        // we should actually handle variance in some way here.
1186        self.relate(a, b)
1187    }
1188
1189    fn tys(&mut self, a: I::Ty, b: I::Ty) -> RelateResult<I, I::Ty> {
1190        rustc_type_ir::relate::structurally_relate_tys(self, a, b)
1191    }
1192
1193    fn regions(&mut self, a: Region<I>, b: Region<I>) -> RelateResult<I, Region<I>> {
1194        if a != b {
1195            self.region_constraints.push(LeafRegionConstraint::RegionOutlives(a, b, ()));
1196            self.region_constraints.push(LeafRegionConstraint::RegionOutlives(b, a, ()));
1197        }
1198        Ok(a)
1199    }
1200
1201    fn consts(&mut self, a: Const<I>, b: Const<I>) -> RelateResult<I, Const<I>> {
1202        rustc_type_ir::relate::structurally_relate_consts(self, a, b)
1203    }
1204
1205    fn binders<T>(&mut self, a: Binder<I, T>, b: Binder<I, T>) -> RelateResult<I, Binder<I, T>>
1206    where
1207        T: Relate<I>,
1208    {
1209        self.infcx.enter_forall_with_empty_assumptions(a, |a| {
1210            let u = self.infcx.universe();
1211            self.infcx.insert_placeholder_assumptions(u, Assumptions::empty());
1212            let b = self.infcx.instantiate_binder_with_infer(b);
1213            self.relate(a, b)
1214        })?;
1215
1216        self.infcx.enter_forall_with_empty_assumptions(b, |b| {
1217            let u = self.infcx.universe();
1218            self.infcx.insert_placeholder_assumptions(u, Assumptions::empty());
1219            let a = self.infcx.instantiate_binder_with_infer(a);
1220            self.relate(a, b)
1221        })?;
1222
1223        Ok(a)
1224    }
1225}