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

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let assumptions = infcx.get_placeholder_assumptions(u);
                        let constraint =
                            rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx,
                                constraint, u, &assumptions);
                        let constraint =
                            compute_new_region_constraints(infcx, constraint, u);
                        let constraint =
                            pull_region_outlives_constraints_out_of_universe(infcx,
                                constraint, u, &assumptions);
                        propagate_ambiguity(constraint)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs:503",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(503u32),
                        ::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)]
504pub fn eagerly_handle_placeholders_in_universe<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
505    infcx: &Infcx,
506    constraint: RegionConstraint<I>,
507    u: UniverseIndex,
508) -> RegionConstraint<I> {
509    let assumptions = infcx.get_placeholder_assumptions(u);
510
511    // 1. rewrite type outlives constraints involving things from `u` into either region constraints
512    //     involving things from `u` or type outlives constraints not involving things from `u`
513    //
514    //    IOW, we only want to encounter things from `u` as part of region out lives constraints.
515    let constraint = rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling(
516        infcx,
517        constraint,
518        u,
519        &assumptions,
520    );
521
522    // 2. compute transitive region outlives and get a new set of region outlives constraints by
523    //     looking for every region which either a placeholder_u flows into it, or it flows into
524    //     the placeholder.
525    let constraint = compute_new_region_constraints(infcx, constraint, u);
526
527    // 3. rewrite region outlives constraints (potentially to false/true)
528    let constraint =
529        pull_region_outlives_constraints_out_of_universe(infcx, constraint, u, &assumptions);
530
531    // 4. force the constraint to ambiguous if it could be `false` in future reruns
532    propagate_ambiguity(constraint)
533}
534
535/// Filter our region constraints to not include constraints between region variables from `u` and
536/// other regions as those are always satisfied. This requires some care to handle correctly for example:
537/// `'!a_u1: '?x_u1: '!b_u1` should result in us requiring `'!a_u1: '!b_u1` rather than dropping the two
538/// constraints entirely.
539///
540/// The only constraints involving things from `u` should be region outlives constraints at this point. Type
541/// outlives constraints should have been handled already either by destructuring into region outlives or by
542/// being rewritten in terms of smaller universe variables.
543{}
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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(543u32),
                                ::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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs:543",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(543u32),
                        ::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)]
