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, PolyTypeOutlivesClause, Region, RegionExt, RegionVid, Ty,
69    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::OutlivesClause(arg, r2): ty::ArgOutlivesClause<'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::OutlivesClause(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::OutlivesClause(r_a, r_b): ty::RegionOutlivesClause<'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 num_registered_region_obligations(&self) -> usize {
190        self.inner.borrow().region_obligations.len()
191    }
192
193    pub fn registered_region_obligations_since(
194        &self,
195        prev: usize,
196    ) -> Vec<TypeOutlivesConstraint<'tcx>> {
197        self.inner.borrow().region_obligations.iter().skip(prev).cloned().collect()
198    }
199
200    pub fn clone_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
201        self.inner.borrow().region_obligations.clone()
202    }
203
204    pub fn register_region_assumption(&self, assumption: ty::ArgOutlivesClause<'tcx>) {
205        let mut inner = self.inner.borrow_mut();
206        inner.undo_log.push(UndoLog::PushRegionAssumption);
207        inner.region_assumptions.push(assumption);
208    }
209
210    pub fn take_registered_region_assumptions(&self) -> Vec<ty::ArgOutlivesClause<'tcx>> {
211        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");
212        std::mem::take(&mut self.inner.borrow_mut().region_assumptions)
213    }
214
215    pub fn destructure_solver_region_constraints_for_regionck(
216        &self,
217        outlives_env: &OutlivesEnvironment<'tcx>,
218        span: Span,
219    ) {
220        let assumptions = rustc_type_ir::region_constraint::Assumptions::new(
221            outlives_env.known_type_outlives().into_iter().cloned().collect(),
222            outlives_env.free_region_map().relation.clone(),
223        );
224        self.destructure_solver_region_constraints(assumptions, self, span);
225    }
226
227    pub fn destructure_solver_region_constraints_for_borrowck(
228        &self,
229        // this is always ConstraintConversion but lol
230        conversion: impl TypeOutlivesDelegate<'tcx>,
231        known_type_outlives: &[PolyTypeOutlivesClause<'tcx>],
232        region_outlives: TransitiveRelation<RegionVid>,
233        span: Span,
234    ) {
235        let assumptions = rustc_type_ir::region_constraint::Assumptions::new(
236            known_type_outlives.into_iter().cloned().collect(),
237            region_outlives.maybe_map(|r| Some(Region::new_var(self.tcx, r))).unwrap(),
238        );
239        self.destructure_solver_region_constraints(assumptions, conversion, span);
240    }
241
242    #[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(242u32),
                                    ::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:256",
                                    "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(256u32),
                                    ::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:263",
                                    "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(263u32),
                                    ::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:265",
                                    "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(265u32),
                                    ::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))]
243    pub fn destructure_solver_region_constraints(
244        &self,
245        assumptions: rustc_type_ir::region_constraint::Assumptions<TyCtxt<'tcx>>,
246        mut conversion: impl TypeOutlivesDelegate<'tcx>,
247        span: Span,
248    ) {
249        assert!(self.tcx.assumptions_on_binders());
250        assert!(self.next_trait_solver());
251
252        let origin = SubregionOrigin::SolverRegionConstraint(span);
253        let category = origin.to_constraint_category();
254
255        let constraint = self.inner.borrow().solver_region_constraint_storage.get_constraint();
256        debug!(?constraint);
257        let constraint =
258            rustc_type_ir::region_constraint::destructure_type_outlives_constraints_in_root(
259                self,
260                constraint,
261                &assumptions,
262            );
263        debug!(?constraint);
264        let constraint = rustc_type_ir::region_constraint::evaluate_solver_constraint(&constraint);
265        debug!(?constraint);
266
267        let mut constraints = vec![constraint];
268        while let Some(c) = constraints.pop() {
269            use rustc_type_ir::region_constraint::RegionConstraint::*;
270
271            match c {
272                Ambiguity => {
273                    self.dcx().err("unable to satisfy constraints involving placeholders due to unknown implied bounds");
274                }
275                RegionOutlives(a, b) => {
276                    conversion.push_sub_region_constraint(
277                        origin.clone(),
278                        // we flip these because regionck is silly :>
279                        b,
280                        a,
281                        category,
282                    );
283                }
284                // FIXME(-Zassumptions-on-binders): actually implement OR as an  OR
285                And(nested) | Or(nested) => constraints.extend(nested),
286                AliasTyOutlivesViaEnv(..) | PlaceholderTyOutlives(..) => unreachable!(),
287            }
288        }
289    }
290
291    /// Process the region obligations that must be proven (during
292    /// `regionck`) for the given `body_id`, given information about
293    /// the region bounds in scope and so forth.
294    ///
295    /// See the `region_obligations` field of `InferCtxt` for some
296    /// comments about how this function fits into the overall expected
297    /// flow of the inferencer. The key point is that it is
298    /// invoked after all type-inference variables have been bound --
299    /// right before lexical region resolution.
300    #[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(300u32),
                                    ::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::OutlivesClause(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:342",
                                            "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(342u32),
                                            ::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))]
