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::traits::query::NoSolution;
67use rustc_middle::ty::outlives::{Component, push_outlives_components};
68use rustc_middle::ty::{
69    self, GenericArgKind, GenericArgsRef, PolyTypeOutlivesPredicate, Region, RegionVid, Ty, TyCtxt,
70    TypeFoldable as _, TypeVisitableExt,
71};
72use rustc_span::Span;
73use smallvec::smallvec;
74use tracing::{debug, instrument};
75
76use super::env::OutlivesEnvironment;
77use crate::infer::outlives::env::RegionBoundPairs;
78use crate::infer::outlives::verify::VerifyBoundCx;
79use crate::infer::resolve::OpportunisticRegionResolver;
80use crate::infer::snapshot::undo_log::UndoLog;
81use crate::infer::{
82    self, GenericKind, InferCtxt, SubregionOrigin, TypeOutlivesConstraint, VerifyBound,
83};
84use crate::traits::{ObligationCause, ObligationCauseCode};
85
86impl<'tcx> InferCtxt<'tcx> {
87    pub fn register_outlives_constraint(
88        &self,
89        ty::OutlivesPredicate(arg, r2): ty::ArgOutlivesPredicate<'tcx>,
90        vis: ty::VisibleForLeakCheck,
91        cause: &ObligationCause<'tcx>,
92    ) {
93        match arg.kind() {
94            ty::GenericArgKind::Lifetime(r1) => {
95                self.register_region_outlives_constraint(ty::OutlivesPredicate(r1, r2), vis, cause);
96            }
97            ty::GenericArgKind::Type(ty1) => {
98                self.register_type_outlives_constraint(ty1, r2, cause);
99            }
100            ty::GenericArgKind::Const(_) => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
101        }
102    }
103
104    pub fn register_region_eq_constraint(
105        &self,
106        ty::RegionEqPredicate(r_a, r_b): ty::RegionEqPredicate<'tcx>,
107        vis: ty::VisibleForLeakCheck,
108        cause: &ObligationCause<'tcx>,
109    ) {
110        let origin = SubregionOrigin::from_obligation_cause(cause, || {
111            SubregionOrigin::RelateRegionParamBound(cause.span, None)
112        });
113        self.equate_regions(origin, r_a, r_b, vis);
114    }
115
116    pub fn register_region_outlives_constraint(
117        &self,
118        ty::OutlivesPredicate(r_a, r_b): ty::RegionOutlivesPredicate<'tcx>,
119        vis: ty::VisibleForLeakCheck,
120        cause: &ObligationCause<'tcx>,
121    ) {
122        let origin = SubregionOrigin::from_obligation_cause(cause, || {
123            SubregionOrigin::RelateRegionParamBound(cause.span, None)
124        });
125        // `'a: 'b` ==> `'b <= 'a`
126        self.sub_regions(origin, r_b, r_a, vis);
127    }
128
129    /// Registers that the given region obligation must be resolved
130    /// from within the scope of `body_id`. These regions are enqueued
131    /// and later processed by regionck, when full type information is
132    /// available (see `region_obligations` field for more
133    /// information).
134    #[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(134u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["obligation"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn 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))]
135    pub fn register_type_outlives_constraint_inner(
136        &self,
137        obligation: TypeOutlivesConstraint<'tcx>,
138    ) {
139        let mut inner = self.inner.borrow_mut();
140        inner.undo_log.push(UndoLog::PushTypeOutlivesConstraint);
141        inner.region_obligations.push(obligation);
142    }
143
144    pub fn register_type_outlives_constraint(
145        &self,
146        sup_type: Ty<'tcx>,
147        sub_region: Region<'tcx>,
148        cause: &ObligationCause<'tcx>,
149    ) {
150        if !!self.tcx.assumptions_on_binders() {
    ::core::panicking::panic("assertion failed: !self.tcx.assumptions_on_binders()")
};assert!(!self.tcx.assumptions_on_binders());
151
152        // `is_global` means the type has no params, infer, placeholder, or non-`'static`
153        // free regions. If the type has none of these things, then we can skip registering
154        // this outlives obligation since it has no components which affect lifetime
155        // checking in an interesting way.
156        if sup_type.is_global() {
157            return;
158        }
159
160        {
    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:160",
                        "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(160u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                        ::tracing_core::field::FieldSet::new(&["sup_type",
                                        "sub_region", "cause"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&sup_type)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&sub_region)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&cause) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?sup_type, ?sub_region, ?cause);