544fn compute_new_region_constraints<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
545    infcx: &Infcx,
546    constraint: RegionConstraint<I>,
547    u: UniverseIndex,
548) -> RegionConstraint<I> {
549    use LeafRegionConstraint::*;
550
551    let extend_from_and = |builder: &mut TransitiveRelationBuilder<_>,
552                           regions: &mut IndexSet<_>,
553                           constraints: &mut Vec<_>,
554                           and: &And<I>| {
555        for c in &and.0 {
556            match c {
557                Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
558                    constraints.push(c.clone())
559                }
560                RegionOutlives(r1, r2, ()) => {
561                    regions.insert(*r1);
562                    regions.insert(*r2);
563                    builder.add(*r2, *r1);
564                }
565            }
566        }
567    };
568
569    let mut base_region_flows_builder = TransitiveRelationBuilder::default();
570    let mut base_regions = IndexSet::new();
571    let mut base_constraints = Vec::new();
572    extend_from_and(
573        &mut base_region_flows_builder,
574        &mut base_regions,
575        &mut base_constraints,
576        &constraint.and_constraint,
577    );
578
579    let mut new_ands = Vec::new();
580    for and in &constraint.or_constraint.0 {
581        let mut region_flows_builder = base_region_flows_builder.clone();
582        let mut regions = base_regions.clone();
583        let mut constraints = base_constraints.clone();
584        extend_from_and(&mut region_flows_builder, &mut regions, &mut constraints, and);
585
586        let region_flow = region_flows_builder.freeze();
587        for r in regions.into_iter() {
588            for ub in region_flow.reachable_from(r) {
589                // we want to retain any region constraints between two "placeholder-likes" where for our
590                // purposes a placeholder-like is either a placeholder or variable in a lower universe
591                let is_placeholder_like = |r: Region<I>| match r.kind() {
592                    RegionKind::ReLateParam(..)
593                    | RegionKind::ReEarlyParam(..)
594                    | RegionKind::RePlaceholder(..)
595                    | RegionKind::ReStatic => true,
596                    RegionKind::ReVar(..) => max_universe(infcx, r) < u,
597                    RegionKind::ReError(..) => false,
598                    RegionKind::ReErased | RegionKind::ReBound(..) => unreachable!(),
599                };
600
601                if is_placeholder_like(r) && is_placeholder_like(ub) {
602                    constraints.push(RegionOutlives(ub, r, ()));
603                }
604            }
605        }
606
607        new_ands.push(Or::new([And::new(constraints)]))
608    }
609
610    // FIXME(-Zassumptions-on-binders): probably bad for perf!
611    RegionConstraint::new_from_or(
612        new_ands.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c)),
613    )
614}
615
616/// Force the whole constraint to be ambiguous if it contains ambiguities which could
617/// have caused the constraint to be `false` if they had been `false` themselves.
618///
619/// For example if we have `'a: 'b AND ambig`  it's possible that if we had more inference
620/// information we could have produced a better region constraint than `ambig`, and that
621/// constraint may then have gone on to be false, at which point we would have `'a: 'b AND false`
622/// causing the whole constraint to be `false`.
623///
624/// If we're not careful we can wind up returning `'a: 'b AND ambig` from passing trait solver
625/// goals and then upon rerunning wind up returning `NoSolution` which would be dubious :3
626///
627/// This is inherently conservative and this method should be called as little as possible as it
628/// can cause us to get ambiguities instead of `NoSolution` (for example if `'a: 'b` is `false`),
629/// which can affect coherence, candidate selection, etc.
630///
631/// FIXME(-Zassumptions-on-binders): this method should probably be trait-solver internal as it only
632/// matters at trait solver query boundaries. We currently call it in more than just that location
633{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("propagate_ambiguity",
                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(633u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I, S> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if let Some(ambig) =
                                constraint.and_constraint.0.iter().find(|c| c.is_ambig()) {
                            return RegionConstraint::new_leaf(ambig.clone());
                        }
                        for and in constraint.or_constraint.0.iter() {
                            if let Some(ambig) = and.0.iter().find(|c| c.is_ambig()) {
                                return RegionConstraint::new_leaf(ambig.clone());
                            }
                        }
                        constraint
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs:633",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(633u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", ret)]
634pub fn propagate_ambiguity<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash>(
635    constraint: RegionConstraint<I, S>,
636) -> RegionConstraint<I, S> {
637    if let Some(ambig) = constraint.and_constraint.0.iter().find(|c| c.is_ambig()) {
638        return RegionConstraint::new_leaf(ambig.clone());
639    }
640
641    for and in constraint.or_constraint.0.iter() {
642        // FIXME(-Zassumptions-on-binders): This is overly conservative. If we have:
643        // `'a: 'b OR ambig` we don't necessarily want to propagate ambiguity here
644        // as we might end up with `'a: 'b` being satisfied in which case we unnecessarily
645        // errored here.
646        //
647        // It's fine if the `ambig` wound up being `false` as that wouldn't cause a goal to
648        // become `NoSolution`, it would instead result in us returning the `'a: 'b` constraint
649        // by itself.
650        //
651        // `rust-lang/project-assumptions-on-binders#21`
652        if let Some(ambig) = and.0.iter().find(|c| c.is_ambig()) {
653            return RegionConstraint::new_leaf(ambig.clone());
654        }
655    }
656
657    constraint
658}
659
660/// Handles converting region outlives constraints involving placeholders from `u` into OR constraints
661/// involving regions from smaller universes with known relationships to the placeholder. For example:
662/// ```ignore (not rust)
663/// for<'a, 'b> where(
664///     'c: 'b, 'd: 'b,
665///     'a: 'e, 'a: 'f,
666/// ) {
667///     'a_u1: 'b_u1
668/// }
669/// ```
670/// will get converted to:
671/// ```ignore (not rust)
672/// OR(
673///     'e: 'c,
674///     'e: 'd,
675///     'f: 'c,
676///     'f: 'd,
677/// )
678/// ```
679/// if we are handling constraints in `u1`.
680{}
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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(680u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_type_ir::region_constraint"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("constraint")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("constraint");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assumptions")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assumptions");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: RegionConstraint<I> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if !(max_universe(infcx, constraint.clone()) <= u) {
                            ::core::panicking::panic("assertion failed: max_universe(infcx, constraint.clone()) <= u")
                        };
                        use LeafRegionConstraint::*;
                        let pull_and =
                            |and: And<I>|
                                {
                                    let mut pulled_constraints = Vec::new();
                                    for c in and.0 {
                                        match c {
                                            Ambiguity(()) | PlaceholderTyOutlives(..) |
                                                AliasTyOutlivesViaEnv(..) => {
                                                if !(max_universe(infcx, c.clone()) < u) {
                                                    ::core::panicking::panic("assertion failed: max_universe(infcx, c.clone()) < u")
                                                };
                                                pulled_constraints.push(Or::new_leaf(c.clone()));
                                            }
                                            RegionOutlives(region_1, region_2, ()) => {
                                                let region_1_u = max_universe(infcx, region_1);
                                                let region_2_u = max_universe(infcx, region_2);
                                                if region_1_u != u && region_2_u != u {
                                                    pulled_constraints.push(Or::new_leaf(c));
                                                    continue;
                                                }
                                                let assumptions =
                                                    match assumptions {
                                                        Some(assumptions) => assumptions,
                                                        None => {
                                                            pulled_constraints.push(Or::new_ambig(()));
                                                            continue;
                                                        }
                                                    };
                                                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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs:680",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(680u32),
                        ::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)]
681fn pull_region_outlives_constraints_out_of_universe<
682    Infcx: InferCtxtLike<Interner = I>,
683    I: Interner,
684>(
685    infcx: &Infcx,
686    constraint: RegionConstraint<I>,
687    u: UniverseIndex,
688    assumptions: &Option<Assumptions<I>>,
689) -> RegionConstraint<I> {
690    assert!(max_universe(infcx, constraint.clone()) <= u);
691
692    // FIXME(-Zassumptions-on-binders): we don't lower universes of region variables when exiting `u`
693    // this seems dubious/potentially wrong? we can't just blindly do this though as if we had something
694    // like `!T_u -> ?x_u -> !U_u` then lowering `?x` to `u-1` when exiting `u` would be wrong.
695    //
696    // I'm not even sure this would be necessary given we filter out region constraints involving regions#
697    // from the current universe and only retain those between placeholders.
698
699    use LeafRegionConstraint::*;
700
701    let pull_and = |and: And<I>| {
702        let mut pulled_constraints = Vec::new();
703        for c in and.0 {
704            match c {
705                Ambiguity(()) | PlaceholderTyOutlives(..) | AliasTyOutlivesViaEnv(..) => {
706                    assert!(max_universe(infcx, c.clone()) < u);
707                    pulled_constraints.push(Or::new_leaf(c.clone()));
708                }
709                RegionOutlives(region_1, region_2, ()) => {
710                    let region_1_u = max_universe(infcx, region_1);
711                    let region_2_u = max_universe(infcx, region_2);
712
713                    if region_1_u != u && region_2_u != u {
714                        pulled_constraints.push(Or::new_leaf(c));
715                        continue;
716                    }
717
718                    let assumptions = match assumptions {
719                        Some(assumptions) => assumptions,
720                        None => {
721                            pulled_constraints.push(Or::new_ambig(()));
722                            continue;
723                        }
724                    };
725
726                    let mut candidates = vec![];
727
728                    for ub in regions_outlived_by(region_1, assumptions)
729                        .filter(|r| max_universe(infcx, *r) < u)
730                    {
731                        // FIXME(-Zassumptions-on-binders): if `region_2` is in a smaller universe there'll be both
732                        // `'region_2` and `'static` as lower bounds which seems... unfortunate and may cause us to
733                        // add a bunch of duplicate `'ub: 'static` candidates the more binders we leave.
734                        for lb in regions_outliving(region_2, assumptions, infcx.cx())
735                            .filter(|r| max_universe(infcx, *r) < u)
736                        {
737                            // As long as any region outlived by `region_1` outlives any region region which
738                            // `region_2` outlives, we know that `region_1: region_2` holds. In other words,
739                            // there exists some set of 4 regions for which `'r1: 'i1` `'i1: 'i2` `'i2: 'r2`
740                            candidates.push(RegionOutlives(ub, lb, ()));
741                        }
742                    }
743
744                    pulled_constraints.push(Or::new(candidates.into_iter().map(|c| And::new([c]))));
745                }
746            };
747        }
748
749        pulled_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
750    };
751
752    let and_constraint = pull_and(constraint.and_constraint);
753    let or_constraint = constraint
754        .or_constraint
755        .0
756        .into_iter()
757        .fold(Or::new_false(), |acc, c| Or::build_or(acc, pull_and(c)));
758    RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
759}
760
761/// Converts type outlives constraints into region outlives constraints. This assumes the *complete* set of
762/// assumptions are known. This should not be called until the end of type checking.
763///
764/// The returned region constraint will not have *any* PlaceholderTyOutlives or AliasTyOutlivesViaEnv constraints.
765{}
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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(765u32),
                                ::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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs:778",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(778u32),
                                                            ::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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs:804",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(804u32),
                                                            ::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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs:808",
                                                            "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(808u32),
                                                            ::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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs:765",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(765u32),
                        ::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)]