301    pub fn process_registered_region_obligations(
302        &self,
303        outlives_env: &OutlivesEnvironment<'tcx>,
304        span: Span,
305    ) {
306        assert!(!self.in_snapshot(), "cannot process registered region obligations in a snapshot");
307
308        if self.tcx.assumptions_on_binders() {
309            self.destructure_solver_region_constraints_for_regionck(outlives_env, span);
310        }
311
312        // Must loop since the process of normalizing may itself register region obligations.
313        for iteration in 0.. {
314            let my_region_obligations = self.take_registered_region_obligations();
315            if my_region_obligations.is_empty() {
316                break;
317            }
318
319            if !self.tcx.recursion_limit().value_within_limit(iteration) {
320                // This may actually be reachable. If so, we should convert
321                // this to a proper error/consider whether we should detect
322                // this somewhere else.
323                bug!(
324                    "unexpected overflowed when processing region obligations: {my_region_obligations:#?}"
325                );
326            }
327
328            for TypeOutlivesConstraint { sup_type, sub_region, origin } in my_region_obligations {
329                // `TypeOutlives` is structural, so we should try to opportunistically resolve all
330                // region vids before processing regions, so we have a better chance to match clauses
331                // in our param-env.
332                let (sup_type, sub_region) = eager_resolve_vars(self, (sup_type, sub_region));
333
334                if self.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
335                    && outlives_env
336                        .higher_ranked_assumptions()
337                        .contains(&ty::OutlivesClause(sup_type.into(), sub_region))
338                {
339                    continue;
340                }
341
342                debug!(?sup_type, ?sub_region, ?origin);
343
344                let outlives = &mut TypeOutlives::new(
345                    self,
346                    self.tcx,
347                    outlives_env.region_bound_pairs(),
348                    None,
349                    outlives_env.known_type_outlives(),
350                );
351                let category = origin.to_constraint_category();
352                outlives.type_must_outlive(origin, sup_type, sub_region, category);
353            }
354        }
355    }
356}
357
358/// The `TypeOutlives` struct has the job of "lowering" a `T: 'a`
359/// obligation into a series of `'a: 'b` constraints and "verify"s, as
360/// described on the module comment. The final constraints are emitted
361/// via a "delegate" of type `D` -- this is usually the `infcx`, which
362/// accrues them into the `region_obligations` code, but for NLL we
363/// use something else.
364pub struct TypeOutlives<'cx, 'tcx, D>
365where
366    D: TypeOutlivesDelegate<'tcx>,
367{
368    // See the comments on `process_registered_region_obligations` for the meaning
369    // of these fields.
370    delegate: D,
371    tcx: TyCtxt<'tcx>,
372    verify_bound: VerifyBoundCx<'cx, 'tcx>,
373}
374
375pub trait TypeOutlivesDelegate<'tcx> {
376    fn push_sub_region_constraint(
377        &mut self,
378        origin: SubregionOrigin<'tcx>,
379        a: ty::Region<'tcx>,
380        b: ty::Region<'tcx>,
381        constraint_category: ConstraintCategory<'tcx>,
382    );
383
384    fn push_verify(
385        &mut self,
386        origin: SubregionOrigin<'tcx>,
387        kind: GenericKind<'tcx>,
388        a: ty::Region<'tcx>,
389        bound: VerifyBound<'tcx>,
390    );
391}
392
393impl<'cx, 'tcx, D> TypeOutlives<'cx, 'tcx, D>
394where
395    D: TypeOutlivesDelegate<'tcx>,
396{
397    pub fn new(
398        delegate: D,
399        tcx: TyCtxt<'tcx>,
400        region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
401        implicit_region_bound: Option<ty::Region<'tcx>>,
402        caller_bounds: &'cx [ty::PolyTypeOutlivesClause<'tcx>],
403    ) -> Self {
404        Self {
405            delegate,
406            tcx,
407            verify_bound: VerifyBoundCx::new(
408                tcx,
409                region_bound_pairs,
410                implicit_region_bound,
411                caller_bounds,
412            ),
413        }
414    }
415
416    /// Adds constraints to inference such that `T: 'a` holds (or
417    /// reports an error if it cannot).
418    ///
419    /// # Parameters
420    ///
421    /// - `origin`, the reason we need this constraint
422    /// - `ty`, the type `T`
423    /// - `region`, the region `'a`
424    #[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(424u32),
                                    ::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))]