161        let origin = SubregionOrigin::from_obligation_cause(cause, || {
162            SubregionOrigin::RelateParamBound(
163                cause.span,
164                sup_type,
165                match cause.code().peel_derives() {
166                    ObligationCauseCode::WhereClause(_, span)
167                    | ObligationCauseCode::WhereClauseInExpr(_, span, ..)
168                    | ObligationCauseCode::OpaqueTypeBound(span, _)
169                        if !span.is_dummy() =>
170                    {
171                        Some(*span)
172                    }
173                    _ => None,
174                },
175            )
176        });
177
178        self.register_type_outlives_constraint_inner(TypeOutlivesConstraint {
179            sup_type,
180            sub_region,
181            origin,
182        });
183    }
184
185    /// Trait queries just want to pass back type obligations "as is"
186    pub fn take_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
187        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");
188        std::mem::take(&mut self.inner.borrow_mut().region_obligations)
189    }
190
191    pub fn clone_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
192        self.inner.borrow().region_obligations.clone()
193    }
194
195    pub fn register_region_assumption(&self, assumption: ty::ArgOutlivesPredicate<'tcx>) {
196        let mut inner = self.inner.borrow_mut();
197        inner.undo_log.push(UndoLog::PushRegionAssumption);
198        inner.region_assumptions.push(assumption);
199    }
200
201    pub fn take_registered_region_assumptions(&self) -> Vec<ty::ArgOutlivesPredicate<'tcx>> {
202        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");
203        std::mem::take(&mut self.inner.borrow_mut().region_assumptions)
204    }
205
206    pub fn destructure_solver_region_constraints_for_regionck(
207        &self,
208        outlives_env: &OutlivesEnvironment<'tcx>,
209        span: Span,
210    ) {
211        let assumptions = rustc_type_ir::region_constraint::Assumptions::new(
212            outlives_env.known_type_outlives().into_iter().cloned().collect(),
213            outlives_env.free_region_map().relation.clone(),
214        );
215        self.destructure_solver_region_constraints(assumptions, self, span);
216    }
217
218    pub fn destructure_solver_region_constraints_for_borrowck(
219        &self,
220        // this is always ConstraintConversion but lol
221        conversion: impl TypeOutlivesDelegate<'tcx>,
222        known_type_outlives: &[PolyTypeOutlivesPredicate<'tcx>],
223        region_outlives: TransitiveRelation<RegionVid>,
224        span: Span,
225    ) {
226        let assumptions = rustc_type_ir::region_constraint::Assumptions::new(
227            known_type_outlives.into_iter().cloned().collect(),
228            region_outlives.maybe_map(|r| Some(Region::new_var(self.tcx, r))).unwrap(),
229        );
230        self.destructure_solver_region_constraints(assumptions, conversion, span);
231    }
232
233    #[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(233u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["assumptions",
                                                    "span"], ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn 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:247",
                                    "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(247u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["constraint"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&constraint)
                                                        as &dyn 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:254",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(254u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["constraint"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&constraint)
                                                        as &dyn 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: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(&["constraint"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&constraint)
                                                        as &dyn 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))]