766pub fn destructure_type_outlives_constraints_in_root<
767    Infcx: InferCtxtLike<Interner = I>,
768    I: Interner,
769    S: Clone + std::fmt::Debug + Eq + std::hash::Hash,
770>(
771    infcx: &Infcx,
772    constraint: RegionConstraint<I, S>,
773    assumptions: &Assumptions<I>,
774) -> RegionConstraint<I, S> {
775    use LeafRegionConstraint::*;
776
777    let destructure_and = |and: &And<I, S>| {
778        debug!("rewriting and: {:?}", and);
779        let mut destructured_constraints = Vec::new();
780        for c in &and.0 {
781            match c {
782                Ambiguity(_) | RegionOutlives(..) => {
783                    destructured_constraints.push(Or::new_leaf(c.clone()))
784                }
785                PlaceholderTyOutlives(ty, r, span) => destructured_constraints.push(Or::new(
786                    regions_outlived_by_placeholder(*ty, assumptions, infcx.cx()).map(
787                        move |assumption_r| {
788                            And::new([RegionOutlives(assumption_r, *r, span.clone())])
789                        },
790                    ),
791                )),
792                AliasTyOutlivesViaEnv(bound_outlives, span) => {
793                    destructured_constraints.push(
794                        alias_outlives_candidates_from_assumptions(
795                            infcx,
796                            *bound_outlives,
797                            assumptions,
798                        )
799                        .with_spans(span.clone()),
800                    );
801                }
802            }
803        }
804        debug!(?destructured_constraints);
805        let merged_constraints = destructured_constraints
806            .into_iter()
807            .fold(Or::new_true(), |acc, c| Or::build_and(acc, c));
808        debug!(?merged_constraints);
809        merged_constraints
810    };
811
812    let and_constraint = destructure_and(&constraint.and_constraint);
813    let or_constraint = constraint
814        .or_constraint
815        .0
816        .into_iter()
817        .fold(Or::new_false(), |acc, c| Or::build_or(acc, destructure_and(&c)));
818
819    RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
820}
821
822/// Converts type outlives constraints into either region outlives constraints, or type outlives
823/// constraints which do not contain anything from `u`.
824///
825/// This only works off assumptions associated with the binder corresponding to `u` both for
826/// perf reasons and because the full set of region assumptions is not known during type checking
827/// due to closure signature inference.
828///
829/// This only really causes problems for higher-ranked outlives assumptions, for example if we have
830/// `where for<'a> <T as Trait<'a>>::Assoc: 'b` then we can't use that to prove `<T as Trait<'!c>>::Assoc: 'b`
831/// until we are in the root context. See comments inside this function for more detail.
832{}
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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(832u32),
                                ::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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs:832",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(832u32),
                        ::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)]