425    pub fn type_must_outlive(
426        &mut self,
427        origin: infer::SubregionOrigin<'tcx>,
428        ty: Ty<'tcx>,
429        region: ty::Region<'tcx>,
430        category: ConstraintCategory<'tcx>,
431    ) {
432        assert!(!ty.has_escaping_bound_vars());
433        debug_assert!(!ty.has_non_region_infer());
434        debug_assert!(
435            !self.tcx.next_trait_solver_globally() || !ty.has_non_rigid_aliases(),
436            "{ty:?} has non-rigid aliases"
437        );
438
439        let mut components = smallvec![];
440        push_outlives_components(self.tcx, ty, &mut components);
441        self.components_must_outlive(origin, &components, region, category);
442    }
443
444    fn components_must_outlive(
445        &mut self,
446        origin: infer::SubregionOrigin<'tcx>,
447        components: &[Component<TyCtxt<'tcx>>],
448        region: ty::Region<'tcx>,
449        category: ConstraintCategory<'tcx>,
450    ) {
451        for component in components.iter() {
452            let origin = origin.clone();
453            match component {
454                Component::Region(region1) => {
455                    self.delegate.push_sub_region_constraint(origin, region, *region1, category);
456                }
457                Component::Param(param_ty) => {
458                    self.param_ty_must_outlive(origin, region, *param_ty);
459                }
460                Component::Placeholder(placeholder_ty) => {
461                    self.placeholder_ty_must_outlive(origin, region, *placeholder_ty);
462                }
463                Component::Alias(is_rigid, alias_ty) => {
464                    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));
465                    self.alias_ty_must_outlive(origin, region, *alias_ty);
466                }
467                Component::EscapingAlias(subcomponents) => {
468                    self.components_must_outlive(origin, subcomponents, region, category);
469                }
470                Component::UnresolvedInferenceVariable(v) => {
471                    // Ignore this, we presume it will yield an error later,
472                    // since if a type variable is not resolved by this point
473                    // it never will be.
474                    self.tcx.dcx().span_delayed_bug(
475                        origin.span(),
476                        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("unresolved inference variable in outlives: {0:?}",
                v))
    })format!("unresolved inference variable in outlives: {v:?}"),
477                    );
478                }
479            }
480        }
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("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(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("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))]
484    fn param_ty_must_outlive(
485        &mut self,
486        origin: infer::SubregionOrigin<'tcx>,
487        region: ty::Region<'tcx>,
488        param_ty: ty::ParamTy,
489    ) {
490        let verify_bound = self.verify_bound.param_or_placeholder_bound(param_ty.to_ty(self.tcx));
491        self.delegate.push_verify(origin, GenericKind::Param(param_ty), region, verify_bound);
492    }
493
494    #[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(494u32),
                                    ::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))]
