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, TransitiveRelationBuilder};
63use rustc_data_structures::undo_log::UndoLogs;
64use rustc_middle::mir::ConstraintCategory;
65use rustc_middle::ty::outlives::{Component, push_outlives_components};
66use rustc_middle::ty::{
67    self, GenericArgKind, GenericArgsRef, PolyTypeOutlivesClause, Region, RegionVid, Ty, TyCtxt,
68    TypeVisitableExt, Upcast,
69};
70use rustc_span::bug;
71use rustc_type_ir::region_constraint::{self, LeafRegionConstraint};
72use smallvec::smallvec;
73use tracing::{debug, instrument};
74
75use super::env::OutlivesEnvironment;
76use crate::infer::outlives::env::RegionBoundPairs;
77use crate::infer::outlives::verify::VerifyBoundCx;
78use crate::infer::snapshot::undo_log::UndoLog;
79use crate::infer::{
80    self, GenericKind, InferCtxt, SolverRegionConstraint, SubregionOrigin, TypeOutlivesConstraint,
81    VerifyBound,
82};
83use crate::traits::{ObligationCause, ObligationCauseCode};
84
85impl<'tcx> InferCtxt<'tcx> {
86    pub fn register_outlives_constraint(
87        &self,
88        ty::OutlivesClause(arg, r2): ty::ArgOutlivesClause<'tcx>,
89        vis: ty::VisibleForLeakCheck,
90        cause: &ObligationCause<'tcx>,
91    ) {
92        match arg.kind() {
93            ty::GenericArgKind::Lifetime(r1) => {
94                self.register_region_outlives_constraint(ty::OutlivesClause(r1, r2), vis, cause);
95            }
96            ty::GenericArgKind::Type(ty1) => {
97                self.register_type_outlives_constraint(ty1, r2, cause);
98            }
99            ty::GenericArgKind::Const(_) => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
100        }
101    }
102
103    pub fn register_region_eq_constraint(
104        &self,
105        ty::RegionEqPredicate(r_a, r_b): ty::RegionEqPredicate<'tcx>,
106        vis: ty::VisibleForLeakCheck,
107        cause: &ObligationCause<'tcx>,
108    ) {
109        let origin = SubregionOrigin::from_obligation_cause(cause, || {
110            SubregionOrigin::RelateRegionParamBound(cause.span, None)
111        });
112        self.equate_regions(origin, r_a, r_b, vis);
113    }
114
115    pub fn register_region_outlives_constraint(
116        &self,
117        ty::OutlivesClause(r_a, r_b): ty::RegionOutlivesClause<'tcx>,
118        vis: ty::VisibleForLeakCheck,
119        cause: &ObligationCause<'tcx>,
120    ) {
121        let origin = SubregionOrigin::from_obligation_cause(cause, || {
122            SubregionOrigin::RelateRegionParamBound(cause.span, None)
123        });
124        // `'a: 'b` ==> `'b <= 'a`
125        self.sub_regions(origin, r_b, r_a, vis);
126    }
127
128    /// Registers that the given region obligation must be resolved
129    /// from within the scope of `body_id`. These regions are enqueued
130    /// and later processed by regionck, when full type information is
131    /// available (see `region_obligations` field for more
132    /// information).
133    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(133u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("obligation");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let mut inner = self.inner.borrow_mut();
            inner.undo_log.push(UndoLog::PushTypeOutlivesConstraint);
            inner.region_obligations.push(obligation);
        }
    }
}#[instrument(level = "debug", skip(self))]
134    pub fn register_type_outlives_constraint_inner(
135        &self,
136        obligation: TypeOutlivesConstraint<'tcx>,
137    ) {
138        let mut inner = self.inner.borrow_mut();
139        inner.undo_log.push(UndoLog::PushTypeOutlivesConstraint);
140        inner.region_obligations.push(obligation);
141    }
142
143    pub fn register_solver_region_constraint(&self, c: SolverRegionConstraint<'tcx>) {
144        let mut inner = self.inner.borrow_mut();
145
146        let old_constraint = inner.solver_region_constraint_storage.get_constraint();
147        let new_constraint = rustc_type_ir::region_constraint::RegionConstraint::build_and(
148            c,
149            old_constraint.clone(),
150        );
151
152        // FIXME(-Zassumptions-on-binders): This is pretty bad for perf, we don't make incremental
153        // changes to the region constraints, instead we just rewrite the entire thing every time
154        // and store the old version.
155        inner.undo_log.push(UndoLog::OverwriteSolverRegionConstraint { old_constraint });
156        inner.solver_region_constraint_storage.overwrite(new_constraint);
157    }
158
159    pub fn register_type_outlives_constraint(
160        &self,
161        sup_type: Ty<'tcx>,
162        sub_region: Region<'tcx>,
163        cause: &ObligationCause<'tcx>,
164    ) {
165        if !!self.tcx.assumptions_on_binders() {
    ::core::panicking::panic("assertion failed: !self.tcx.assumptions_on_binders()")
};assert!(!self.tcx.assumptions_on_binders());
166
167        // `is_global` means the type has no params, infer, placeholder, or non-`'static`
168        // free regions. If the type has none of these things, then we can skip registering
169        // this outlives obligation since it has no components which affect lifetime
170        // checking in an interesting way.
171        if sup_type.is_global() {
172            return;
173        }
174
175        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs:175",
                        "rustc_infer::infer::outlives::obligations",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                        ::tracing_core::__macro_support::Option::Some(175u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("sup_type")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("sup_type");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("sub_region")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("sub_region");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("cause")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("cause");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sup_type)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sub_region)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&cause)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?sup_type, ?sub_region, ?cause);