833fn rewrite_type_outlives_constraints_in_universe_for_eager_placeholder_handling<
834    Infcx: InferCtxtLike<Interner = I>,
835    I: Interner,
836>(
837    infcx: &Infcx,
838    constraint: RegionConstraint<I>,
839    u: UniverseIndex,
840    assumptions: &Option<Assumptions<I>>,
841) -> RegionConstraint<I> {
842    use LeafRegionConstraint::*;
843
844    assert!(
845        max_universe(infcx, constraint.clone()) <= u,
846        "constraint {:?} contains terms from a larger universe than {:?}",
847        constraint.clone(),
848        u
849    );
850
851    let rewrite_and = |and: And<I>| {
852        let mut rewritten_constraints = Vec::new();
853        for c in and.0 {
854            match c {
855                Ambiguity(()) | RegionOutlives(..) => rewritten_constraints.push(Or::new_leaf(c)),
856                PlaceholderTyOutlives(ty, region, ()) => {
857                    rewritten_constraints.push(rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, ty, region, u, assumptions));
858                }
859                AliasTyOutlivesViaEnv(bound_outlives, ()) => {
860                    rewritten_constraints.push(rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling(infcx, bound_outlives, u, assumptions));
861                }
862            }
863        }
864        rewritten_constraints.into_iter().fold(Or::new_true(), |acc, c| Or::build_and(acc, c))
865    };
866
867    let and_constraint = rewrite_and(constraint.and_constraint);
868    let or_constraint = constraint
869        .or_constraint
870        .0
871        .into_iter()
872        .fold(Or::new_false(), |acc, c| Or::build_or(acc, rewrite_and(c)));
873
874    RegionConstraint::new_from_or(Or::build_and(and_constraint, or_constraint))
875}
876
877fn rewrite_placeholder_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
878    Infcx: InferCtxtLike<Interner = I>,
879    I: Interner,
880>(
881    infcx: &Infcx,
882    ty: I::Ty,
883    region: Region<I>,
884    u: UniverseIndex,
885    assumptions: &Option<Assumptions<I>>,
886) -> Or<I> {
887    use LeafRegionConstraint::*;
888
889    let ty_u = max_universe(infcx, ty);
890    let region_u = max_universe(infcx, region);
891
892    if region_u != u && ty_u != u {
893        return Or::new_leaf(PlaceholderTyOutlives(ty, region, ()));
894    }
895
896    let assumptions = match assumptions {
897        Some(assumptions) => assumptions,
898        None => return Or::new_ambig(()),
899    };
900
901    let mut candidates = ::alloc::vec::Vec::new()vec![];
902
903    // There could be `!T: 'region` assumptions in the env even if `!T` is in a
904    // smaller universe
905    candidates.extend(
906        regions_outlived_by_placeholder(ty, assumptions, infcx.cx())
907            .map(move |assumption_r| RegionOutlives(assumption_r, region, ())),
908    );
909
910    // We can express `!T: 'region` as `!T: 'r` where `'r: 'region`. This is only necessary
911    // if the placeholder type is in a smaller universe as otherwise we know all regions which
912    // the placeholder outlives and can just destructure into an OR of RegionOutlives.
913    if region_u == u && ty_u < u {
914        candidates.extend(
915            regions_outliving::<I>(region, assumptions, infcx.cx())
916                .filter(|r| max_universe(infcx, *r) < u)
917                .map(|r| PlaceholderTyOutlives(ty, r, ())),
918        );
919    }
920
921    Or::new(candidates.into_iter().map(|c| And::new([c])))
922}
923
924fn rewrite_alias_ty_outlives_constraints_in_universe_for_eager_placeholder_handling<
925    Infcx: InferCtxtLike<Interner = I>,
926    I: Interner,
927>(
928    infcx: &Infcx,
929    bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
930    u: UniverseIndex,
931    assumptions: &Option<Assumptions<I>>,
932) -> Or<I> {
933    use LeafRegionConstraint::*;
934
935    let mut candidates = Vec::new();
936
937    // given there can be higher ranked assumptions, e.g. `for<'a> <T as Trait<'a>>::Assoc: 'c`, that
938    // means that it's actually *always* possible for an alias outlive to be satisfied in the root universe
939    // which means there should *always* be atleast two candidates when destructuring alias outlives. The
940    // two candidates being component outlives and then a higher ranked alias outlives.
941    //
942    // we dont care about this for region outlives as `for<'a> 'a: 'b` can't exist as we don't elaborate
943    // higher ranked type outlives assumptions into higher ranked region outlives assumptions. similarly,
944    // we don't care about `for<'a> Foo<'a>: 'b` as we always destructure adts into their components and if
945    // we dont equivalently elaborate the assumption into assumptions on the adt's components we just drop the
946    // assumptions
947    //
948    // so actually only `for<'a, 'b> Alias<'a>: 'b` and `for<'a> T: 'a` are assumptions we actually need to
949    // handle.
950    //
951    // we don't care about this when rewriting in the root universe as we know the complete set of assumptions
952    if max_universe(infcx, bound_outlives) == u {
953        let mut replacer = PlaceholderReplacer {
954            cx: infcx.cx(),
955            existing_var_count: bound_outlives.bound_vars().len(),
956            bound_vars: IndexMap::default(),
957            universe: u,
958            current_index: DebruijnIndex::ZERO,
959        };
960        let escaping_outlives = bound_outlives.skip_binder().fold_with(&mut replacer);
961        let bound_vars = bound_outlives.bound_vars().iter().chain(
962            core::mem::take(&mut replacer.bound_vars)
963                .into_iter()
964                .map(|(_, bound_region)| BoundVariableKind::Region(bound_region.kind)),
965        );
966        let bound_outlives = Binder::bind_with_vars(
967            escaping_outlives,
968            I::BoundVarKinds::from_vars(infcx.cx(), bound_vars),
969        );
970        let candidate = Or::new_leaf(AliasTyOutlivesViaEnv(bound_outlives, ()));
971        if max_universe(infcx, candidate.clone()) < u {
972            candidates.push(candidate);
973        } else {
974            // `PlaceholderReplacer` only folds regions. A non-lifetime binder can leave
975            // a placeholder type in `u`, so this type-outlives constraint cannot be
976            // handled by the region-outlives-only eager placeholder machinery.
977            candidates.push(Or::new_ambig(()));
978        }
979    }
980
981    let assumptions = match assumptions {
982        Some(assumptions) => assumptions,
983        None => {
984            candidates.push(Or::new_ambig(()));
985            return candidates.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c));
986        }
987    };
988
989    // Actually look at the assumptions and matching our higher ranked alias outlives goal
990    // against potentially higher ranked type outlives assumptions.
991    candidates.push(alias_outlives_candidates_from_assumptions(infcx, bound_outlives, assumptions));
992
993    // we can rewrite `Alias_u1: 'u2` into `Or(Alias_u1: 'u1)`
994    // given a list of regions which outlive `'u2`
995    //
996    // we don't care about this when rewriting in the root universe as we know the complete set of assumptions
997    let (escaping_alias, escaping_r) = bound_outlives.skip_binder();
998    if max_universe(infcx, escaping_r) == u {
999        let mut replacer = PlaceholderReplacer {
1000            cx: infcx.cx(),
1001            existing_var_count: bound_outlives.bound_vars().len(),
1002            bound_vars: IndexMap::default(),
1003            universe: u,
1004            current_index: DebruijnIndex::ZERO,
1005        };
1006        let escaping_alias = escaping_alias.fold_with(&mut replacer);
1007        let bound_vars = bound_outlives.bound_vars().iter().chain(
1008            core::mem::take(&mut replacer.bound_vars)
1009                .into_iter()
1010                .map(|(_, bound_region)| BoundVariableKind::Region(bound_region.kind)),
1011        );
1012        let bound_alias = Binder::bind_with_vars(
1013            escaping_alias,
1014            I::BoundVarKinds::from_vars(infcx.cx(), bound_vars),
1015        );
1016
1017        // while we did skip the binder, bound vars aren't in any universe so
1018        // this can't be an escaping bound var
1019        candidates.push(Or::new(
1020            regions_outliving(escaping_r, assumptions, infcx.cx())
1021                .filter(|r2| max_universe(infcx, *r2) < u)
1022                .map(|r2| {
1023                    let candidate =
1024                        AliasTyOutlivesViaEnv(bound_alias.map_bound(|alias| (alias, r2)), ());
1025                    if max_universe(infcx, candidate.clone()) < u {
1026                        And::new([candidate])
1027                    } else {
1028                        And::new([Ambiguity(())])
1029                    }
1030                }),
1031        ));
1032    }
1033
1034    // I'm not convinced our handling here is *complete* so for now
1035    // let's be conservative and not let alias outlives' cause NoSolution
1036    // in coherence
1037    match infcx.typing_mode_raw() {
1038        TypingMode::Coherence => candidates.push(Or::new_ambig(())),
1039        TypingMode::Typeck { .. }
1040        | TypingMode::Reflection
1041        | TypingMode::ErasedNotCoherence { .. }
1042        | TypingMode::PostTypeckUntilBorrowck { .. }
1043        | TypingMode::PostBorrowck { .. }
1044        | TypingMode::PostAnalysis
1045        | TypingMode::Codegen => (),
1046    };
1047
1048    candidates.into_iter().fold(Or::new_false(), |acc, c| Or::build_or(acc, c))
1049}
1050
1051/// Returns all regions `r2` for which `r: r2` is known to hold in
1052/// the universe associated with `assumptions`
1053pub fn regions_outlived_by<I: Interner>(
1054    r: Region<I>,
1055    assumptions: &Assumptions<I>,
1056) -> impl Iterator<Item = Region<I>> {
1057    // FIXME(-Zassumptions-on-binders): do we need to be adding the reflexive edge here?
1058    assumptions.region_outlives.reachable_from(r).into_iter().chain([r])
1059}
1060
1061/// Returns all regions `r2` for which `r2: r` is known to hold in
1062/// the universe associated with `assumptions`
1063pub fn regions_outliving<I: Interner>(
1064    r: Region<I>,
1065    assumptions: &Assumptions<I>,
1066    cx: I,
1067) -> impl Iterator<Item = Region<I>> {
1068    assumptions
1069        .inverse_region_outlives
1070        .reachable_from(r)
1071        .into_iter()
1072        // FIXME(-Zassumptions-on-binders): 'static may have been an input region canonicalized to something else is that important?
1073        // FIXME(-Zassumptions-on-binders): do we need to adding the reflexive edge here?
1074        .chain([r, Region::new_static(cx)])
1075}
1076
1077/// Returns all regions `r` for which `!t: r` is known to hold in
1078/// the universe associated with `assumptions`
1079pub fn regions_outlived_by_placeholder<I: Interner>(
1080    t: I::Ty,
1081    assumptions: &Assumptions<I>,
1082    cx: I,
1083) -> impl Iterator<Item = Region<I>> {
1084    match t.kind() {
1085        TyKind::Placeholder(..) | TyKind::Param(..) => (),
1086        _ => {
    ::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:?}"),
1087    }
1088
1089    assumptions.type_outlives.iter().flat_map(move |binder| match binder.no_bound_vars() {
1090        Some(OutlivesClause(ty, r)) => (ty == t).then_some(r),
1091        None => Some(Region::new_static(cx)),
1092    })
1093}
1094
1095pub struct PlaceholderReplacer<I: Interner> {
1096    cx: I,
1097    existing_var_count: usize,
1098    bound_vars: IndexMap<BoundVar, BoundRegion<I>>,
1099    universe: UniverseIndex,
1100    current_index: DebruijnIndex,
1101}
1102
1103impl<I: Interner> TypeFolder<I> for PlaceholderReplacer<I> {
1104    fn cx(&self) -> I {
1105        self.cx
1106    }
1107
1108    fn fold_region(&mut self, r: Region<I>) -> Region<I> {
1109        match r.kind() {
1110            RegionKind::RePlaceholder(p) if p.universe == self.universe => {
1111                let bound_vars_len = self.bound_vars.len();
1112                let mapped_var = self.bound_vars.entry(p.bound.var).or_insert(BoundRegion {
1113                    var: BoundVar::from_usize(self.existing_var_count + bound_vars_len),
1114                    kind: p.bound.kind,
1115                });
1116                Region::new_bound(self.cx, self.current_index, *mapped_var)
1117            }
1118            // FIXME(-Zassumptions-on-binders): We should be handling region variables here somehow
1119            _ => r,
1120        }
1121    }
1122
1123    fn fold_binder<T: TypeFoldable<I>>(&mut self, b: Binder<I, T>) -> Binder<I, T> {
1124        self.current_index.shift_in(1);
1125        let b = b.super_fold_with(self);
1126        self.current_index.shift_out(1);
1127        b
1128    }
1129}
1130
1131/// Converts an `AliasTyOutlivesViaEnv` constraint into an OR of region outlives constraints by
1132/// matching the alias against any `Alias: 'a` assumptions. This is somewhat tricky as we have a
1133/// potentially higher ranked alias being equated with a potentially higher ranked assumption and
1134/// we don't handle it correctly right now (though it is a somewhat reasonable halfway step).
1135{}
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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                                ::tracing_core::__macro_support::Option::Some(1135u32),
                                ::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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs:1169",
                                                "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                                                ::tracing_core::__macro_support::Option::Some(1169u32),
                                                ::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/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs:1135",
                        "rustc_type_ir::region_constraint", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/0fc141305da7a8a222f65aef1f1acc739c46282b/compiler/rustc_type_ir/src/region_constraint.rs"),
                        ::tracing_core::__macro_support::Option::Some(1135u32),
                        ::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)]