495    fn placeholder_ty_must_outlive(
496        &mut self,
497        origin: infer::SubregionOrigin<'tcx>,
498        region: ty::Region<'tcx>,
499        placeholder_ty: ty::PlaceholderType<'tcx>,
500    ) {
501        let verify_bound = self
502            .verify_bound
503            .param_or_placeholder_bound(Ty::new_placeholder(self.tcx, placeholder_ty));
504        self.delegate.push_verify(
505            origin,
506            GenericKind::Placeholder(placeholder_ty),
507            region,
508            verify_bound,
509        );
510    }
511
512    #[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(512u32),
                                    ::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:551",
                                    "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(551u32),
                                    ::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:557",
                                    "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(557u32),
                                    ::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:578",
                                        "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(578u32),
                                        ::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:609",
                                        "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(609u32),
                                        ::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:610",
                                        "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(610u32),
                                        ::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:622",
                                    "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(622u32),
                                    ::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))]
513    fn alias_ty_must_outlive(
514        &mut self,
515        origin: infer::SubregionOrigin<'tcx>,
516        region: ty::Region<'tcx>,
517        alias_ty: ty::AliasTy<'tcx>,
518    ) {
519        // An optimization for a common case with opaque types.
520        if alias_ty.args.is_empty() {
521            return;
522        }
523
524        if alias_ty.has_non_region_infer() {
525            self.tcx
526                .dcx()
527                .span_delayed_bug(origin.span(), "an alias has infers during region solving");
528            return;
529        }
530
531        // This case is thorny for inference. The fundamental problem is
532        // that there are many cases where we have choice, and inference
533        // doesn't like choice (the current region inference in
534        // particular). :) First off, we have to choose between using the
535        // OutlivesProjectionEnv, OutlivesProjectionTraitDef, and
536        // OutlivesProjectionComponent rules, any one of which is
537        // sufficient. If there are no inference variables involved, it's
538        // not hard to pick the right rule, but if there are, we're in a
539        // bit of a catch 22: if we picked which rule we were going to
540        // use, we could add constraints to the region inference graph
541        // that make it apply, but if we don't add those constraints, the
542        // rule might not apply (but another rule might). For now, we err
543        // on the side of adding too few edges into the graph.
544
545        // Compute the bounds we can derive from the trait definition.
546        // These are guaranteed to apply, no matter the inference
547        // results.
548        let trait_bounds: Vec<_> =
549            rustc_type_ir::outlives::declared_bounds_from_definition(self.tcx, alias_ty).collect();
550
551        debug!(?trait_bounds);
552
553        // Compute the bounds we can derive from the environment. This
554        // is an "approximate" match -- in some cases, these bounds
555        // may not apply.
556        let approx_env_bounds = self.verify_bound.approx_declared_bounds_from_env(alias_ty);
557        debug!(?approx_env_bounds);
558
559        // If declared bounds list is empty, the only applicable rule is
560        // OutlivesProjectionComponent. If there are inference variables,
561        // then, we can break down the outlives into more primitive
562        // components without adding unnecessary edges.
563        //
564        // If there are *no* inference variables, however, we COULD do
565        // this, but we choose not to, because the error messages are less
566        // good. For example, a requirement like `T::Item: 'r` would be
567        // translated to a requirement that `T: 'r`; when this is reported
568        // to the user, it will thus say "T: 'r must hold so that T::Item:
569        // 'r holds". But that makes it sound like the only way to fix
570        // the problem is to add `T: 'r`, which isn't true. So, if there are no
571        // inference variables, we use a verify constraint instead of adding
572        // edges, which winds up enforcing the same condition.
573        let kind = alias_ty.kind;
574        if approx_env_bounds.is_empty()
575            && trait_bounds.is_empty()
576            && (alias_ty.has_infer_regions() || matches!(kind, ty::Opaque { .. }))
577        {
578            debug!("no declared bounds");
579            let opt_variances = self.tcx.opt_alias_variances(kind);
580            self.args_must_outlive(alias_ty.args, origin, region, opt_variances);
581            return;
582        }
583
584        // If we found a unique bound `'b` from the trait, and we
585        // found nothing else from the environment, then the best
586        // action is to require that `'b: 'r`, so do that.
587        //
588        // This is best no matter what rule we use:
589        //
590        // - OutlivesProjectionEnv: these would translate to the requirement that `'b:'r`
591        // - OutlivesProjectionTraitDef: these would translate to the requirement that `'b:'r`
592        // - OutlivesProjectionComponent: this would require `'b:'r`
593        //   in addition to other conditions
594        if !trait_bounds.is_empty()
595            && trait_bounds[1..]
596                .iter()
597                .map(|r| Some(*r))
598                .chain(
599                    // NB: The environment may contain `for<'a> T: 'a` style bounds.
600                    // In that case, we don't know if they are equal to the trait bound
601                    // or not (since we don't *know* whether the environment bound even applies),
602                    // so just map to `None` here if there are bound vars, ensuring that
603                    // the call to `all` will fail below.
604                    approx_env_bounds.iter().map(|b| b.map_bound(|b| b.1).no_bound_vars()),
605                )
606                .all(|b| b == Some(trait_bounds[0]))
607        {
608            let unique_bound = trait_bounds[0];
609            debug!(?unique_bound);
610            debug!("unique declared bound appears in trait ref");
611            let category = origin.to_constraint_category();
612            self.delegate.push_sub_region_constraint(origin, region, unique_bound, category);
613            return;
614        }
615
616        // Fallback to verifying after the fact that there exists a
617        // declared bound, or that all the components appearing in the
618        // projection outlive; in some cases, this may add insufficient
619        // edges into the inference graph, leading to inference failures
620        // even though a satisfactory solution exists.
621        let verify_bound = self.verify_bound.alias_bound(alias_ty);
622        debug!("alias_must_outlive: pushing {:?}", verify_bound);
623        self.delegate.push_verify(origin, GenericKind::Alias(alias_ty), region, verify_bound);
624    }
625
626    #[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(626u32),
                                    ::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))]