234    pub fn destructure_solver_region_constraints(
235        &self,
236        assumptions: rustc_type_ir::region_constraint::Assumptions<TyCtxt<'tcx>>,
237        mut conversion: impl TypeOutlivesDelegate<'tcx>,
238        span: Span,
239    ) {
240        assert!(self.tcx.assumptions_on_binders());
241        assert!(self.next_trait_solver());
242
243        let origin = SubregionOrigin::SolverRegionConstraint(span);
244        let category = origin.to_constraint_category();
245
246        let constraint = self.inner.borrow().solver_region_constraint_storage.get_constraint();
247        debug!(?constraint);
248        let constraint =
249            rustc_type_ir::region_constraint::destructure_type_outlives_constraints_in_root(
250                self,
251                constraint,
252                &assumptions,
253            );
254        debug!(?constraint);
255        let constraint = rustc_type_ir::region_constraint::evaluate_solver_constraint(&constraint);
256        debug!(?constraint);
257
258        let mut constraints = vec![constraint];
259        while let Some(c) = constraints.pop() {
260            use rustc_type_ir::region_constraint::RegionConstraint::*;
261
262            match c {
263                Ambiguity => {
264                    self.dcx().err("unable to satisfy constraints involving placeholders due to unknown implied bounds");
265                }
266                RegionOutlives(a, b) => {
267                    conversion.push_sub_region_constraint(
268                        origin.clone(),
269                        // we flip these because regionck is silly :>
270                        b,
271                        a,
272                        category,
273                    );
274                }
275                // FIXME(-Zassumptions-on-binders): actually implement OR as an  OR
276                And(nested) | Or(nested) => constraints.extend(nested),
277                AliasTyOutlivesViaEnv(..) | PlaceholderTyOutlives(..) => unreachable!(),
278            }
279        }
280    }
281
282    /// Process the region obligations that must be proven (during
283    /// `regionck`) for the given `body_id`, given information about
284    /// the region bounds in scope and so forth.
285    ///
286    /// See the `region_obligations` field of `InferCtxt` for some
287    /// comments about how this function fits into the overall expected
288    /// flow of the inferencer. The key point is that it is
289    /// invoked after all type-inference variables have been bound --
290    /// right before lexical region resolution.
291    #[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(291u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["span"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn 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:
                    Result<(),
                    (PolyTypeOutlivesPredicate<'tcx>, SubregionOrigin<'tcx>)> =
                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 outlives =
                        ty::Binder::dummy(ty::OutlivesPredicate(sup_type,
                                sub_region));
                    let ty::OutlivesPredicate(sup_type, sub_region) =
                        deeply_normalize_ty(outlives,
                                            origin.clone()).map_err(|NoSolution|
                                            (outlives,
                                                origin.clone()))?.no_bound_vars().expect("started with no bound vars, should end with no bound vars");
                    let (sup_type, sub_region) =
                        (sup_type,
                                sub_region).fold_with(&mut OpportunisticRegionResolver::new(self));
                    if self.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
                            &&
                            outlives_env.higher_ranked_assumptions().contains(&ty::OutlivesPredicate(sup_type.into(),
                                        sub_region)) {
                        continue;
                    }
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event compiler/rustc_infer/src/infer/outlives/obligations.rs:345",
                                            "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(345u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                            ::tracing_core::field::FieldSet::new(&["sup_type",
                                                            "sub_region", "origin"],
                                                ::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};
                                    let mut iter = __CALLSITE.metadata().fields().iter();
                                    __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                        ::tracing::__macro_support::Option::Some(&debug(&sup_type)
                                                                as &dyn Value)),
                                                    (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                        ::tracing::__macro_support::Option::Some(&debug(&sub_region)
                                                                as &dyn Value)),
                                                    (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                        ::tracing::__macro_support::Option::Some(&debug(&origin) as
                                                                &dyn 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);
                }
            }
            Ok(())
        }
    }
}#[instrument(level = "debug", skip(self, outlives_env, deeply_normalize_ty))]
292    pub fn process_registered_region_obligations(
293        &self,
294        outlives_env: &OutlivesEnvironment<'tcx>,
295        mut deeply_normalize_ty: impl FnMut(
296            PolyTypeOutlivesPredicate<'tcx>,
297            SubregionOrigin<'tcx>,
298        )
299            -> Result<PolyTypeOutlivesPredicate<'tcx>, NoSolution>,
300        span: Span,
301    ) -> Result<(), (PolyTypeOutlivesPredicate<'tcx>, SubregionOrigin<'tcx>)> {
302        assert!(!self.in_snapshot(), "cannot process registered region obligations in a snapshot");
303
304        if self.tcx.assumptions_on_binders() {
305            self.destructure_solver_region_constraints_for_regionck(outlives_env, span);
306        }
307
308        // Must loop since the process of normalizing may itself register region obligations.
309        for iteration in 0.. {
310            let my_region_obligations = self.take_registered_region_obligations();
311            if my_region_obligations.is_empty() {
312                break;
313            }
314
315            if !self.tcx.recursion_limit().value_within_limit(iteration) {
316                // This may actually be reachable. If so, we should convert
317                // this to a proper error/consider whether we should detect
318                // this somewhere else.
319                bug!(
320                    "unexpected overflowed when processing region obligations: {my_region_obligations:#?}"
321                );
322            }
323
324            for TypeOutlivesConstraint { sup_type, sub_region, origin } in my_region_obligations {
325                let outlives = ty::Binder::dummy(ty::OutlivesPredicate(sup_type, sub_region));
326                let ty::OutlivesPredicate(sup_type, sub_region) =
327                    deeply_normalize_ty(outlives, origin.clone())
328                        .map_err(|NoSolution| (outlives, origin.clone()))?
329                        .no_bound_vars()
330                        .expect("started with no bound vars, should end with no bound vars");
331                // `TypeOutlives` is structural, so we should try to opportunistically resolve all
332                // region vids before processing regions, so we have a better chance to match clauses
333                // in our param-env.
334                let (sup_type, sub_region) =
335                    (sup_type, sub_region).fold_with(&mut OpportunisticRegionResolver::new(self));
336
337                if self.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
338                    && outlives_env
339                        .higher_ranked_assumptions()
340                        .contains(&ty::OutlivesPredicate(sup_type.into(), sub_region))
341                {
342                    continue;
343                }
344
345                debug!(?sup_type, ?sub_region, ?origin);
346
347                let outlives = &mut TypeOutlives::new(
348                    self,
349                    self.tcx,
350                    outlives_env.region_bound_pairs(),
351                    None,
352                    outlives_env.known_type_outlives(),
353                );
354                let category = origin.to_constraint_category();
355                outlives.type_must_outlive(origin, sup_type, sub_region, category);
356            }
357        }
358
359        Ok(())
360    }
361}
362
363/// The `TypeOutlives` struct has the job of "lowering" a `T: 'a`
364/// obligation into a series of `'a: 'b` constraints and "verify"s, as
365/// described on the module comment. The final constraints are emitted
366/// via a "delegate" of type `D` -- this is usually the `infcx`, which
367/// accrues them into the `region_obligations` code, but for NLL we
368/// use something else.
369pub struct TypeOutlives<'cx, 'tcx, D>
370where
371    D: TypeOutlivesDelegate<'tcx>,
372{
373    // See the comments on `process_registered_region_obligations` for the meaning
374    // of these fields.
375    delegate: D,
376    tcx: TyCtxt<'tcx>,
377    verify_bound: VerifyBoundCx<'cx, 'tcx>,
378}
379
380pub trait TypeOutlivesDelegate<'tcx> {
381    fn push_sub_region_constraint(
382        &mut self,
383        origin: SubregionOrigin<'tcx>,
384        a: ty::Region<'tcx>,
385        b: ty::Region<'tcx>,
386        constraint_category: ConstraintCategory<'tcx>,
387    );
388
389    fn push_verify(
390        &mut self,
391        origin: SubregionOrigin<'tcx>,
392        kind: GenericKind<'tcx>,
393        a: ty::Region<'tcx>,
394        bound: VerifyBound<'tcx>,
395    );
396}
397
398impl<'cx, 'tcx, D> TypeOutlives<'cx, 'tcx, D>
399where
400    D: TypeOutlivesDelegate<'tcx>,
401{
402    pub fn new(
403        delegate: D,
404        tcx: TyCtxt<'tcx>,
405        region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
406        implicit_region_bound: Option<ty::Region<'tcx>>,
407        caller_bounds: &'cx [ty::PolyTypeOutlivesPredicate<'tcx>],
408    ) -> Self {
409        Self {
410            delegate,
411            tcx,
412            verify_bound: VerifyBoundCx::new(
413                tcx,
414                region_bound_pairs,
415                implicit_region_bound,
416                caller_bounds,
417            ),
418        }
419    }
420
421    /// Adds constraints to inference such that `T: 'a` holds (or
422    /// reports an error if it cannot).
423    ///
424    /// # Parameters
425    ///
426    /// - `origin`, the reason we need this constraint
427    /// - `ty`, the type `T`
428    /// - `region`, the region `'a`
429    #[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(429u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["origin", "ty",
                                                    "region", "category"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&category)
                                                            as &dyn 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()")
            };
            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))]