176        let origin = SubregionOrigin::from_obligation_cause(cause, || {
177            SubregionOrigin::RelateParamBound(
178                cause.span,
179                sup_type,
180                match cause.code().peel_derives() {
181                    ObligationCauseCode::WhereClause(_, span)
182                    | ObligationCauseCode::WhereClauseInExpr(_, span, ..)
183                    | ObligationCauseCode::OpaqueTypeBound(span, _)
184                        if !span.is_dummy() =>
185                    {
186                        Some(*span)
187                    }
188                    _ => None,
189                },
190            )
191        });
192
193        self.register_type_outlives_constraint_inner(TypeOutlivesConstraint {
194            sup_type,
195            sub_region,
196            origin,
197        });
198    }
199
200    /// Trait queries just want to pass back type obligations "as is"
201    pub fn take_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
202        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");
203        std::mem::take(&mut self.inner.borrow_mut().region_obligations)
204    }
205
206    pub fn num_registered_region_obligations(&self) -> usize {
207        self.inner.borrow().region_obligations.len()
208    }
209
210    pub fn registered_region_obligations_since(
211        &self,
212        prev: usize,
213    ) -> Vec<TypeOutlivesConstraint<'tcx>> {
214        self.inner.borrow().region_obligations.iter().skip(prev).cloned().collect()
215    }
216
217    pub fn clone_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
218        self.inner.borrow().region_obligations.clone()
219    }
220
221    pub fn register_region_assumption(&self, assumption: ty::ArgOutlivesClause<'tcx>) {
222        let mut inner = self.inner.borrow_mut();
223        inner.undo_log.push(UndoLog::PushRegionAssumption);
224        inner.region_assumptions.push(assumption);
225    }
226
227    pub fn take_registered_region_assumptions(&self) -> Vec<ty::ArgOutlivesClause<'tcx>> {
228        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");
229        std::mem::take(&mut self.inner.borrow_mut().region_assumptions)
230    }
231
232    pub fn destructure_solver_region_constraints_for_regionck(
233        &self,
234        outlives_env: &OutlivesEnvironment<'tcx>,
235    ) {
236        // `FreeRegionMap::relation` stores `'sub <= 'sup` edges while
237        // `Assumptions::region_outlives` expects `'longer: 'shorter` ones, so the
238        // edges have to be inverted here.
239        let mut region_outlives = TransitiveRelationBuilder::default();
240        for (r1, r2) in outlives_env.free_region_map().relation.base_edges() {
241            region_outlives.add(r2, r1);
242        }
243        let assumptions = rustc_type_ir::region_constraint::Assumptions::new(
244            self,
245            assumed_type_outlives(
246                self.tcx,
247                outlives_env.known_type_outlives(),
248                outlives_env.region_bound_pairs(),
249            ),
250            region_outlives.freeze(),
251            ty::UniverseIndex::ROOT,
252        );
253        self.destructure_solver_region_constraints(assumptions, self);
254    }
255
256    pub fn destructure_solver_region_constraints_for_borrowck(
257        &self,
258        // this is always ConstraintConversion but lol
259        conversion: impl TypeOutlivesDelegate<'tcx>,
260        known_type_outlives: &[PolyTypeOutlivesClause<'tcx>],
261        region_bound_pairs: &RegionBoundPairs<'tcx>,
262        region_outlives: TransitiveRelation<RegionVid>,
263    ) {
264        let assumptions = region_constraint::Assumptions::new(
265            self,
266            assumed_type_outlives(self.tcx, known_type_outlives, region_bound_pairs),
267            region_outlives.maybe_map(|r| Some(Region::new_var(self.tcx, r))).unwrap(),
268            ty::UniverseIndex::ROOT,
269        );
270        self.destructure_solver_region_constraints(assumptions, conversion);
271    }
272
273    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(273u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("assumptions")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("assumptions");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assumptions)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } 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 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 /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs:283",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(283u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("constraint")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("constraint");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let constraint =
                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 /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs:289",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(289u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("constraint")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("constraint");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            for c in
                constraint.and_constraint.0.into_iter().chain(constraint.or_constraint.0.into_iter().flat_map(|and_constraint|
                            and_constraint.0.into_iter())) {
                use LeafRegionConstraint::*;
                match c {
                    Ambiguity(span) => {
                        self.dcx().struct_span_err(span,
                                "unable to satisfy constraints involving placeholders due to unknown implied bounds").emit();
                    }
                    RegionOutlives(a, b, span) => {
                        let origin = SubregionOrigin::SolverRegionConstraint(span);
                        let category = origin.to_constraint_category();
                        conversion.push_sub_region_constraint(origin, b, a,
                            category);
                    }
                    AliasTyOutlivesViaEnv(..) | PlaceholderTyOutlives(..) => {
                        ::core::panicking::panic("internal error: entered unreachable code")
                    }
                }
            }
        }
    }
}#[instrument(level = "debug", skip(self, conversion))]
274    pub fn destructure_solver_region_constraints(
275        &self,
276        assumptions: rustc_type_ir::region_constraint::Assumptions<TyCtxt<'tcx>>,
277        mut conversion: impl TypeOutlivesDelegate<'tcx>,
278    ) {
279        assert!(self.tcx.assumptions_on_binders());
280        assert!(self.next_trait_solver());
281
282        let constraint = self.inner.borrow().solver_region_constraint_storage.get_constraint();
283        debug!(?constraint);
284        let constraint = region_constraint::destructure_type_outlives_constraints_in_root(
285            self,
286            constraint,
287            &assumptions,
288        );
289        debug!(?constraint);
290
291        // FIXME(-Zassumptions-on-binders): actually implement OR as an  OR
292        for c in constraint.and_constraint.0.into_iter().chain(
293            constraint
294                .or_constraint
295                .0
296                .into_iter()
297                .flat_map(|and_constraint| and_constraint.0.into_iter()),
298        ) {
299            use LeafRegionConstraint::*;
300
301            match c {
302                Ambiguity(span) => {
303                    self.dcx()
304                        .struct_span_err(
305                            span,
306                            "unable to satisfy constraints involving placeholders due to unknown implied bounds",
307                        )
308                        .emit();
309                }
310                RegionOutlives(a, b, span) => {
311                    let origin = SubregionOrigin::SolverRegionConstraint(span);
312                    let category = origin.to_constraint_category();
313                    conversion.push_sub_region_constraint(
314                        origin, // we flip these because regionck is silly :>
315                        b, a, category,
316                    );
317                }
318                AliasTyOutlivesViaEnv(..) | PlaceholderTyOutlives(..) => {
319                    unreachable!()
320                }
321            }
322        }
323    }
324
325    /// Process the region obligations that must be proven (during
326    /// `regionck`) for the given `body_id`, given information about
327    /// the region bounds in scope and so forth.
328    ///
329    /// See the `region_obligations` field of `InferCtxt` for some
330    /// comments about how this function fits into the overall expected
331    /// flow of the inferencer. The key point is that it is
332    /// invoked after all type-inference variables have been bound --
333    /// right before lexical region resolution.
334    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(334u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::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,
                        &{ meta.fields().value_set_all(&[]) })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if !!self.in_snapshot() {
                {
                    ::core::panicking::panic_fmt(format_args!("cannot process registered region obligations in a snapshot"));
                }
            };
            if self.tcx.assumptions_on_binders() {
                self.destructure_solver_region_constraints_for_regionck(outlives_env);
            }
            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_span::macros::bug_impl(None,
                        format_args!("unexpected overflowed when processing region obligations: {0:#?}",
                            my_region_obligations), Location::caller());
                }
                for TypeOutlivesConstraint { sup_type, sub_region, origin } in
                    my_region_obligations {
                    #[allow(rustc::usage_of_type_ir_traits)]
                    let (sup_type, sub_region) =
                        self.deeply_resolve_via_unification_table((sup_type,
                                sub_region));
                    if self.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
                            &&
                            outlives_env.higher_ranked_assumptions().contains(&ty::OutlivesClause(sup_type.into(),
                                        sub_region)) {
                        continue;
                    }
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs:377",
                                            "rustc_infer::infer::outlives::obligations",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                            ::tracing_core::__macro_support::Option::Some(377u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                            ::tracing_core::field::FieldSet::new(&[{
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("sup_type")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("sup_type");
                                                                NAME.as_str()
                                                            },
                                                            {
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("sub_region")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("sub_region");
                                                                NAME.as_str()
                                                            },
                                                            {
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("origin")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("origin");
                                                                NAME.as_str()
                                                            }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                            ::tracing::metadata::Kind::EVENT)
                                    };
                                ::tracing::callsite::DefaultCallsite::new(&META)
                            };
                        let enabled =
                            ::tracing::Level::DEBUG <=
                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                    ::tracing::Level::DEBUG <=
                                        ::tracing::level_filters::LevelFilter::current() &&
                                {
                                    let interest = __CALLSITE.interest();
                                    !interest.is_never() &&
                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                            interest)
                                };
                        if enabled {
                            (|value_set: ::tracing::field::ValueSet|
                                        {
                                            let meta = __CALLSITE.metadata();
                                            ::tracing::Event::dispatch(meta, &value_set);
                                            ;
                                        })({
                                    #[allow(unused_imports)]
                                    use ::tracing::field::{debug, display, Value};
                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sup_type)
                                                                as &dyn ::tracing::field::Value)),
                                                    (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sub_region)
                                                                as &dyn ::tracing::field::Value)),
                                                    (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                                as &dyn ::tracing::field::Value))])
                                });
                        } else { ; }
                    };
                    let outlives =
                        &mut TypeOutlives::new(self, self.tcx,
                                outlives_env.region_bound_pairs(), None,
                                outlives_env.known_type_outlives());
                    let category = origin.to_constraint_category();
                    outlives.type_must_outlive(origin, sup_type, sub_region,
                        category);
                }
            }
        }
    }
}#[instrument(level = "debug", skip(self, outlives_env))]
335    pub fn process_registered_region_obligations(&self, outlives_env: &OutlivesEnvironment<'tcx>) {
336        assert!(!self.in_snapshot(), "cannot process registered region obligations in a snapshot");
337
338        if self.tcx.assumptions_on_binders() {
339            self.destructure_solver_region_constraints_for_regionck(outlives_env);
340        }
341
342        // Must loop since the process of normalizing may itself register region obligations.
343        for iteration in 0.. {
344            let my_region_obligations = self.take_registered_region_obligations();
345            if my_region_obligations.is_empty() {
346                break;
347            }
348
349            if !self.tcx.recursion_limit().value_within_limit(iteration) {
350                // This may actually be reachable. If so, we should convert
351                // this to a proper error/consider whether we should detect
352                // this somewhere else.
353                bug!(
354                    "unexpected overflowed when processing region obligations: {my_region_obligations:#?}"
355                );
356            }
357
358            for TypeOutlivesConstraint { sup_type, sub_region, origin } in my_region_obligations {
359                // `TypeOutlives` is structural, so we should try to opportunistically resolve all
360                // region vids before processing regions, so we have a better chance to match clauses
361                // in our param-env.
362                //
363                // We *want* this folder to live in `rustc_type_ir`. Our best way to call into it is
364                // through `InferCtxtLike` and it is not defined as an inherent method on `InferCtxt`.
365                #[allow(rustc::usage_of_type_ir_traits)]
366                let (sup_type, sub_region) =
367                    self.deeply_resolve_via_unification_table((sup_type, sub_region));
368
369                if self.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
370                    && outlives_env
371                        .higher_ranked_assumptions()
372                        .contains(&ty::OutlivesClause(sup_type.into(), sub_region))
373                {
374                    continue;
375                }
376
377                debug!(?sup_type, ?sub_region, ?origin);
378
379                let outlives = &mut TypeOutlives::new(
380                    self,
381                    self.tcx,
382                    outlives_env.region_bound_pairs(),
383                    None,
384                    outlives_env.known_type_outlives(),
385                );
386                let category = origin.to_constraint_category();
387                outlives.type_must_outlive(origin, sup_type, sub_region, category);
388            }
389        }
390    }
391}
392
393/// The type outlives assumptions available in the root context, as clauses for
394/// [`region_constraint::Assumptions::new`] to elaborate.
395///
396/// `known_type_outlives` only contains the explicit `Ty: 'a` where clauses. The implied bounds,
397/// e.g. `T: 'a` from a `&'a T` argument, are only tracked in `region_bound_pairs` so we have to
398/// pull them in separately. Without them we'd fail to prove `T: 'a` for a `&'a T` argument
399/// whenever the only explicit bound on `T` mentions a different region.
400fn assumed_type_outlives<'tcx>(
401    tcx: TyCtxt<'tcx>,
402    known_type_outlives: &[PolyTypeOutlivesClause<'tcx>],
403    region_bound_pairs: &RegionBoundPairs<'tcx>,
404) -> Vec<ty::Clause<'tcx>> {
405    known_type_outlives
406        .iter()
407        .copied()
408        .chain(region_bound_pairs.iter().map(|&ty::OutlivesClause(kind, r)| {
409            ty::Binder::dummy(ty::OutlivesClause(kind.to_ty(tcx), r))
410        }))
411        .map(|c| c.map_bound(ty::ClauseKind::TypeOutlives).upcast(tcx))
412        .collect()
413}
414
415/// The `TypeOutlives` struct has the job of "lowering" a `T: 'a`
416/// obligation into a series of `'a: 'b` constraints and "verify"s, as
417/// described on the module comment. The final constraints are emitted
418/// via a "delegate" of type `D` -- this is usually the `infcx`, which
419/// accrues them into the `region_obligations` code, but for NLL we
420/// use something else.
421pub struct TypeOutlives<'cx, 'tcx, D>
422where
423    D: TypeOutlivesDelegate<'tcx>,
424{
425    // See the comments on `process_registered_region_obligations` for the meaning
426    // of these fields.
427    delegate: D,
428    tcx: TyCtxt<'tcx>,
429    verify_bound: VerifyBoundCx<'cx, 'tcx>,
430}
431
432pub trait TypeOutlivesDelegate<'tcx> {
433    fn push_sub_region_constraint(
434        &mut self,
435        origin: SubregionOrigin<'tcx>,
436        a: ty::Region<'tcx>,
437        b: ty::Region<'tcx>,
438        constraint_category: ConstraintCategory<'tcx>,
439    );
440
441    fn push_verify(
442        &mut self,
443        origin: SubregionOrigin<'tcx>,
444        kind: GenericKind<'tcx>,
445        a: ty::Region<'tcx>,
446        bound: VerifyBound<'tcx>,
447    );
448}
449
450impl<'cx, 'tcx, D> TypeOutlives<'cx, 'tcx, D>
451where
452    D: TypeOutlivesDelegate<'tcx>,
453{
454    pub fn new(
455        delegate: D,
456        tcx: TyCtxt<'tcx>,
457        region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
458        implicit_region_bound: Option<ty::Region<'tcx>>,
459        caller_bounds: &'cx [ty::PolyTypeOutlivesClause<'tcx>],
460    ) -> Self {
461        Self {
462            delegate,
463            tcx,
464            verify_bound: VerifyBoundCx::new(
465                tcx,
466                region_bound_pairs,
467                implicit_region_bound,
468                caller_bounds,
469            ),
470        }
471    }
472
473    /// Adds constraints to inference such that `T: 'a` holds (or
474    /// reports an error if it cannot).
475    ///
476    /// # Parameters
477    ///
478    /// - `origin`, the reason we need this constraint
479    /// - `ty`, the type `T`
480    /// - `region`, the region `'a`
481    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(481u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("origin")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("origin");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("region")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("region");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("category")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("category");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&category)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if !!ty.has_escaping_bound_vars() {
                ::core::panicking::panic("assertion failed: !ty.has_escaping_bound_vars()")
            };
            if true {
                if !!ty.has_non_region_infer() {
                    ::core::panicking::panic("assertion failed: !ty.has_non_region_infer()")
                };
            };
            if true {
                if !(!self.tcx.next_trait_solver_globally() ||
                            !ty.has_non_rigid_aliases()) {
                    {
                        ::core::panicking::panic_fmt(format_args!("{0:?} has non-rigid aliases",
                                ty));
                    }
                };
            };
            let mut components = ::smallvec::SmallVec::new();
            push_outlives_components(self.tcx, ty, &mut components);
            self.components_must_outlive(origin, &components, region,
                category);
        }
    }
}#[instrument(level = "debug", skip(self))]
482    pub fn type_must_outlive(
483        &mut self,
484        origin: infer::SubregionOrigin<'tcx>,
485        ty: Ty<'tcx>,
486        region: ty::Region<'tcx>,
487        category: ConstraintCategory<'tcx>,
488    ) {
489        assert!(!ty.has_escaping_bound_vars());
490        debug_assert!(!ty.has_non_region_infer());
491        debug_assert!(
492            !self.tcx.next_trait_solver_globally() || !ty.has_non_rigid_aliases(),
493            "{ty:?} has non-rigid aliases"
494        );
495
496        let mut components = smallvec![];
497        push_outlives_components(self.tcx, ty, &mut components);
498        self.components_must_outlive(origin, &components, region, category);
499    }
500
501    fn components_must_outlive(
502        &mut self,
503        origin: infer::SubregionOrigin<'tcx>,
504        components: &[Component<TyCtxt<'tcx>>],
505        region: ty::Region<'tcx>,
506        category: ConstraintCategory<'tcx>,
507    ) {
508        for component in components.iter() {
509            let origin = origin.clone();
510            match component {
511                Component::Region(region1) => {
512                    self.delegate.push_sub_region_constraint(origin, region, *region1, category);
513                }
514                Component::Param(param_ty) => {
515                    self.param_ty_must_outlive(origin, region, *param_ty);
516                }
517                Component::Placeholder(placeholder_ty) => {
518                    self.placeholder_ty_must_outlive(origin, region, *placeholder_ty);
519                }
520                Component::Alias(is_rigid, alias_ty) => {
521                    if true {
    {
        match (&*is_rigid, &ty::IsRigid::yes_if_next_solver(self.tcx)) {
            (left_val, right_val) => {
                if !(*left_val == *right_val) {
                    let kind = ::core::panicking::AssertKind::Eq;
                    ::core::panicking::assert_failed(kind, &*left_val,
                        &*right_val, ::core::option::Option::None);
                }
            }
        }
    };
};debug_assert_eq!(*is_rigid, ty::IsRigid::yes_if_next_solver(self.tcx));
522                    self.alias_ty_must_outlive(origin, region, *alias_ty);
523                }
524                Component::EscapingAlias(subcomponents) => {
525                    self.components_must_outlive(origin, subcomponents, region, category);
526                }
527                Component::UnresolvedInferenceVariable(v) => {
528                    // Ignore this, we presume it will yield an error later,
529                    // since if a type variable is not resolved by this point
530                    // it never will be.
531                    self.tcx.dcx().span_delayed_bug(
532                        origin.span(),
533                        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("unresolved inference variable in outlives: {0:?}",
                v))
    })format!("unresolved inference variable in outlives: {v:?}"),
534                    );
535                }
536            }
537        }
538    }
539
540    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(540u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("origin")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("origin");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("region")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("region");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("param_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("param_ty");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&param_ty)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let verify_bound =
                self.verify_bound.param_or_placeholder_bound(param_ty.to_ty(self.tcx));
            self.delegate.push_verify(origin, GenericKind::Param(param_ty),
                region, verify_bound);
        }
    }
}#[instrument(level = "debug", skip(self))]
541    fn param_ty_must_outlive(
542        &mut self,
543        origin: infer::SubregionOrigin<'tcx>,
544        region: ty::Region<'tcx>,
545        param_ty: ty::ParamTy,
546    ) {
547        let verify_bound = self.verify_bound.param_or_placeholder_bound(param_ty.to_ty(self.tcx));
548        self.delegate.push_verify(origin, GenericKind::Param(param_ty), region, verify_bound);
549    }
550
551    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(551u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("origin")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("origin");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("region")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("region");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("placeholder_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("placeholder_ty");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&placeholder_ty)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let verify_bound =
                self.verify_bound.param_or_placeholder_bound(Ty::new_placeholder(self.tcx,
                        placeholder_ty));
            self.delegate.push_verify(origin,
                GenericKind::Placeholder(placeholder_ty), region,
                verify_bound);
        }
    }
}#[instrument(level = "debug", skip(self))]
552    fn placeholder_ty_must_outlive(
553        &mut self,
554        origin: infer::SubregionOrigin<'tcx>,
555        region: ty::Region<'tcx>,
556        placeholder_ty: ty::PlaceholderType<'tcx>,
557    ) {
558        let verify_bound = self
559            .verify_bound
560            .param_or_placeholder_bound(Ty::new_placeholder(self.tcx, placeholder_ty));
561        self.delegate.push_verify(
562            origin,
563            GenericKind::Placeholder(placeholder_ty),
564            region,
565            verify_bound,
566        );
567    }
568
569    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(569u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("origin")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("origin");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("region")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("region");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("alias_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("alias_ty");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&alias_ty)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if alias_ty.args.is_empty() { return; }
            if alias_ty.has_non_region_infer() {
                self.tcx.dcx().span_delayed_bug(origin.span(),
                    "an alias has infers during region solving");
                return;
            }
            let trait_bounds: Vec<_> =
                rustc_type_ir::outlives::declared_bounds_from_definition(self.tcx,
                        alias_ty).collect();
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs:608",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(608u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("trait_bounds")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("trait_bounds");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_bounds)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let approx_env_bounds =
                self.verify_bound.approx_declared_bounds_from_env(alias_ty);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs:614",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(614u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("approx_env_bounds")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("approx_env_bounds");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&approx_env_bounds)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let kind = alias_ty.kind;
            if approx_env_bounds.is_empty() && trait_bounds.is_empty() &&
                    (alias_ty.has_infer_regions() ||
                            #[allow(non_exhaustive_omitted_patterns)] match kind {
                                ty::Opaque { .. } => true,
                                _ => false,
                            }) {
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs:635",
                                        "rustc_infer::infer::outlives::obligations",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                        ::tracing_core::__macro_support::Option::Some(635u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                        ::tracing_core::field::FieldSet::new(&["message"],
                                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                        ::tracing::metadata::Kind::EVENT)
                                };
                            ::tracing::callsite::DefaultCallsite::new(&META)
                        };
                    let enabled =
                        ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            {
                                let interest = __CALLSITE.interest();
                                !interest.is_never() &&
                                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                        interest)
                            };
                    if enabled {
                        (|value_set: ::tracing::field::ValueSet|
                                    {
                                        let meta = __CALLSITE.metadata();
                                        ::tracing::Event::dispatch(meta, &value_set);
                                        ;
                                    })({
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("no declared bounds")
                                                            as &dyn ::tracing::field::Value))])
                            });
                    } else { ; }
                };
                let opt_variances = self.tcx.opt_alias_variances(kind);
                self.args_must_outlive(alias_ty.args, origin, region,
                    opt_variances);
                return;
            }
            if !trait_bounds.is_empty() &&
                    trait_bounds[1..].iter().map(|r|
                                    Some(*r)).chain(approx_env_bounds.iter().map(|b|
                                    b.map_bound(|b|
                                                b.1).no_bound_vars())).all(|b| b == Some(trait_bounds[0])) {
                let unique_bound = trait_bounds[0];
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs:666",
                                        "rustc_infer::infer::outlives::obligations",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                        ::tracing_core::__macro_support::Option::Some(666u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                        ::tracing_core::field::FieldSet::new(&[{
                                                            const NAME:
                                                                ::tracing::__macro_support::FieldName<{
                                                                    ::tracing::__macro_support::FieldName::len("unique_bound")
                                                                }> =
                                                                ::tracing::__macro_support::FieldName::new("unique_bound");
                                                            NAME.as_str()
                                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                        ::tracing::metadata::Kind::EVENT)
                                };
                            ::tracing::callsite::DefaultCallsite::new(&META)
                        };
                    let enabled =
                        ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            {
                                let interest = __CALLSITE.interest();
                                !interest.is_never() &&
                                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                        interest)
                            };
                    if enabled {
                        (|value_set: ::tracing::field::ValueSet|
                                    {
                                        let meta = __CALLSITE.metadata();
                                        ::tracing::Event::dispatch(meta, &value_set);
                                        ;
                                    })({
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&unique_bound)
                                                            as &dyn ::tracing::field::Value))])
                            });
                    } else { ; }
                };
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs:667",
                                        "rustc_infer::infer::outlives::obligations",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                        ::tracing_core::__macro_support::Option::Some(667u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                        ::tracing_core::field::FieldSet::new(&["message"],
                                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                        ::tracing::metadata::Kind::EVENT)
                                };
                            ::tracing::callsite::DefaultCallsite::new(&META)
                        };
                    let enabled =
                        ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            {
                                let interest = __CALLSITE.interest();
                                !interest.is_never() &&
                                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                        interest)
                            };
                    if enabled {
                        (|value_set: ::tracing::field::ValueSet|
                                    {
                                        let meta = __CALLSITE.metadata();
                                        ::tracing::Event::dispatch(meta, &value_set);
                                        ;
                                    })({
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("unique declared bound appears in trait ref")
                                                            as &dyn ::tracing::field::Value))])
                            });
                    } else { ; }
                };
                let category = origin.to_constraint_category();
                self.delegate.push_sub_region_constraint(origin, region,
                    unique_bound, category);
                return;
            }
            let verify_bound = self.verify_bound.alias_bound(alias_ty);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs:679",
                                    "rustc_infer::infer::outlives::obligations",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(679u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&["message"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("alias_must_outlive: pushing {0:?}",
                                                                verify_bound) as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            self.delegate.push_verify(origin, GenericKind::Alias(alias_ty),
                region, verify_bound);
        }
    }
}#[instrument(level = "debug", skip(self))]
570    fn alias_ty_must_outlive(
571        &mut self,
572        origin: infer::SubregionOrigin<'tcx>,
573        region: ty::Region<'tcx>,
574        alias_ty: ty::AliasTy<'tcx>,
575    ) {
576        // An optimization for a common case with opaque types.
577        if alias_ty.args.is_empty() {
578            return;
579        }
580
581        if alias_ty.has_non_region_infer() {
582            self.tcx
583                .dcx()
584                .span_delayed_bug(origin.span(), "an alias has infers during region solving");
585            return;
586        }
587
588        // This case is thorny for inference. The fundamental problem is
589        // that there are many cases where we have choice, and inference
590        // doesn't like choice (the current region inference in
591        // particular). :) First off, we have to choose between using the
592        // OutlivesProjectionEnv, OutlivesProjectionTraitDef, and
593        // OutlivesProjectionComponent rules, any one of which is
594        // sufficient. If there are no inference variables involved, it's
595        // not hard to pick the right rule, but if there are, we're in a
596        // bit of a catch 22: if we picked which rule we were going to
597        // use, we could add constraints to the region inference graph
598        // that make it apply, but if we don't add those constraints, the
599        // rule might not apply (but another rule might). For now, we err
600        // on the side of adding too few edges into the graph.
601
602        // Compute the bounds we can derive from the trait definition.
603        // These are guaranteed to apply, no matter the inference
604        // results.
605        let trait_bounds: Vec<_> =
606            rustc_type_ir::outlives::declared_bounds_from_definition(self.tcx, alias_ty).collect();
607
608        debug!(?trait_bounds);
609
610        // Compute the bounds we can derive from the environment. This
611        // is an "approximate" match -- in some cases, these bounds
612        // may not apply.
613        let approx_env_bounds = self.verify_bound.approx_declared_bounds_from_env(alias_ty);
614        debug!(?approx_env_bounds);
615
616        // If declared bounds list is empty, the only applicable rule is
617        // OutlivesProjectionComponent. If there are inference variables,
618        // then, we can break down the outlives into more primitive
619        // components without adding unnecessary edges.
620        //
621        // If there are *no* inference variables, however, we COULD do
622        // this, but we choose not to, because the error messages are less
623        // good. For example, a requirement like `T::Item: 'r` would be
624        // translated to a requirement that `T: 'r`; when this is reported
625        // to the user, it will thus say "T: 'r must hold so that T::Item:
626        // 'r holds". But that makes it sound like the only way to fix
627        // the problem is to add `T: 'r`, which isn't true. So, if there are no
628        // inference variables, we use a verify constraint instead of adding
629        // edges, which winds up enforcing the same condition.
630        let kind = alias_ty.kind;
631        if approx_env_bounds.is_empty()
632            && trait_bounds.is_empty()
633            && (alias_ty.has_infer_regions() || matches!(kind, ty::Opaque { .. }))
634        {
635            debug!("no declared bounds");
636            let opt_variances = self.tcx.opt_alias_variances(kind);
637            self.args_must_outlive(alias_ty.args, origin, region, opt_variances);
638            return;
639        }
640
641        // If we found a unique bound `'b` from the trait, and we
642        // found nothing else from the environment, then the best
643        // action is to require that `'b: 'r`, so do that.
644        //
645        // This is best no matter what rule we use:
646        //
647        // - OutlivesProjectionEnv: these would translate to the requirement that `'b:'r`
648        // - OutlivesProjectionTraitDef: these would translate to the requirement that `'b:'r`
649        // - OutlivesProjectionComponent: this would require `'b:'r`
650        //   in addition to other conditions
651        if !trait_bounds.is_empty()
652            && trait_bounds[1..]
653                .iter()
654                .map(|r| Some(*r))
655                .chain(
656                    // NB: The environment may contain `for<'a> T: 'a` style bounds.
657                    // In that case, we don't know if they are equal to the trait bound
658                    // or not (since we don't *know* whether the environment bound even applies),
659                    // so just map to `None` here if there are bound vars, ensuring that
660                    // the call to `all` will fail below.
661                    approx_env_bounds.iter().map(|b| b.map_bound(|b| b.1).no_bound_vars()),
662                )
663                .all(|b| b == Some(trait_bounds[0]))
664        {
665            let unique_bound = trait_bounds[0];
666            debug!(?unique_bound);
667            debug!("unique declared bound appears in trait ref");
668            let category = origin.to_constraint_category();
669            self.delegate.push_sub_region_constraint(origin, region, unique_bound, category);
670            return;
671        }
672
673        // Fallback to verifying after the fact that there exists a
674        // declared bound, or that all the components appearing in the
675        // projection outlive; in some cases, this may add insufficient
676        // edges into the inference graph, leading to inference failures
677        // even though a satisfactory solution exists.
678        let verify_bound = self.verify_bound.alias_bound(alias_ty);
679        debug!("alias_must_outlive: pushing {:?}", verify_bound);
680        self.delegate.push_verify(origin, GenericKind::Alias(alias_ty), region, verify_bound);
681    }
682
683    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_infer/src/infer/outlives/obligations.rs"),
                                    ::tracing_core::__macro_support::Option::Some(683u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_infer::infer::outlives::obligations"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("args")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("args");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("origin")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("origin");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("region")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("region");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("opt_variances")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("opt_variances");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&region)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&opt_variances)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let constraint = origin.to_constraint_category();
            for (index, arg) in args.iter().enumerate() {
                match arg.kind() {
                    GenericArgKind::Lifetime(lt) => {
                        let variance =
                            if let Some(variances) = opt_variances {
                                variances[index]
                            } else { ty::Invariant };
                        if variance == ty::Invariant {
                            self.delegate.push_sub_region_constraint(origin.clone(),
                                region, lt, constraint);
                        }
                    }
                    GenericArgKind::Type(ty) => {
                        self.type_must_outlive(origin.clone(), ty, region,
                            constraint);
                    }
                    GenericArgKind::Const(_) => {}
                }
            }
        }
    }
}#[instrument(level = "debug", skip(self))]
684    fn args_must_outlive(
685        &mut self,
686        args: GenericArgsRef<'tcx>,
687        origin: infer::SubregionOrigin<'tcx>,
688        region: ty::Region<'tcx>,
689        opt_variances: Option<&[ty::Variance]>,
690    ) {
691        let constraint = origin.to_constraint_category();
692        for (index, arg) in args.iter().enumerate() {
693            match arg.kind() {
694                GenericArgKind::Lifetime(lt) => {
695                    let variance = if let Some(variances) = opt_variances {
696                        variances[index]
697                    } else {
698                        ty::Invariant
699                    };
700                    if variance == ty::Invariant {
701                        self.delegate.push_sub_region_constraint(
702                            origin.clone(),
703                            region,
704                            lt,
705                            constraint,
706                        );
707                    }
708                }
709                GenericArgKind::Type(ty) => {
710                    self.type_must_outlive(origin.clone(), ty, region, constraint);
711                }
712                GenericArgKind::Const(_) => {
713                    // Const parameters don't impose constraints.
714                }
715            }
716        }
717    }
718}
719
720impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'tcx> {
721    fn push_sub_region_constraint(
722        &mut self,
723        origin: SubregionOrigin<'tcx>,
724        a: ty::Region<'tcx>,
725        b: ty::Region<'tcx>,
726        _constraint_category: ConstraintCategory<'tcx>,
727    ) {
728        // We don't do leak check in lexical region resolution
729        self.sub_regions(origin, a, b, ty::VisibleForLeakCheck::Unreachable)
730    }
731
732    fn push_verify(
733        &mut self,
734        origin: SubregionOrigin<'tcx>,
735        kind: GenericKind<'tcx>,
736        a: ty::Region<'tcx>,
737        bound: VerifyBound<'tcx>,
738    ) {
739        self.verify_generic_bound(origin, kind, a, bound)
740    }
741}