Skip to main content

rustc_infer/infer/outlives/
obligations.rs

1//! Code that handles "type-outlives" constraints like `T: 'a`. This
2//! is based on the `push_outlives_components` function defined in rustc_infer,
3//! but it adds a bit of heuristics on top, in particular to deal with
4//! associated types and projections.
5//!
6//! When we process a given `T: 'a` obligation, we may produce two
7//! kinds of constraints for the region inferencer:
8//!
9//! - Relationships between inference variables and other regions.
10//!   For example, if we have `&'?0 u32: 'a`, then we would produce
11//!   a constraint that `'a <= '?0`.
12//! - "Verifys" that must be checked after inferencing is done.
13//!   For example, if we know that, for some type parameter `T`,
14//!   `T: 'a + 'b`, and we have a requirement that `T: '?1`,
15//!   then we add a "verify" that checks that `'?1 <= 'a || '?1 <= 'b`.
16//!   - Note the difference with the previous case: here, the region
17//!     variable must be less than something else, so this doesn't
18//!     affect how inference works (it finds the smallest region that
19//!     will do); it's just a post-condition that we have to check.
20//!
21//! **The key point is that once this function is done, we have
22//! reduced all of our "type-region outlives" obligations into relationships
23//! between individual regions.**
24//!
25//! One key input to this function is the set of "region-bound pairs".
26//! These are basically the relationships between type parameters and
27//! regions that are in scope at the point where the outlives
28//! obligation was incurred. **When type-checking a function,
29//! particularly in the face of closures, this is not known until
30//! regionck runs!** This is because some of those bounds come
31//! from things we have yet to infer.
32//!
33//! Consider:
34//!
35//! ```
36//! fn bar<T>(a: T, b: impl for<'a> Fn(&'a T)) {}
37//! fn foo<T>(x: T) {
38//!     bar(x, |y| { /* ... */})
39//!     //      ^ closure arg
40//! }
41//! ```
42//!
43//! Here, the type of `y` may involve inference variables and the
44//! like, and it may also contain implied bounds that are needed to
45//! type-check the closure body (e.g., here it informs us that `T`
46//! outlives the late-bound region `'a`).
47//!
48//! Note that by delaying the gathering of implied bounds until all
49//! inference information is known, we may find relationships between
50//! bound regions and other regions in the environment. For example,
51//! when we first check a closure like the one expected as argument
52//! to `foo`:
53//!
54//! ```
55//! fn foo<U, F: for<'a> FnMut(&'a U)>(_f: F) {}
56//! ```
57//!
58//! the type of the closure's first argument would be `&'a ?U`. We
59//! might later infer `?U` to something like `&'b u32`, which would
60//! imply that `'b: 'a`.
61
62use rustc_data_structures::transitive_relation::TransitiveRelation;
63use rustc_data_structures::undo_log::UndoLogs;
64use rustc_middle::bug;
65use rustc_middle::mir::ConstraintCategory;
66use rustc_middle::ty::outlives::{Component, push_outlives_components};
67use rustc_middle::ty::{
68    self, GenericArgKind, GenericArgsRef, PolyTypeOutlivesPredicate, Region, RegionExt, RegionVid,
69    Ty, TyCtxt, TypeVisitableExt, eager_resolve_vars,
70};
71use rustc_span::Span;
72use smallvec::smallvec;
73use tracing::{debug, instrument};
74
75use super::env::OutlivesEnvironment;
76use crate::infer::outlives::env::RegionBoundPairs;
77use crate::infer::outlives::verify::VerifyBoundCx;
78use crate::infer::snapshot::undo_log::UndoLog;
79use crate::infer::{
80    self, GenericKind, InferCtxt, SubregionOrigin, TypeOutlivesConstraint, VerifyBound,
81};
82use crate::traits::{ObligationCause, ObligationCauseCode};
83
84impl<'tcx> InferCtxt<'tcx> {
85    pub fn register_outlives_constraint(
86        &self,
87        ty::OutlivesPredicate(arg, r2): ty::ArgOutlivesPredicate<'tcx>,
88        vis: ty::VisibleForLeakCheck,
89        cause: &ObligationCause<'tcx>,
90    ) {
91        match arg.kind() {
92            ty::GenericArgKind::Lifetime(r1) => {
93                self.register_region_outlives_constraint(ty::OutlivesPredicate(r1, r2), vis, cause);
94            }
95            ty::GenericArgKind::Type(ty1) => {
96                self.register_type_outlives_constraint(ty1, r2, cause);
97            }
98            ty::GenericArgKind::Const(_) => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
99        }
100    }
101
102    pub fn register_region_eq_constraint(
103        &self,
104        ty::RegionEqPredicate(r_a, r_b): ty::RegionEqPredicate<'tcx>,
105        vis: ty::VisibleForLeakCheck,
106        cause: &ObligationCause<'tcx>,
107    ) {
108        let origin = SubregionOrigin::from_obligation_cause(cause, || {
109            SubregionOrigin::RelateRegionParamBound(cause.span, None)
110        });
111        self.equate_regions(origin, r_a, r_b, vis);
112    }
113
114    pub fn register_region_outlives_constraint(
115        &self,
116        ty::OutlivesPredicate(r_a, r_b): ty::RegionOutlivesPredicate<'tcx>,
117        vis: ty::VisibleForLeakCheck,
118        cause: &ObligationCause<'tcx>,
119    ) {
120        let origin = SubregionOrigin::from_obligation_cause(cause, || {
121            SubregionOrigin::RelateRegionParamBound(cause.span, None)
122        });
123        // `'a: 'b` ==> `'b <= 'a`
124        self.sub_regions(origin, r_b, r_a, vis);
125    }
126
127    /// Registers that the given region obligation must be resolved
128    /// from within the scope of `body_id`. These regions are enqueued
129    /// and later processed by regionck, when full type information is
130    /// available (see `region_obligations` field for more
131    /// information).
132    #[allow(clippy :: suspicious_else_formatting)]
{
    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("register_type_outlives_constraint_inner",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(132u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("obligation");
                                                        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(&obligation)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let mut inner = self.inner.borrow_mut();
            inner.undo_log.push(UndoLog::PushTypeOutlivesConstraint);
            inner.region_obligations.push(obligation);
        }
    }
}#[instrument(level = "debug", skip(self))]
133    pub fn register_type_outlives_constraint_inner(
134        &self,
135        obligation: TypeOutlivesConstraint<'tcx>,
136    ) {
137        let mut inner = self.inner.borrow_mut();
138        inner.undo_log.push(UndoLog::PushTypeOutlivesConstraint);
139        inner.region_obligations.push(obligation);
140    }
141
142    pub fn register_type_outlives_constraint(
143        &self,
144        sup_type: Ty<'tcx>,
145        sub_region: Region<'tcx>,
146        cause: &ObligationCause<'tcx>,
147    ) {
148        if !!self.tcx.assumptions_on_binders() {
    ::core::panicking::panic("assertion failed: !self.tcx.assumptions_on_binders()")
};assert!(!self.tcx.assumptions_on_binders());
149
150        // `is_global` means the type has no params, infer, placeholder, or non-`'static`
151        // free regions. If the type has none of these things, then we can skip registering
152        // this outlives obligation since it has no components which affect lifetime
153        // checking in an interesting way.
154        if sup_type.is_global() {
155            return;
156        }
157
158        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:158",
                        "rustc_infer::infer::outlives::obligations",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                        ::tracing_core::__macro_support::Option::Some(158u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("sup_type")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("sup_type");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("sub_region")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("sub_region");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("cause")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("cause");
                                            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(&sup_type)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sub_region)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&cause)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?sup_type, ?sub_region, ?cause);