430    pub fn type_must_outlive(
431        &mut self,
432        origin: infer::SubregionOrigin<'tcx>,
433        ty: Ty<'tcx>,
434        region: ty::Region<'tcx>,
435        category: ConstraintCategory<'tcx>,
436    ) {
437        assert!(!ty.has_escaping_bound_vars());
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(alias_ty) => self.alias_ty_must_outlive(origin, region, *alias_ty),
464                Component::EscapingAlias(subcomponents) => {
465                    self.components_must_outlive(origin, subcomponents, region, category);
466                }
467                Component::UnresolvedInferenceVariable(v) => {
468                    // Ignore this, we presume it will yield an error later,
469                    // since if a type variable is not resolved by this point
470                    // it never will be.
471                    self.tcx.dcx().span_delayed_bug(
472                        origin.span(),
473                        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("unresolved inference variable in outlives: {0:?}",
                v))
    })format!("unresolved inference variable in outlives: {v:?}"),
474                    );
475                }
476            }
477        }
478    }
479
480    #[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(480u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["origin", "region",
                                                    "param_ty"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&param_ty)
                                                            as &dyn 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))]
481    fn param_ty_must_outlive(
482        &mut self,
483        origin: infer::SubregionOrigin<'tcx>,
484        region: ty::Region<'tcx>,
485        param_ty: ty::ParamTy,
486    ) {
487        let verify_bound = self.verify_bound.param_or_placeholder_bound(param_ty.to_ty(self.tcx));
488        self.delegate.push_verify(origin, GenericKind::Param(param_ty), region, verify_bound);
489    }
490
491    #[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(491u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["origin", "region",
                                                    "placeholder_ty"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&placeholder_ty)
                                                            as &dyn 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))]
