Skip to main content

rustc_next_trait_solver/solve/eval_ctxt/
solver_region_constraints.rs

1//! Logic for `-Zassumptions-on-binders` stuff
2
3#[cfg(feature = "nightly")]
4use rustc_data_structures::transitive_relation::TransitiveRelationBuilder;
5use rustc_type_ir::inherent::*;
6use rustc_type_ir::outlives::{Component, push_outlives_components};
7#[cfg(not(feature = "nightly"))]
8use rustc_type_ir::region_constraint::TransitiveRelationBuilder;
9use rustc_type_ir::region_constraint::{
10    And, Assumptions, LeafRegionConstraint, Or, eagerly_handle_placeholders_in_universe,
11};
12use rustc_type_ir::{
13    AliasTy, Binder, ClauseKind, Const, InferCtxtLike, Interner, Region, TypeVisitable,
14    TypeVisitableExt, TypeVisitor, UniverseIndex,
15};
16use tracing::{debug, instrument};
17
18use crate::delegate::SolverDelegate;
19use crate::solve::{Certainty, EvalCtxt, Goal, NoSolution};
20
21/// Logic for `-Zassumptions-on-binders` stuff
22impl<'a, D, I> EvalCtxt<'a, D>
23where
24    D: SolverDelegate<Interner = I>,
25    I: Interner,
26{
27    /// Computes the assumptions associated with a binder for use in eagerly handling placeholders when
28    /// exiting the binder. Though, right now we do not actually handle placeholders when exiting binders,
29    /// instead we handle placeholders when computing the final response for the goal being computed.
30    {}
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("region_assumptions_for_placeholders_in_universe",
                                "rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs"),
                                ::tracing_core::__macro_support::Option::Some(30u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("t")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("t");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("u")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("u");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("param_env")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("param_env");
                                                    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(&t)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&u)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&param_env)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: Option<Assumptions<I>> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if !self.cx().assumptions_on_binders() {
                            ::core::panicking::panic("assertion failed: self.cx().assumptions_on_binders()")
                        };
                        struct RawAssumptions<'a, 'b,
                            D: SolverDelegate<Interner = I>, I: Interner> {
                            ecx: &'a mut EvalCtxt<'b, D, I>,
                            param_env: I::ParamEnv,
                            out: Vec<Goal<I, I::Predicate>>,
                        }
                        impl<D, I> TypeVisitor<I> for RawAssumptions<'_, '_, D, I>
                            where I: Interner, D: SolverDelegate<Interner = I> {
                            type Result = ();
                            fn visit_ty(&mut self, t: I::Ty) {
                                self.out.extend(self.ecx.well_formed_goals(self.param_env,
                                                t.into()).unwrap_or(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                    [Goal::new(self.ecx.cx(), self.param_env,
                                                                ClauseKind::WellFormed(t.into()))]))).into_iter());
                            }
                            fn visit_const(&mut self, c: Const<I>) {
                                self.out.extend(self.ecx.well_formed_goals(self.param_env,
                                                c.into()).unwrap_or(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                    [Goal::new(self.ecx.cx(), self.param_env,
                                                                ClauseKind::WellFormed(c.into()))]))).into_iter());
                            }
                        }
                        let mut reqs_builder =
                            RawAssumptions {
                                ecx: self,
                                param_env,
                                out: ::alloc::vec::Vec::new(),
                            };
                        t.visit_with(&mut reqs_builder);
                        let reqs = reqs_builder.out;
                        if reqs.iter().any(|goal|
                                    { goal.predicate.has_non_region_infer() }) {
                            return None;
                        }
                        let clauses =
                            reqs.into_iter().filter_map(|goal|
                                    goal.predicate.as_clause());
                        Some(Assumptions::new(&**self.delegate, clauses,
                                TransitiveRelationBuilder::default().freeze(), u))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs:30",
                        "rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs"),
                        ::tracing_core::__macro_support::Option::Some(30u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
31    pub(super) fn region_assumptions_for_placeholders_in_universe(
32        &mut self,
33        t: impl TypeVisitable<I>,
34        u: UniverseIndex,
35        param_env: I::ParamEnv,
36    ) -> Option<Assumptions<I>> {
37        assert!(self.cx().assumptions_on_binders());
38
39        struct RawAssumptions<'a, 'b, D: SolverDelegate<Interner = I>, I: Interner> {
40            ecx: &'a mut EvalCtxt<'b, D, I>,
41            param_env: I::ParamEnv,
42            out: Vec<Goal<I, I::Predicate>>,
43        }
44
45        impl<D, I> TypeVisitor<I> for RawAssumptions<'_, '_, D, I>
46        where
47            I: Interner,
48            D: SolverDelegate<Interner = I>,
49        {
50            type Result = ();
51
52            fn visit_ty(&mut self, t: I::Ty) {
53                self.out.extend(
54                    self.ecx
55                        .well_formed_goals(self.param_env, t.into())
56                        .unwrap_or(vec![Goal::new(
57                            self.ecx.cx(),
58                            self.param_env,
59                            ClauseKind::WellFormed(t.into()),
60                        )])
61                        .into_iter(),
62                );
63            }
64
65            fn visit_const(&mut self, c: Const<I>) {
66                self.out.extend(
67                    self.ecx
68                        .well_formed_goals(self.param_env, c.into())
69                        .unwrap_or(vec![Goal::new(
70                            self.ecx.cx(),
71                            self.param_env,
72                            ClauseKind::WellFormed(c.into()),
73                        )])
74                        .into_iter(),
75                );
76            }
77        }
78
79        let mut reqs_builder = RawAssumptions { ecx: self, param_env, out: vec![] };
80        t.visit_with(&mut reqs_builder);
81        let reqs = reqs_builder.out;
82
83        // If there are inference variables in type outlives then we may not be able
84        // to elaborate to the full set of implied bounds right now. To avoid incorrectly
85        // NoSolution'ing when lifting constraints to a lower universe due to no usable
86        // assumptions, we just bail here.
87        //
88        // This is somewhat imprecise as if both the infer var and the outlived region are
89        // in a lower universe than the binder we're computing assumptions for then it doesn't
90        // really matter as we wouldn't use those outlives as assumptions anyway.
91        if reqs.iter().any(|goal| {
92            // We don't care about region infers as they can't be further destructured
93            goal.predicate.has_non_region_infer()
94        }) {
95            return None;
96        }
97
98        // FIXME(-Zassumptions-on-binders): we need to normalize here/somewhere
99        // as we assume the type outlives assumptions only have rigid types :>
100        //
101        // `Assumptions::new` elaborates, restricts the clauses to `u` and picks out the
102        // outlives ones for us, so we just hand over everything the requirements gave us.
103        let clauses = reqs.into_iter().filter_map(|goal| goal.predicate.as_clause());
104
105        Some(Assumptions::new(
106            &**self.delegate,
107            clauses,
108            TransitiveRelationBuilder::default().freeze(),
109            u,
110        ))
111    }
112
113    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("eagerly_handle_placeholders",
                                "rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs"),
                                ::tracing_core::__macro_support::Option::Some(113u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints"),
                                ::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();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                Result<Certainty, NoSolution> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let constraint =
                            self.delegate.get_solver_region_constraint();
                        let smallest_universe = self.max_input_universe;
                        let largest_universe = self.delegate.universe();
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs:119",
                                                "rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs"),
                                                ::tracing_core::__macro_support::Option::Some(119u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints"),
                                                ::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!("smallest_universe={0:#?}, largest_universe={1:#?}",
                                                                            smallest_universe, largest_universe) as
                                                                    &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        if !self.delegate.has_placeholder_assumptions(((smallest_universe
                                                        + 1)..=largest_universe).into()) {
                            return Ok(Certainty::AMBIGUOUS);
                        }
                        let constraint =
                            ((smallest_universe.index() +
                                                        1)..=largest_universe.index()).map(UniverseIndex::from_usize).rev().fold(constraint,
                                |constraint, u|
                                    {
                                        eagerly_handle_placeholders_in_universe(&**self.delegate,
                                            constraint, u)
                                    });
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs:139",
                                                "rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs"),
                                                ::tracing_core::__macro_support::Option::Some(139u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints"),
                                                ::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!("final constraint={0:?}",
                                                                            constraint) as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        self.delegate.overwrite_solver_region_constraint(constraint.clone(),
                            self.origin_span);
                        if constraint.is_false() {
                            Err(NoSolution)
                        } else if constraint.is_ambig() {
                            Ok(Certainty::AMBIGUOUS)
                        } else { Ok(Certainty::Yes) }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs:113",
                        "rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs"),
                        ::tracing_core::__macro_support::Option::Some(113u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
114    pub(super) fn eagerly_handle_placeholders(&mut self) -> Result<Certainty, NoSolution> {
115        let constraint = self.delegate.get_solver_region_constraint();
116
117        let smallest_universe = self.max_input_universe;
118        let largest_universe = self.delegate.universe();
119        debug!("smallest_universe={smallest_universe:#?}, largest_universe={largest_universe:#?}");
120
121        // We rely on placeholder assumptions to evaluate region constraints with placeholders.
122        // But we can fail to compute assumptions due to unresolved type variables. In that case,
123        // we conservatively bail with ambiguity.
124        if !self
125            .delegate
126            .has_placeholder_assumptions(((smallest_universe + 1)..=largest_universe).into())
127        {
128            return Ok(Certainty::AMBIGUOUS);
129        }
130
131        // Walk around that `Step` trait is nightly only.
132        let constraint = ((smallest_universe.index() + 1)..=largest_universe.index())
133            .map(UniverseIndex::from_usize)
134            .rev()
135            .fold(constraint, |constraint, u| {
136                eagerly_handle_placeholders_in_universe(&**self.delegate, constraint, u)
137            });
138
139        debug!("final constraint={:?}", constraint);
140        self.delegate.overwrite_solver_region_constraint(constraint.clone(), self.origin_span);
141
142        if constraint.is_false() {
143            Err(NoSolution)
144        } else if constraint.is_ambig() {
145            Ok(Certainty::AMBIGUOUS)
146        } else {
147            Ok(Certainty::Yes)
148        }
149    }
150
151    /// Convert a type outlives constraint into a set of region outlives constraints and
152    /// type outlives constraints between the "components" of the type. E.g. `Foo<T, 'a>: 'b`
153    /// will be turned into `T: 'b, 'a: 'b`
154    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("destructure_type_outlives",
                                "rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs"),
                                ::tracing_core::__macro_support::Option::Some(154u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    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("r")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("r");
                                                    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(&ty)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&r)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: Or<I> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let mut components = Default::default();
                        push_outlives_components(self.cx(), ty, &mut components);
                        self.destructure_components(&components, r)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs:154",
                        "rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs"),
                        ::tracing_core::__macro_support::Option::Some(154u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
155    pub(in crate::solve) fn destructure_type_outlives(&mut self, ty: I::Ty, r: Region<I>) -> Or<I> {
156        let mut components = Default::default();
157        push_outlives_components(self.cx(), ty, &mut components);
158        self.destructure_components(&components, r)
159    }
160
161    fn destructure_components(&mut self, components: &[Component<I>], r: Region<I>) -> Or<I> {
162        components
163            .into_iter()
164            .fold(Or::new_true(), |acc, c| Or::build_and(acc, self.destructure_component(c, r)))
165    }
166
167    fn destructure_component(&mut self, c: &Component<I>, r: Region<I>) -> Or<I> {
168        use Component::*;
169        use LeafRegionConstraint::*;
170        match c {
171            Region(c_r) => Or::new_leaf(RegionOutlives(*c_r, r, ())),
172            Placeholder(p) => {
173                Or::new_leaf(PlaceholderTyOutlives(Ty::new_placeholder(self.cx(), *p), r, ()))
174            }
175            Alias(_, alias) => self.destructure_alias_outlives(*alias, r),
176            UnresolvedInferenceVariable(_) => {
177                {
    ::core::panicking::panic_fmt(format_args!("Shouldn\'t destructure type outlives when ty vars exist"));
}panic!("Shouldn't destructure type outlives when ty vars exist")
178            }
179            Param(_) => {
    ::core::panicking::panic_fmt(format_args!("Params should have been canonicalized to placeholders"));
}panic!("Params should have been canonicalized to placeholders"),
180            EscapingAlias(components) => self.destructure_components(components, r),
181        }
182    }
183
184    /// Convert an alias outlives constraint into an OR constraint of any number of three
185    /// separate classes of candidates:
186    /// 1. component outlives. we turn `Alias<T, 'a>: 'b` into `T: 'b, 'a: 'b`.
187    /// 2. item bounds. we turn `Alias<T, 'a>: 'b` into `'c: 'b` if `Alias` is
188    ///     defined as `type Alias<T, 'a>: 'c`
189    /// 3. env assumptions. we defer handling `Alias<T, 'a>: 'b` via where clauses until
190    ///     when exiting the current binder. See [`LeafRegionConstraint::AliasTyOutlivesViaEnv`].
191    {}
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_alias_outlives",
                                "rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs"),
                                ::tracing_core::__macro_support::Option::Some(191u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("alias")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("alias");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("r")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("r");
                                                    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(&alias)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&r)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: Or<I> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        use LeafRegionConstraint::*;
                        let item_bounds =
                            rustc_type_ir::outlives::declared_bounds_from_definition(self.cx(),
                                    alias).map(|bound|
                                    And::new([RegionOutlives(bound, r, ())]));
                        let item_bound_outlives = Or::new(item_bounds);
                        let where_clause_outlives =
                            Or::new_leaf(AliasTyOutlivesViaEnv(Binder::dummy((alias,
                                            r)), ()));
                        let mut components = Default::default();
                        rustc_type_ir::outlives::compute_alias_components_recursive(self.cx(),
                            alias, &mut components);
                        let components_outlives =
                            self.destructure_components(&components, r);
                        let assumption_outlives =
                            Or::build_or(item_bound_outlives, where_clause_outlives);
                        Or::build_or(assumption_outlives, components_outlives)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs:191",
                        "rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/db8f076d2619ce2585b0380dda06e8da25a40da4/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/solver_region_constraints.rs"),
                        ::tracing_core::__macro_support::Option::Some(191u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt::solver_region_constraints"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
192    fn destructure_alias_outlives(&mut self, alias: AliasTy<I>, r: Region<I>) -> Or<I> {
193        use LeafRegionConstraint::*;
194
195        let item_bounds =
196            rustc_type_ir::outlives::declared_bounds_from_definition(self.cx(), alias)
197                .map(|bound| And::new([RegionOutlives(bound, r, ())]));
198        let item_bound_outlives = Or::new(item_bounds);
199
200        let where_clause_outlives =
201            Or::new_leaf(AliasTyOutlivesViaEnv(Binder::dummy((alias, r)), ()));
202
203        let mut components = Default::default();
204        rustc_type_ir::outlives::compute_alias_components_recursive(
205            self.cx(),
206            alias,
207            &mut components,
208        );
209        let components_outlives = self.destructure_components(&components, r);
210
211        let assumption_outlives = Or::build_or(item_bound_outlives, where_clause_outlives);
212        Or::build_or(assumption_outlives, components_outlives)
213    }
214}