627    fn args_must_outlive(
628        &mut self,
629        args: GenericArgsRef<'tcx>,
630        origin: infer::SubregionOrigin<'tcx>,
631        region: ty::Region<'tcx>,
632        opt_variances: Option<&[ty::Variance]>,
633    ) {
634        let constraint = origin.to_constraint_category();
635        for (index, arg) in args.iter().enumerate() {
636            match arg.kind() {
637                GenericArgKind::Lifetime(lt) => {
638                    let variance = if let Some(variances) = opt_variances {
639                        variances[index]
640                    } else {
641                        ty::Invariant
642                    };
643                    if variance == ty::Invariant {
644                        self.delegate.push_sub_region_constraint(
645                            origin.clone(),
646                            region,
647                            lt,
648                            constraint,
649                        );
650                    }
651                }
652                GenericArgKind::Type(ty) => {
653                    self.type_must_outlive(origin.clone(), ty, region, constraint);
654                }
655                GenericArgKind::Const(_) => {
656                    // Const parameters don't impose constraints.
657                }
658            }
659        }
660    }
661}
662
663impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'tcx> {
664    fn push_sub_region_constraint(
665        &mut self,
666        origin: SubregionOrigin<'tcx>,
667        a: ty::Region<'tcx>,
668        b: ty::Region<'tcx>,
669        _constraint_category: ConstraintCategory<'tcx>,
670    ) {
671        // We don't do leak check in lexical region resolution
672        self.sub_regions(origin, a, b, ty::VisibleForLeakCheck::Unreachable)
673    }
674
675    fn push_verify(
676        &mut self,
677        origin: SubregionOrigin<'tcx>,
678        kind: GenericKind<'tcx>,
679        a: ty::Region<'tcx>,
680        bound: VerifyBound<'tcx>,
681    ) {
682        self.verify_generic_bound(origin, kind, a, bound)
683    }
684}