492    fn placeholder_ty_must_outlive(
493        &mut self,
494        origin: infer::SubregionOrigin<'tcx>,
495        region: ty::Region<'tcx>,
496        placeholder_ty: ty::PlaceholderType<'tcx>,
497    ) {
498        let verify_bound = self
499            .verify_bound
500            .param_or_placeholder_bound(Ty::new_placeholder(self.tcx, placeholder_ty));
501        self.delegate.push_verify(
502            origin,
503            GenericKind::Placeholder(placeholder_ty),
504            region,
505            verify_bound,
506        );
507    }
508
509    #[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(509u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["origin", "region",
                                                    "alias_ty"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&alias_ty)
                                                            as &dyn 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:548",
                                    "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(548u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["trait_bounds"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&trait_bounds)
                                                        as &dyn 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:554",
                                    "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(554u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["approx_env_bounds"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&approx_env_bounds)
                                                        as &dyn 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:575",
                                        "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(575u32),
                                        ::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};
                                let mut iter = __CALLSITE.metadata().fields().iter();
                                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&format_args!("no declared bounds")
                                                            as &dyn 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:606",
                                        "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(606u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                        ::tracing_core::field::FieldSet::new(&["unique_bound"],
                                            ::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};
                                let mut iter = __CALLSITE.metadata().fields().iter();
                                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&debug(&unique_bound)
                                                            as &dyn 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:607",
                                        "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(607u32),
                                        ::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};
                                let mut iter = __CALLSITE.metadata().fields().iter();
                                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&format_args!("unique declared bound appears in trait ref")
                                                            as &dyn 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:619",
                                    "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(619u32),
                                    ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&format_args!("alias_must_outlive: pushing {0:?}",
                                                                verify_bound) as &dyn Value))])
                        });
                } else { ; }
            };
            self.delegate.push_verify(origin, GenericKind::Alias(alias_ty),
                region, verify_bound);
        }
    }
}#[instrument(level = "debug", skip(self))]
510    fn alias_ty_must_outlive(
511        &mut self,
512        origin: infer::SubregionOrigin<'tcx>,
513        region: ty::Region<'tcx>,
514        alias_ty: ty::AliasTy<'tcx>,
515    ) {
516        // An optimization for a common case with opaque types.
517        if alias_ty.args.is_empty() {
518            return;
519        }
520
521        if alias_ty.has_non_region_infer() {
522            self.tcx
523                .dcx()
524                .span_delayed_bug(origin.span(), "an alias has infers during region solving");
525            return;
526        }
527
528        // This case is thorny for inference. The fundamental problem is
529        // that there are many cases where we have choice, and inference
530        // doesn't like choice (the current region inference in
531        // particular). :) First off, we have to choose between using the
532        // OutlivesProjectionEnv, OutlivesProjectionTraitDef, and
533        // OutlivesProjectionComponent rules, any one of which is
534        // sufficient. If there are no inference variables involved, it's
535        // not hard to pick the right rule, but if there are, we're in a
536        // bit of a catch 22: if we picked which rule we were going to
537        // use, we could add constraints to the region inference graph
538        // that make it apply, but if we don't add those constraints, the
539        // rule might not apply (but another rule might). For now, we err
540        // on the side of adding too few edges into the graph.
541
542        // Compute the bounds we can derive from the trait definition.
543        // These are guaranteed to apply, no matter the inference
544        // results.
545        let trait_bounds: Vec<_> =
546            rustc_type_ir::outlives::declared_bounds_from_definition(self.tcx, alias_ty).collect();
547
548        debug!(?trait_bounds);
549
550        // Compute the bounds we can derive from the environment. This
551        // is an "approximate" match -- in some cases, these bounds
552        // may not apply.
553        let approx_env_bounds = self.verify_bound.approx_declared_bounds_from_env(alias_ty);
554        debug!(?approx_env_bounds);
555
556        // If declared bounds list is empty, the only applicable rule is
557        // OutlivesProjectionComponent. If there are inference variables,
558        // then, we can break down the outlives into more primitive
559        // components without adding unnecessary edges.
560        //
561        // If there are *no* inference variables, however, we COULD do
562        // this, but we choose not to, because the error messages are less
563        // good. For example, a requirement like `T::Item: 'r` would be
564        // translated to a requirement that `T: 'r`; when this is reported
565        // to the user, it will thus say "T: 'r must hold so that T::Item:
566        // 'r holds". But that makes it sound like the only way to fix
567        // the problem is to add `T: 'r`, which isn't true. So, if there are no
568        // inference variables, we use a verify constraint instead of adding
569        // edges, which winds up enforcing the same condition.
570        let kind = alias_ty.kind;
571        if approx_env_bounds.is_empty()
572            && trait_bounds.is_empty()
573            && (alias_ty.has_infer_regions() || matches!(kind, ty::Opaque { .. }))
574        {
575            debug!("no declared bounds");
576            let opt_variances = self.tcx.opt_alias_variances(kind);
577            self.args_must_outlive(alias_ty.args, origin, region, opt_variances);
578            return;
579        }
580
581        // If we found a unique bound `'b` from the trait, and we
582        // found nothing else from the environment, then the best
583        // action is to require that `'b: 'r`, so do that.
584        //
585        // This is best no matter what rule we use:
586        //
587        // - OutlivesProjectionEnv: these would translate to the requirement that `'b:'r`
588        // - OutlivesProjectionTraitDef: these would translate to the requirement that `'b:'r`
589        // - OutlivesProjectionComponent: this would require `'b:'r`
590        //   in addition to other conditions
591        if !trait_bounds.is_empty()
592            && trait_bounds[1..]
593                .iter()
594                .map(|r| Some(*r))
595                .chain(
596                    // NB: The environment may contain `for<'a> T: 'a` style bounds.
597                    // In that case, we don't know if they are equal to the trait bound
598                    // or not (since we don't *know* whether the environment bound even applies),
599                    // so just map to `None` here if there are bound vars, ensuring that
600                    // the call to `all` will fail below.
601                    approx_env_bounds.iter().map(|b| b.map_bound(|b| b.1).no_bound_vars()),
602                )
603                .all(|b| b == Some(trait_bounds[0]))
604        {
605            let unique_bound = trait_bounds[0];
606            debug!(?unique_bound);
607            debug!("unique declared bound appears in trait ref");
608            let category = origin.to_constraint_category();
609            self.delegate.push_sub_region_constraint(origin, region, unique_bound, category);
610            return;
611        }
612
613        // Fallback to verifying after the fact that there exists a
614        // declared bound, or that all the components appearing in the
615        // projection outlive; in some cases, this may add insufficient
616        // edges into the inference graph, leading to inference failures
617        // even though a satisfactory solution exists.
618        let verify_bound = self.verify_bound.alias_bound(alias_ty);
619        debug!("alias_must_outlive: pushing {:?}", verify_bound);
620        self.delegate.push_verify(origin, GenericKind::Alias(alias_ty), region, verify_bound);
621    }
622
623    #[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(623u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["args", "origin",
                                                    "region", "opt_variances"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&opt_variances)
                                                            as &dyn 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))]