159        let origin = SubregionOrigin::from_obligation_cause(cause, || {
160            SubregionOrigin::RelateParamBound(
161                cause.span,
162                sup_type,
163                match cause.code().peel_derives() {
164                    ObligationCauseCode::WhereClause(_, span)
165                    | ObligationCauseCode::WhereClauseInExpr(_, span, ..)
166                    | ObligationCauseCode::OpaqueTypeBound(span, _)
167                        if !span.is_dummy() =>
168                    {
169                        Some(*span)
170                    }
171                    _ => None,
172                },
173            )
174        });
175
176        self.register_type_outlives_constraint_inner(TypeOutlivesConstraint {
177            sup_type,
178            sub_region,
179            origin,
180        });
181    }
182
183    /// Trait queries just want to pass back type obligations "as is"
184    pub fn take_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
185        if !!self.in_snapshot() {
    {
        ::core::panicking::panic_fmt(format_args!("cannot take registered region obligations in a snapshot"));
    }
};assert!(!self.in_snapshot(), "cannot take registered region obligations in a snapshot");
186        std::mem::take(&mut self.inner.borrow_mut().region_obligations)
187    }
188
189    pub fn clone_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
190        self.inner.borrow().region_obligations.clone()
191    }
192
193    pub fn register_region_assumption(&self, assumption: ty::ArgOutlivesPredicate<'tcx>) {
194        let mut inner = self.inner.borrow_mut();
195        inner.undo_log.push(UndoLog::PushRegionAssumption);
196        inner.region_assumptions.push(assumption);
197    }
198
199    pub fn take_registered_region_assumptions(&self) -> Vec<ty::ArgOutlivesPredicate<'tcx>> {
200        if !!self.in_snapshot() {
    {
        ::core::panicking::panic_fmt(format_args!("cannot take registered region assumptions in a snapshot"));
    }
};assert!(!self.in_snapshot(), "cannot take registered region assumptions in a snapshot");
201        std::mem::take(&mut self.inner.borrow_mut().region_assumptions)
202    }
203
204    pub fn destructure_solver_region_constraints_for_regionck(
205        &self,
206        outlives_env: &OutlivesEnvironment<'tcx>,
207        span: Span,
208    ) {
209        let assumptions = rustc_type_ir::region_constraint::Assumptions::new(
210            outlives_env.known_type_outlives().into_iter().cloned().collect(),
211            outlives_env.free_region_map().relation.clone(),
212        );
213        self.destructure_solver_region_constraints(assumptions, self, span);
214    }
215
216    pub fn destructure_solver_region_constraints_for_borrowck(
217        &self,
218        // this is always ConstraintConversion but lol
219        conversion: impl TypeOutlivesDelegate<'tcx>,
220        known_type_outlives: &[PolyTypeOutlivesPredicate<'tcx>],
221        region_outlives: TransitiveRelation<RegionVid>,
222        span: Span,
223    ) {
224        let assumptions = rustc_type_ir::region_constraint::Assumptions::new(
225            known_type_outlives.into_iter().cloned().collect(),
226            region_outlives.maybe_map(|r| Some(Region::new_var(self.tcx, r))).unwrap(),
227        );
228        self.destructure_solver_region_constraints(assumptions, conversion, span);
229    }
230
231    #[allow(clippy :: suspicious_else_formatting)]
{
    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_solver_region_constraints",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(231u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("assumptions")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("assumptions");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("span")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("span");
                                                        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(&assumptions)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if !self.tcx.assumptions_on_binders() {
                ::core::panicking::panic("assertion failed: self.tcx.assumptions_on_binders()")
            };
            if !self.next_trait_solver() {
                ::core::panicking::panic("assertion failed: self.next_trait_solver()")
            };
            let origin = SubregionOrigin::SolverRegionConstraint(span);
            let category = origin.to_constraint_category();
            let constraint =
                self.inner.borrow().solver_region_constraint_storage.get_constraint();
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:245",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(245u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::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::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(&constraint)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let constraint =
                rustc_type_ir::region_constraint::destructure_type_outlives_constraints_in_root(self,
                    constraint, &assumptions);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:252",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(252u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::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::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(&constraint)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let constraint =
                rustc_type_ir::region_constraint::evaluate_solver_constraint(&constraint);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:254",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(254u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::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::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(&constraint)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let mut constraints =
                ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                        [constraint]));
            while let Some(c) = constraints.pop() {
                use rustc_type_ir::region_constraint::RegionConstraint::*;
                match c {
                    Ambiguity => {
                        self.dcx().err("unable to satisfy constraints involving placeholders due to unknown implied bounds");
                    }
                    RegionOutlives(a, b) => {
                        conversion.push_sub_region_constraint(origin.clone(), b, a,
                            category);
                    }
                    And(nested) | Or(nested) => constraints.extend(nested),
                    AliasTyOutlivesViaEnv(..) | PlaceholderTyOutlives(..) =>
                        ::core::panicking::panic("internal error: entered unreachable code"),
                }
            }
        }
    }
}#[instrument(level = "debug", skip(self, conversion))]
232    pub fn destructure_solver_region_constraints(
233        &self,
234        assumptions: rustc_type_ir::region_constraint::Assumptions<TyCtxt<'tcx>>,
235        mut conversion: impl TypeOutlivesDelegate<'tcx>,
236        span: Span,
237    ) {
238        assert!(self.tcx.assumptions_on_binders());
239        assert!(self.next_trait_solver());
240
241        let origin = SubregionOrigin::SolverRegionConstraint(span);
242        let category = origin.to_constraint_category();
243
244        let constraint = self.inner.borrow().solver_region_constraint_storage.get_constraint();
245        debug!(?constraint);
246        let constraint =
247            rustc_type_ir::region_constraint::destructure_type_outlives_constraints_in_root(
248                self,
249                constraint,
250                &assumptions,
251            );
252        debug!(?constraint);
253        let constraint = rustc_type_ir::region_constraint::evaluate_solver_constraint(&constraint);
254        debug!(?constraint);
255
256        let mut constraints = vec![constraint];
257        while let Some(c) = constraints.pop() {
258            use rustc_type_ir::region_constraint::RegionConstraint::*;
259
260            match c {
261                Ambiguity => {
262                    self.dcx().err("unable to satisfy constraints involving placeholders due to unknown implied bounds");
263                }
264                RegionOutlives(a, b) => {
265                    conversion.push_sub_region_constraint(
266                        origin.clone(),
267                        // we flip these because regionck is silly :>
268                        b,
269                        a,
270                        category,
271                    );
272                }
273                // FIXME(-Zassumptions-on-binders): actually implement OR as an  OR
274                And(nested) | Or(nested) => constraints.extend(nested),
275                AliasTyOutlivesViaEnv(..) | PlaceholderTyOutlives(..) => unreachable!(),
276            }
277        }
278    }
279
280    /// Process the region obligations that must be proven (during
281    /// `regionck`) for the given `body_id`, given information about
282    /// the region bounds in scope and so forth.
283    ///
284    /// See the `region_obligations` field of `InferCtxt` for some
285    /// comments about how this function fits into the overall expected
286    /// flow of the inferencer. The key point is that it is
287    /// invoked after all type-inference variables have been bound --
288    /// right before lexical region resolution.
289    #[allow(clippy :: suspicious_else_formatting)]
{
    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("process_registered_region_obligations",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(289u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("span")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("span");
                                                        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(&span)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if !!self.in_snapshot() {
                {
                    ::core::panicking::panic_fmt(format_args!("cannot process registered region obligations in a snapshot"));
                }
            };
            if self.tcx.assumptions_on_binders() {
                self.destructure_solver_region_constraints_for_regionck(outlives_env,
                    span);
            }
            for iteration in 0.. {
                let my_region_obligations =
                    self.take_registered_region_obligations();
                if my_region_obligations.is_empty() { break; }
                if !self.tcx.recursion_limit().value_within_limit(iteration) {
                    ::rustc_middle::util::bug::bug_fmt(format_args!("unexpected overflowed when processing region obligations: {0:#?}",
                            my_region_obligations));
                }
                for TypeOutlivesConstraint { sup_type, sub_region, origin } in
                    my_region_obligations {
                    let (sup_type, sub_region) =
                        eager_resolve_vars(self, (sup_type, sub_region));
                    if self.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
                            &&
                            outlives_env.higher_ranked_assumptions().contains(&ty::OutlivesPredicate(sup_type.into(),
                                        sub_region)) {
                        continue;
                    }
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:331",
                                            "rustc_infer::infer::outlives::obligations",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                            ::tracing_core::__macro_support::Option::Some(331u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                            ::tracing_core::field::FieldSet::new(&[{
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("sup_type")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("sup_type");
                                                                NAME.as_str()
                                                            },
                                                            {
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("sub_region")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("sub_region");
                                                                NAME.as_str()
                                                            },
                                                            {
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("origin")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("origin");
                                                                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(&sup_type)
                                                                as &dyn ::tracing::field::Value)),
                                                    (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sub_region)
                                                                as &dyn ::tracing::field::Value)),
                                                    (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                                as &dyn ::tracing::field::Value))])
                                });
                        } else { ; }
                    };
                    let outlives =
                        &mut TypeOutlives::new(self, self.tcx,
                                outlives_env.region_bound_pairs(), None,
                                outlives_env.known_type_outlives());
                    let category = origin.to_constraint_category();
                    outlives.type_must_outlive(origin, sup_type, sub_region,
                        category);
                }
            }
        }
    }
}#[instrument(level = "debug", skip(self, outlives_env))]
290    pub fn process_registered_region_obligations(
291        &self,
292        outlives_env: &OutlivesEnvironment<'tcx>,
293        span: Span,
294    ) {
295        assert!(!self.in_snapshot(), "cannot process registered region obligations in a snapshot");
296
297        if self.tcx.assumptions_on_binders() {
298            self.destructure_solver_region_constraints_for_regionck(outlives_env, span);
299        }
300
301        // Must loop since the process of normalizing may itself register region obligations.
302        for iteration in 0.. {
303            let my_region_obligations = self.take_registered_region_obligations();
304            if my_region_obligations.is_empty() {
305                break;
306            }
307
308            if !self.tcx.recursion_limit().value_within_limit(iteration) {
309                // This may actually be reachable. If so, we should convert
310                // this to a proper error/consider whether we should detect
311                // this somewhere else.
312                bug!(
313                    "unexpected overflowed when processing region obligations: {my_region_obligations:#?}"
314                );
315            }
316
317            for TypeOutlivesConstraint { sup_type, sub_region, origin } in my_region_obligations {
318                // `TypeOutlives` is structural, so we should try to opportunistically resolve all
319                // region vids before processing regions, so we have a better chance to match clauses
320                // in our param-env.
321                let (sup_type, sub_region) = eager_resolve_vars(self, (sup_type, sub_region));
322
323                if self.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
324                    && outlives_env
325                        .higher_ranked_assumptions()
326                        .contains(&ty::OutlivesPredicate(sup_type.into(), sub_region))
327                {
328                    continue;
329                }
330
331                debug!(?sup_type, ?sub_region, ?origin);
332
333                let outlives = &mut TypeOutlives::new(
334                    self,
335                    self.tcx,
336                    outlives_env.region_bound_pairs(),
337                    None,
338                    outlives_env.known_type_outlives(),
339                );
340                let category = origin.to_constraint_category();
341                outlives.type_must_outlive(origin, sup_type, sub_region, category);
342            }
343        }
344    }
345}
346
347/// The `TypeOutlives` struct has the job of "lowering" a `T: 'a`
348/// obligation into a series of `'a: 'b` constraints and "verify"s, as
349/// described on the module comment. The final constraints are emitted
350/// via a "delegate" of type `D` -- this is usually the `infcx`, which
351/// accrues them into the `region_obligations` code, but for NLL we
352/// use something else.
353pub struct TypeOutlives<'cx, 'tcx, D>
354where
355    D: TypeOutlivesDelegate<'tcx>,
356{
357    // See the comments on `process_registered_region_obligations` for the meaning
358    // of these fields.
359    delegate: D,
360    tcx: TyCtxt<'tcx>,
361    verify_bound: VerifyBoundCx<'cx, 'tcx>,
362}
363
364pub trait TypeOutlivesDelegate<'tcx> {
365    fn push_sub_region_constraint(
366        &mut self,
367        origin: SubregionOrigin<'tcx>,
368        a: ty::Region<'tcx>,
369        b: ty::Region<'tcx>,
370        constraint_category: ConstraintCategory<'tcx>,
371    );
372
373    fn push_verify(
374        &mut self,
375        origin: SubregionOrigin<'tcx>,
376        kind: GenericKind<'tcx>,
377        a: ty::Region<'tcx>,
378        bound: VerifyBound<'tcx>,
379    );
380}
381
382impl<'cx, 'tcx, D> TypeOutlives<'cx, 'tcx, D>
383where
384    D: TypeOutlivesDelegate<'tcx>,
385{
386    pub fn new(
387        delegate: D,
388        tcx: TyCtxt<'tcx>,
389        region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
390        implicit_region_bound: Option<ty::Region<'tcx>>,
391        caller_bounds: &'cx [ty::PolyTypeOutlivesPredicate<'tcx>],
392    ) -> Self {
393        Self {
394            delegate,
395            tcx,
396            verify_bound: VerifyBoundCx::new(
397                tcx,
398                region_bound_pairs,
399                implicit_region_bound,
400                caller_bounds,
401            ),
402        }
403    }
404
405    /// Adds constraints to inference such that `T: 'a` holds (or
406    /// reports an error if it cannot).
407    ///
408    /// # Parameters
409    ///
410    /// - `origin`, the reason we need this constraint
411    /// - `ty`, the type `T`
412    /// - `region`, the region `'a`
413    #[allow(clippy :: suspicious_else_formatting)]
{
    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("type_must_outlive",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(413u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("origin")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("origin");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("region")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("region");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("category")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("category");
                                                        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(&origin)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&category)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if !!ty.has_escaping_bound_vars() {
                ::core::panicking::panic("assertion failed: !ty.has_escaping_bound_vars()")
            };
            if true {
                if !!ty.has_non_region_infer() {
                    ::core::panicking::panic("assertion failed: !ty.has_non_region_infer()")
                };
            };
            if true {
                if !(!self.tcx.next_trait_solver_globally() ||
                            !ty.has_non_rigid_aliases()) {
                    {
                        ::core::panicking::panic_fmt(format_args!("{0:?} has non-rigid aliases",
                                ty));
                    }
                };
            };
            let mut components = ::smallvec::SmallVec::new();
            push_outlives_components(self.tcx, ty, &mut components);
            self.components_must_outlive(origin, &components, region,
                category);
        }
    }
}#[instrument(level = "debug", skip(self))]
414    pub fn type_must_outlive(
415        &mut self,
416        origin: infer::SubregionOrigin<'tcx>,
417        ty: Ty<'tcx>,
418        region: ty::Region<'tcx>,
419        category: ConstraintCategory<'tcx>,
420    ) {
421        assert!(!ty.has_escaping_bound_vars());
422        debug_assert!(!ty.has_non_region_infer());
423        debug_assert!(
424            !self.tcx.next_trait_solver_globally() || !ty.has_non_rigid_aliases(),
425            "{ty:?} has non-rigid aliases"
426        );
427
428        let mut components = smallvec![];
429        push_outlives_components(self.tcx, ty, &mut components);
430        self.components_must_outlive(origin, &components, region, category);
431    }
432
433    fn components_must_outlive(
434        &mut self,
435        origin: infer::SubregionOrigin<'tcx>,
436        components: &[Component<TyCtxt<'tcx>>],
437        region: ty::Region<'tcx>,
438        category: ConstraintCategory<'tcx>,
439    ) {
440        for component in components.iter() {
441            let origin = origin.clone();
442            match component {
443                Component::Region(region1) => {
444                    self.delegate.push_sub_region_constraint(origin, region, *region1, category);
445                }
446                Component::Param(param_ty) => {
447                    self.param_ty_must_outlive(origin, region, *param_ty);
448                }
449                Component::Placeholder(placeholder_ty) => {
450                    self.placeholder_ty_must_outlive(origin, region, *placeholder_ty);
451                }
452                Component::Alias(is_rigid, alias_ty) => {
453                    if true {
    {
        match (&*is_rigid, &ty::IsRigid::yes_if_next_solver(self.tcx)) {
            (left_val, right_val) => {
                if !(*left_val == *right_val) {
                    let kind = ::core::panicking::AssertKind::Eq;
                    ::core::panicking::assert_failed(kind, &*left_val,
                        &*right_val, ::core::option::Option::None);
                }
            }
        }
    };
};debug_assert_eq!(*is_rigid, ty::IsRigid::yes_if_next_solver(self.tcx));
454                    self.alias_ty_must_outlive(origin, region, *alias_ty);
455                }
456                Component::EscapingAlias(subcomponents) => {
457                    self.components_must_outlive(origin, subcomponents, region, category);
458                }
459                Component::UnresolvedInferenceVariable(v) => {
460                    // Ignore this, we presume it will yield an error later,
461                    // since if a type variable is not resolved by this point
462                    // it never will be.
463                    self.tcx.dcx().span_delayed_bug(
464                        origin.span(),
465                        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("unresolved inference variable in outlives: {0:?}",
                v))
    })format!("unresolved inference variable in outlives: {v:?}"),
466                    );
467                }
468            }
469        }
470    }
471
472    #[allow(clippy :: suspicious_else_formatting)]
{
    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("param_ty_must_outlive",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(472u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("origin")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("origin");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("region")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("region");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("param_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("param_ty");
                                                        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(&origin)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&param_ty)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let verify_bound =
                self.verify_bound.param_or_placeholder_bound(param_ty.to_ty(self.tcx));
            self.delegate.push_verify(origin, GenericKind::Param(param_ty),
                region, verify_bound);
        }
    }
}#[instrument(level = "debug", skip(self))]
473    fn param_ty_must_outlive(
474        &mut self,
475        origin: infer::SubregionOrigin<'tcx>,
476        region: ty::Region<'tcx>,
477        param_ty: ty::ParamTy,
478    ) {
479        let verify_bound = self.verify_bound.param_or_placeholder_bound(param_ty.to_ty(self.tcx));
480        self.delegate.push_verify(origin, GenericKind::Param(param_ty), region, verify_bound);
481    }
482
483    #[allow(clippy :: suspicious_else_formatting)]
{
    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("placeholder_ty_must_outlive",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(483u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("origin")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("origin");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("region")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("region");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("placeholder_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("placeholder_ty");
                                                        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(&origin)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&placeholder_ty)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let verify_bound =
                self.verify_bound.param_or_placeholder_bound(Ty::new_placeholder(self.tcx,
                        placeholder_ty));
            self.delegate.push_verify(origin,
                GenericKind::Placeholder(placeholder_ty), region,
                verify_bound);
        }
    }
}#[instrument(level = "debug", skip(self))]
484    fn placeholder_ty_must_outlive(
485        &mut self,
486        origin: infer::SubregionOrigin<'tcx>,
487        region: ty::Region<'tcx>,
488        placeholder_ty: ty::PlaceholderType<'tcx>,
489    ) {
490        let verify_bound = self
491            .verify_bound
492            .param_or_placeholder_bound(Ty::new_placeholder(self.tcx, placeholder_ty));
493        self.delegate.push_verify(
494            origin,
495            GenericKind::Placeholder(placeholder_ty),
496            region,
497            verify_bound,
498        );
499    }
500
501    #[allow(clippy :: suspicious_else_formatting)]
{
    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_ty_must_outlive",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(501u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("origin")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("origin");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("region")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("region");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("alias_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("alias_ty");
                                                        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(&origin)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&alias_ty)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if alias_ty.args.is_empty() { return; }
            if alias_ty.has_non_region_infer() {
                self.tcx.dcx().span_delayed_bug(origin.span(),
                    "an alias has infers during region solving");
                return;
            }
            let trait_bounds: Vec<_> =
                rustc_type_ir::outlives::declared_bounds_from_definition(self.tcx,
                        alias_ty).collect();
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:540",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(540u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("trait_bounds")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("trait_bounds");
                                                        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(&trait_bounds)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let approx_env_bounds =
                self.verify_bound.approx_declared_bounds_from_env(alias_ty);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:546",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(546u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("approx_env_bounds")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("approx_env_bounds");
                                                        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(&approx_env_bounds)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let kind = alias_ty.kind;
            if approx_env_bounds.is_empty() && trait_bounds.is_empty() &&
                    (alias_ty.has_infer_regions() ||
                            #[allow(non_exhaustive_omitted_patterns)] match kind {
                                ty::Opaque { .. } => true,
                                _ => false,
                            }) {
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:567",
                                        "rustc_infer::infer::outlives::obligations",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                        ::tracing_core::__macro_support::Option::Some(567u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                        ::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!("no declared bounds")
                                                            as &dyn ::tracing::field::Value))])
                            });
                    } else { ; }
                };
                let opt_variances = self.tcx.opt_alias_variances(kind);
                self.args_must_outlive(alias_ty.args, origin, region,
                    opt_variances);
                return;
            }
            if !trait_bounds.is_empty() &&
                    trait_bounds[1..].iter().map(|r|
                                    Some(*r)).chain(approx_env_bounds.iter().map(|b|
                                    b.map_bound(|b|
                                                b.1).no_bound_vars())).all(|b| b == Some(trait_bounds[0])) {
                let unique_bound = trait_bounds[0];
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:598",
                                        "rustc_infer::infer::outlives::obligations",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                        ::tracing_core::__macro_support::Option::Some(598u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                        ::tracing_core::field::FieldSet::new(&[{
                                                            const NAME:
                                                                ::tracing::__macro_support::FieldName<{
                                                                    ::tracing::__macro_support::FieldName::len("unique_bound")
                                                                }> =
                                                                ::tracing::__macro_support::FieldName::new("unique_bound");
                                                            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(&unique_bound)
                                                            as &dyn ::tracing::field::Value))])
                            });
                    } else { ; }
                };
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:599",
                                        "rustc_infer::infer::outlives::obligations",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                        ::tracing_core::__macro_support::Option::Some(599u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                        ::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!("unique declared bound appears in trait ref")
                                                            as &dyn ::tracing::field::Value))])
                            });
                    } else { ; }
                };
                let category = origin.to_constraint_category();
                self.delegate.push_sub_region_constraint(origin, region,
                    unique_bound, category);
                return;
            }
            let verify_bound = self.verify_bound.alias_bound(alias_ty);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:611",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(611u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::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!("alias_must_outlive: pushing {0:?}",
                                                                verify_bound) as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            self.delegate.push_verify(origin, GenericKind::Alias(alias_ty),
                region, verify_bound);
        }
    }
}#[instrument(level = "debug", skip(self))]
502    fn alias_ty_must_outlive(
503        &mut self,
504        origin: infer::SubregionOrigin<'tcx>,
505        region: ty::Region<'tcx>,
506        alias_ty: ty::AliasTy<'tcx>,
507    ) {
508        // An optimization for a common case with opaque types.
509        if alias_ty.args.is_empty() {
510            return;
511        }
512
513        if alias_ty.has_non_region_infer() {
514            self.tcx
515                .dcx()
516                .span_delayed_bug(origin.span(), "an alias has infers during region solving");
517            return;
518        }
519
520        // This case is thorny for inference. The fundamental problem is
521        // that there are many cases where we have choice, and inference
522        // doesn't like choice (the current region inference in
523        // particular). :) First off, we have to choose between using the
524        // OutlivesProjectionEnv, OutlivesProjectionTraitDef, and
525        // OutlivesProjectionComponent rules, any one of which is
526        // sufficient. If there are no inference variables involved, it's
527        // not hard to pick the right rule, but if there are, we're in a
528        // bit of a catch 22: if we picked which rule we were going to
529        // use, we could add constraints to the region inference graph
530        // that make it apply, but if we don't add those constraints, the
531        // rule might not apply (but another rule might). For now, we err
532        // on the side of adding too few edges into the graph.
533
534        // Compute the bounds we can derive from the trait definition.
535        // These are guaranteed to apply, no matter the inference
536        // results.
537        let trait_bounds: Vec<_> =
538            rustc_type_ir::outlives::declared_bounds_from_definition(self.tcx, alias_ty).collect();
539
540        debug!(?trait_bounds);
541
542        // Compute the bounds we can derive from the environment. This
543        // is an "approximate" match -- in some cases, these bounds
544        // may not apply.
545        let approx_env_bounds = self.verify_bound.approx_declared_bounds_from_env(alias_ty);
546        debug!(?approx_env_bounds);
547
548        // If declared bounds list is empty, the only applicable rule is
549        // OutlivesProjectionComponent. If there are inference variables,
550        // then, we can break down the outlives into more primitive
551        // components without adding unnecessary edges.
552        //
553        // If there are *no* inference variables, however, we COULD do
554        // this, but we choose not to, because the error messages are less
555        // good. For example, a requirement like `T::Item: 'r` would be
556        // translated to a requirement that `T: 'r`; when this is reported
557        // to the user, it will thus say "T: 'r must hold so that T::Item:
558        // 'r holds". But that makes it sound like the only way to fix
559        // the problem is to add `T: 'r`, which isn't true. So, if there are no
560        // inference variables, we use a verify constraint instead of adding
561        // edges, which winds up enforcing the same condition.
562        let kind = alias_ty.kind;
563        if approx_env_bounds.is_empty()
564            && trait_bounds.is_empty()
565            && (alias_ty.has_infer_regions() || matches!(kind, ty::Opaque { .. }))
566        {
567            debug!("no declared bounds");
568            let opt_variances = self.tcx.opt_alias_variances(kind);
569            self.args_must_outlive(alias_ty.args, origin, region, opt_variances);
570            return;
571        }
572
573        // If we found a unique bound `'b` from the trait, and we
574        // found nothing else from the environment, then the best
575        // action is to require that `'b: 'r`, so do that.
576        //
577        // This is best no matter what rule we use:
578        //
579        // - OutlivesProjectionEnv: these would translate to the requirement that `'b:'r`
580        // - OutlivesProjectionTraitDef: these would translate to the requirement that `'b:'r`
581        // - OutlivesProjectionComponent: this would require `'b:'r`
582        //   in addition to other conditions
583        if !trait_bounds.is_empty()
584            && trait_bounds[1..]
585                .iter()
586                .map(|r| Some(*r))
587                .chain(
588                    // NB: The environment may contain `for<'a> T: 'a` style bounds.
589                    // In that case, we don't know if they are equal to the trait bound
590                    // or not (since we don't *know* whether the environment bound even applies),
591                    // so just map to `None` here if there are bound vars, ensuring that
592                    // the call to `all` will fail below.
593                    approx_env_bounds.iter().map(|b| b.map_bound(|b| b.1).no_bound_vars()),
594                )
595                .all(|b| b == Some(trait_bounds[0]))
596        {
597            let unique_bound = trait_bounds[0];
598            debug!(?unique_bound);
599            debug!("unique declared bound appears in trait ref");
600            let category = origin.to_constraint_category();
601            self.delegate.push_sub_region_constraint(origin, region, unique_bound, category);
602            return;
603        }
604
605        // Fallback to verifying after the fact that there exists a
606        // declared bound, or that all the components appearing in the
607        // projection outlive; in some cases, this may add insufficient
608        // edges into the inference graph, leading to inference failures
609        // even though a satisfactory solution exists.
610        let verify_bound = self.verify_bound.alias_bound(alias_ty);
611        debug!("alias_must_outlive: pushing {:?}", verify_bound);
612        self.delegate.push_verify(origin, GenericKind::Alias(alias_ty), region, verify_bound);
613    }
614
615    #[allow(clippy :: suspicious_else_formatting)]
{
    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("args_must_outlive",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(615u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("args")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("args");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("origin")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("origin");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("region")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("region");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("opt_variances")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("opt_variances");
                                                        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(&args)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&opt_variances)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let constraint = origin.to_constraint_category();
            for (index, arg) in args.iter().enumerate() {
                match arg.kind() {
                    GenericArgKind::Lifetime(lt) => {
                        let variance =
                            if let Some(variances) = opt_variances {
                                variances[index]
                            } else { ty::Invariant };
                        if variance == ty::Invariant {
                            self.delegate.push_sub_region_constraint(origin.clone(),
                                region, lt, constraint);
                        }
                    }
                    GenericArgKind::Type(ty) => {
                        self.type_must_outlive(origin.clone(), ty, region,
                            constraint);
                    }
                    GenericArgKind::Const(_) => {}
                }
            }
        }
    }
}#[instrument(level = "debug", skip(self))]
616    fn args_must_outlive(
617        &mut self,
618        args: GenericArgsRef<'tcx>,
619        origin: infer::SubregionOrigin<'tcx>,
620        region: ty::Region<'tcx>,
621        opt_variances: Option<&[ty::Variance]>,
622    ) {
623        let constraint = origin.to_constraint_category();
624        for (index, arg) in args.iter().enumerate() {
625            match arg.kind() {
626                GenericArgKind::Lifetime(lt) => {
627                    let variance = if let Some(variances) = opt_variances {
628                        variances[index]
629                    } else {
630                        ty::Invariant
631                    };
632                    if variance == ty::Invariant {
633                        self.delegate.push_sub_region_constraint(
634                            origin.clone(),
635                            region,
636                            lt,
637                            constraint,
638                        );
639                    }
640                }
641                GenericArgKind::Type(ty) => {
642                    self.type_must_outlive(origin.clone(), ty, region, constraint);
643                }
644                GenericArgKind::Const(_) => {
645                    // Const parameters don't impose constraints.
646                }
647            }
648        }
649    }
650}
651
652impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'tcx> {
653    fn push_sub_region_constraint(
654        &mut self,
655        origin: SubregionOrigin<'tcx>,
656        a: ty::Region<'tcx>,
657        b: ty::Region<'tcx>,
658        _constraint_category: ConstraintCategory<'tcx>,
659    ) {
660        // We don't do leak check in lexical region resolution
661        self.sub_regions(origin, a, b, ty::VisibleForLeakCheck::Unreachable)
662    }
663
664    fn push_verify(
665        &mut self,
666        origin: SubregionOrigin<'tcx>,
667        kind: GenericKind<'tcx>,
668        a: ty::Region<'tcx>,
669        bound: VerifyBound<'tcx>,
670    ) {
671        self.verify_generic_bound(origin, kind, a, bound)
672    }
673}