1136fn alias_outlives_candidates_from_assumptions<Infcx: InferCtxtLike<Interner = I>, I: Interner>(
1137    infcx: &Infcx,
1138    bound_outlives: Binder<I, (AliasTy<I>, Region<I>)>,
1139    assumptions: &Assumptions<I>,
1140) -> Or<I> {
1141    let mut candidates = Vec::new();
1142
1143    let prev_universe = infcx.universe();
1144
1145    infcx.enter_forall_with_empty_assumptions(bound_outlives, |(alias, r)| {
1146        for bound_type_outlives in assumptions.type_outlives.iter() {
1147            let OutlivesClause(alias2, r2) =
1148                infcx.instantiate_binder_with_infer(*bound_type_outlives);
1149
1150            let mut relation = HigherRankedAliasMatcher {
1151                infcx,
1152                region_constraints: vec![LeafRegionConstraint::RegionOutlives(r2, r, ())],
1153            };
1154
1155            // FIXME(#155345): Both sides should be rigid in the future.
1156            // Currently we can't guarantee that.
1157            if let Ok(_) = relation.relate(
1158                alias.to_ty(infcx.cx(), IsRigid::No),
1159                set_aliases_to_non_rigid(infcx.cx(), alias2).skip_norm_wip(),
1160            ) {
1161                candidates.push(And::new(relation.region_constraints));
1162            }
1163        }
1164    });
1165
1166    let constraint = RegionConstraint::new_from_or(Or::new(candidates));
1167
1168    let largest_universe = infcx.universe();
1169    debug!(?prev_universe, ?largest_universe);
1170
1171    let canonical_constraint = ((prev_universe.index() + 1)..=largest_universe.index())
1172        .map(|u| UniverseIndex::from_usize(u))
1173        .rev()
1174        .fold(constraint, |constraint, u| {
1175            eagerly_handle_placeholders_in_universe(infcx, constraint, u)
1176        });
1177
1178    canonical_constraint.splatted_and_constraints()
1179}
1180
1181struct HigherRankedAliasMatcher<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> {
1182    infcx: &'a Infcx,
1183    region_constraints: Vec<LeafRegionConstraint<I>>,
1184}
1185
1186impl<'a, Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeRelation<I>
1187    for HigherRankedAliasMatcher<'a, Infcx, I>
1188{
1189    fn cx(&self) -> I {
1190        self.infcx.cx()
1191    }
1192
1193    fn relate_ty_args(
1194        &mut self,
1195        a_ty: I::Ty,
1196        _b_ty: I::Ty,
1197        _ty_def_id: I::DefId,
1198        a_args: I::GenericArgs,
1199        b_args: I::GenericArgs,
1200        _mk: impl FnOnce(I::GenericArgs) -> I::Ty,
1201    ) -> RelateResult<I, I::Ty> {
1202        rustc_type_ir::relate::relate_args_invariantly(self, a_args, b_args)?;
1203        Ok(a_ty)
1204    }
1205
1206    fn relate_with_variance<T: Relate<I>>(
1207        &mut self,
1208        _variance: Variance,
1209        _info: VarianceDiagInfo<I>,
1210        a: T,
1211        b: T,
1212    ) -> RelateResult<I, T> {
1213        // FIXME(-Zassumptions-on-binders): bivariance is important for opaque type args so
1214        // we should actually handle variance in some way here.
1215        self.relate(a, b)
1216    }
1217
1218    fn tys(&mut self, a: I::Ty, b: I::Ty) -> RelateResult<I, I::Ty> {
1219        rustc_type_ir::relate::structurally_relate_tys(self, a, b)
1220    }
1221
1222    fn regions(&mut self, a: Region<I>, b: Region<I>) -> RelateResult<I, Region<I>> {
1223        if a != b {
1224            self.region_constraints.push(LeafRegionConstraint::RegionOutlives(a, b, ()));
1225            self.region_constraints.push(LeafRegionConstraint::RegionOutlives(b, a, ()));
1226        }
1227        Ok(a)
1228    }
1229
1230    fn consts(&mut self, a: I::Const, b: I::Const) -> RelateResult<I, I::Const> {
1231        rustc_type_ir::relate::structurally_relate_consts(self, a, b)
1232    }
1233
1234    fn binders<T>(&mut self, a: Binder<I, T>, b: Binder<I, T>) -> RelateResult<I, Binder<I, T>>
1235    where
1236        T: Relate<I>,
1237    {
1238        self.infcx.enter_forall_with_empty_assumptions(a, |a| {
1239            let u = self.infcx.universe();
1240            self.infcx.insert_placeholder_assumptions(u, Some(Assumptions::empty()));
1241            let b = self.infcx.instantiate_binder_with_infer(b);
1242            self.relate(a, b)
1243        })?;
1244
1245        self.infcx.enter_forall_with_empty_assumptions(b, |b| {
1246            let u = self.infcx.universe();
1247            self.infcx.insert_placeholder_assumptions(u, Some(Assumptions::empty()));
1248            let a = self.infcx.instantiate_binder_with_infer(a);
1249            self.relate(a, b)
1250        })?;
1251
1252        Ok(a)
1253    }
1254}