624    fn args_must_outlive(
625        &mut self,
626        args: GenericArgsRef<'tcx>,
627        origin: infer::SubregionOrigin<'tcx>,
628        region: ty::Region<'tcx>,
629        opt_variances: Option<&[ty::Variance]>,
630    ) {
631        let constraint = origin.to_constraint_category();
632        for (index, arg) in args.iter().enumerate() {
633            match arg.kind() {
634                GenericArgKind::Lifetime(lt) => {
635                    let variance = if let Some(variances) = opt_variances {
636                        variances[index]
637                    } else {
638                        ty::Invariant
639                    };
640                    if variance == ty::Invariant {
641                        self.delegate.push_sub_region_constraint(
642                            origin.clone(),
643                            region,
644                            lt,
645                            constraint,
646                        );
647                    }
648                }
649                GenericArgKind::Type(ty) => {
650                    self.type_must_outlive(origin.clone(), ty, region, constraint);
651                }
652                GenericArgKind::Const(_) => {
653                    // Const parameters don't impose constraints.
654                }
655            }
656        }
657    }
658}
659
660impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'tcx> {
661    fn push_sub_region_constraint(
662        &mut self,
663        origin: SubregionOrigin<'tcx>,
664        a: ty::Region<'tcx>,
665        b: ty::Region<'tcx>,
666        _constraint_category: ConstraintCategory<'tcx>,
667    ) {
668        // We don't do leak check in lexical region resolution
669        self.sub_regions(origin, a, b, ty::VisibleForLeakCheck::Unreachable)
670    }
671
672    fn push_verify(
673        &mut self,
674        origin: SubregionOrigin<'tcx>,
675        kind: GenericKind<'tcx>,
676        a: ty::Region<'tcx>,
677        bound: VerifyBound<'tcx>,
678    ) {
679        self.verify_generic_bound(origin, kind, a, bound)
680    }
681}