Skip to main content

rustc_next_trait_solver/solve/
mod.rs

1//! The next-generation trait solver, currently still WIP.
2//!
3//! As a user of rust, you can use `-Znext-solver` to enable the new trait solver.
4//!
5//! As a developer of rustc, you shouldn't be using the new trait
6//! solver without asking the trait-system-refactor-initiative, but it can
7//! be enabled with `InferCtxtBuilder::with_next_trait_solver`. This will
8//! ensure that trait solving using that inference context will be routed
9//! to the new trait solver.
10//!
11//! For a high-level overview of how this solver works, check out the relevant
12//! section of the rustc-dev-guide.
13
14mod assembly;
15mod effect_goals;
16mod eval_ctxt;
17pub mod inspect;
18mod normalizes_to;
19mod project_goals;
20mod search_graph;
21mod trait_goals;
22
23use derive_where::derive_where;
24use rustc_type_ir::inherent::*;
25use rustc_type_ir::lang_items::SolverTraitLangItem;
26pub use rustc_type_ir::solve::*;
27use rustc_type_ir::transmute::Condition;
28use rustc_type_ir::{self as ty, Const, Interner, Region, TraitClause, TypeVisitableExt, Upcast};
29use thin_vec::{ThinVec, thin_vec};
30use tracing::instrument;
31
32pub use self::eval_ctxt::{
33    EvalCtxt, SolverDelegateEvalExt, evaluate_root_goal_for_proof_tree_raw_provider, fast_path,
34};
35use crate::delegate::SolverDelegate;
36use crate::solve::assembly::Candidate;
37
38/// How many fixpoint iterations we should attempt inside of the solver before bailing
39/// with overflow.
40///
41/// We previously used  `cx.recursion_limit().0.checked_ilog2().unwrap_or(0)` for this.
42/// However, it feels unlikely that uncreasing the recursion limit by a power of two
43/// to get one more iteration is ever useful or desirable. We now instead used a constant
44/// here. If there ever ends up some use-cases where a bigger number of fixpoint iterations
45/// is required, we can add a new attribute for that or revert this to be dependent on the
46/// recursion limit again. However, this feels very unlikely.
47const FIXPOINT_STEP_LIMIT: usize = 8;
48
49/// Whether evaluating this goal ended up changing the
50/// inference state.
51#[derive(#[automatically_derived]impl ::core::marker::StructuralPartialEq for
    HasChanged {
}
#[automatically_derived]impl ::core::cmp::PartialEq for HasChanged {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for HasChanged { }Eq, #[automatically_derived]impl ::core::fmt::Debug for HasChanged {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self { HasChanged::Yes => "Yes", HasChanged::No => "No", })
    }
}Debug, #[automatically_derived]impl ::core::hash::Hash for HasChanged {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for HasChanged {
}
#[automatically_derived]impl ::core::clone::Clone for HasChanged {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for HasChanged { }Copy)]
52pub enum HasChanged {
53    Yes,
54    No,
55}
56
57// FIXME(trait-system-refactor-initiative#117): we don't detect whether a response
58// ended up pulling down any universes.
59pub(crate) fn has_no_inference_or_external_constraints<I: Interner>(
60    response: ty::Canonical<I, Response<I>>,
61) -> bool {
62    let ExternalConstraintsData {
63        ref region_constraints,
64        ref opaque_types,
65        ref normalization_nested_goals,
66    } = *response.value.external_constraints;
67    response.value.var_values_is_identity == IsIdentity::Yes
68        && region_constraints.is_empty()
69        && opaque_types.is_empty()
70        && normalization_nested_goals.is_empty()
71}
72
73fn has_only_region_constraints<I: Interner>(response: ty::Canonical<I, Response<I>>) -> bool {
74    let ExternalConstraintsData {
75        region_constraints: _,
76        ref opaque_types,
77        ref normalization_nested_goals,
78    } = *response.value.external_constraints;
79    response.value.var_values_is_identity >= IsIdentity::ModuloRegions
80        && opaque_types.is_empty()
81        && normalization_nested_goals.is_empty()
82}
83
84impl<'a, D, I> EvalCtxt<'a, D>
85where
86    D: SolverDelegate<Interner = I>,
87    I: Interner,
88{
89    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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("compute_type_outlives_goal",
                                    "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(89u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("goal")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("goal");
                                                        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::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::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(&goal)
                                                            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: QueryResultOrRerunNonErased<I> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            let ty::OutlivesClause(ty, lt) = goal.predicate;
            let ty =
                self.normalize(goal.param_env,
                        ty::Unnormalized::new_wip(ty))?;
            if ty.has_non_region_infer() || ty.has_non_rigid_aliases() {
                self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
            } else {
                if self.cx().assumptions_on_binders() {
                    use rustc_type_ir::region_constraint::RegionConstraint;
                    let constraint = self.destructure_type_outlives(ty, lt);
                    self.register_solver_region_constraint(RegionConstraint::new_from_or(constraint));
                } else { self.register_ty_outlives(ty, lt); }
                self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
            }
        }
    }
}#[instrument(level = "trace", skip(self))]
90    fn compute_type_outlives_goal(
91        &mut self,
92        goal: Goal<I, ty::OutlivesClause<I, I::Ty>>,
93    ) -> QueryResultOrRerunNonErased<I> {
94        let ty::OutlivesClause(ty, lt) = goal.predicate;
95        let ty = self.normalize(goal.param_env, ty::Unnormalized::new_wip(ty))?;
96
97        // The normalized type can still contain non-rigid higher ranked aliases if their
98        // normalization ends up with ambiguity. Or we have non-rigid aliases inside rigid ones.
99        // Infer vars may be resolved to types/consts containing non-rigid aliases later.
100        // Thus we should stall this goal to avoid registering non-rigid type outlives into
101        // the outer infcx.
102        if ty.has_non_region_infer() || ty.has_non_rigid_aliases() {
103            self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
104        } else {
105            // We drop region constraints in ambiguous response so there's no need to add them in
106            // the ambiguous branch. Also this guarantees we don't have ty vars when destructuring
107            // type outlives.
108            if self.cx().assumptions_on_binders() {
109                use rustc_type_ir::region_constraint::RegionConstraint;
110
111                let constraint = self.destructure_type_outlives(ty, lt);
112                self.register_solver_region_constraint(RegionConstraint::new_from_or(constraint));
113            } else {
114                self.register_ty_outlives(ty, lt);
115            }
116
117            self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
118        }
119    }
120
121    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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("compute_region_outlives_goal",
                                    "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(121u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("goal")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("goal");
                                                        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::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::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(&goal)
                                                            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: QueryResultOrRerunNonErased<I> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            let ty::OutlivesClause(a, b) = goal.predicate;
            if self.cx().assumptions_on_binders() {
                use rustc_type_ir::region_constraint::{
                    LeafRegionConstraint, NoSpan, RegionConstraint,
                };
                let constraint =
                    RegionConstraint::new_leaf(LeafRegionConstraint::RegionOutlives(a,
                            b, NoSpan));
                self.register_solver_region_constraint(constraint);
            } else {
                self.register_region_outlives(a, b, VisibleForLeakCheck::Yes);
            }
            self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
        }
    }
}#[instrument(level = "trace", skip(self))]
122    fn compute_region_outlives_goal(
123        &mut self,
124        goal: Goal<I, ty::OutlivesClause<I, Region<I>>>,
125    ) -> QueryResultOrRerunNonErased<I> {
126        let ty::OutlivesClause(a, b) = goal.predicate;
127
128        if self.cx().assumptions_on_binders() {
129            use rustc_type_ir::region_constraint::{
130                LeafRegionConstraint, NoSpan, RegionConstraint,
131            };
132
133            let constraint =
134                RegionConstraint::new_leaf(LeafRegionConstraint::RegionOutlives(a, b, NoSpan));
135            self.register_solver_region_constraint(constraint);
136        } else {
137            self.register_region_outlives(a, b, VisibleForLeakCheck::Yes);
138        }
139
140        self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
141    }
142
143    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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("compute_coerce_goal",
                                    "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(143u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("goal")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("goal");
                                                        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::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::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(&goal)
                                                            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: QueryResultOrRerunNonErased<I> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            self.compute_subtype_goal(Goal {
                    param_env: goal.param_env,
                    predicate: ty::SubtypePredicate {
                        a_is_expected: false,
                        a: goal.predicate.a,
                        b: goal.predicate.b,
                    },
                })
        }
    }
}#[instrument(level = "trace", skip(self))]
144    fn compute_coerce_goal(
145        &mut self,
146        goal: Goal<I, ty::CoercePredicate<I>>,
147    ) -> QueryResultOrRerunNonErased<I> {
148        self.compute_subtype_goal(Goal {
149            param_env: goal.param_env,
150            predicate: ty::SubtypePredicate {
151                a_is_expected: false,
152                a: goal.predicate.a,
153                b: goal.predicate.b,
154            },
155        })
156    }
157
158    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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("compute_subtype_goal",
                                    "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(158u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("goal")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("goal");
                                                        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::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::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(&goal)
                                                            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: QueryResultOrRerunNonErased<I> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            match (goal.predicate.a.kind(), goal.predicate.b.kind()) {
                (ty::Infer(ty::TyVar(a_vid)), ty::Infer(ty::TyVar(b_vid))) =>
                    {
                    self.sub_unify_ty_vids_raw(a_vid, b_vid);
                    self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
                }
                _ => {
                    self.sub(goal.param_env, goal.predicate.a,
                            goal.predicate.b)?;
                    self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
                }
            }
        }
    }
}#[instrument(level = "trace", skip(self))]
159    fn compute_subtype_goal(
160        &mut self,
161        goal: Goal<I, ty::SubtypePredicate<I>>,
162    ) -> QueryResultOrRerunNonErased<I> {
163        match (goal.predicate.a.kind(), goal.predicate.b.kind()) {
164            (ty::Infer(ty::TyVar(a_vid)), ty::Infer(ty::TyVar(b_vid))) => {
165                self.sub_unify_ty_vids_raw(a_vid, b_vid);
166                self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
167            }
168            _ => {
169                self.sub(goal.param_env, goal.predicate.a, goal.predicate.b)?;
170                self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
171            }
172        }
173    }
174
175    fn compute_dyn_compatible_goal(
176        &mut self,
177        trait_def_id: I::TraitId,
178    ) -> QueryResultOrRerunNonErased<I> {
179        if self.cx().trait_is_dyn_compatible(trait_def_id) {
180            self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
181        } else {
182            Err(NoSolution.into())
183        }
184    }
185
186    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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("compute_well_formed_goal",
                                    "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(186u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("goal")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("goal");
                                                        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::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::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(&goal)
                                                            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: QueryResultOrRerunNonErased<I> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            match self.well_formed_goals(goal.param_env, goal.predicate) {
                Some(goals) => {
                    self.add_goals(GoalSource::Misc, goals)?;
                    self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
                }
                None =>
                    self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS),
            }
        }
    }
}#[instrument(level = "trace", skip(self))]
187    fn compute_well_formed_goal(
188        &mut self,
189        goal: Goal<I, I::Term>,
190    ) -> QueryResultOrRerunNonErased<I> {
191        match self.well_formed_goals(goal.param_env, goal.predicate) {
192            Some(goals) => {
193                self.add_goals(GoalSource::Misc, goals)?;
194                self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
195            }
196            None => self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS),
197        }
198    }
199
200    fn compute_unstable_feature_goal(
201        &mut self,
202        param_env: <I as Interner>::ParamEnv,
203        symbol: <I as Interner>::Symbol,
204    ) -> QueryResultOrRerunNonErased<I> {
205        if self.may_use_unstable_feature(param_env, symbol)? {
206            self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
207        } else {
208            self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
209        }
210    }
211
212    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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("compute_const_evaluatable_goal",
                                    "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(212u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("param_env")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("param_env");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("ct")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("ct");
                                                        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::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::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(&param_env)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ct)
                                                            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: QueryResultOrRerunNonErased<I> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            match ct.kind() {
                ty::ConstKind::Alias(ty::IsRigid::Yes, _) |
                    ty::ConstKind::Placeholder(_) | ty::ConstKind::Value(_) |
                    ty::ConstKind::Error(_) => {
                    self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
                }
                ty::ConstKind::Infer(_) => {
                    self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
                }
                ty::ConstKind::Alias(ty::IsRigid::No, _) => {
                    self.normalize(param_env, ty::Unnormalized::new(ct))?;
                    self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
                }
                ty::ConstKind::Param(_) | ty::ConstKind::Bound(_, _) |
                    ty::ConstKind::Expr(_) => {
                    {
                        ::core::panicking::panic_fmt(format_args!("unexpected const kind: {0:?}",
                                ct));
                    }
                }
            }
        }
    }
}#[instrument(level = "trace", skip(self))]
213    fn compute_const_evaluatable_goal(
214        &mut self,
215        Goal { param_env, predicate: ct }: Goal<I, Const<I>>,
216    ) -> QueryResultOrRerunNonErased<I> {
217        match ct.kind() {
218            ty::ConstKind::Alias(ty::IsRigid::Yes, _)
219            | ty::ConstKind::Placeholder(_)
220            | ty::ConstKind::Value(_)
221            | ty::ConstKind::Error(_) => {
222                self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
223            }
224
225            ty::ConstKind::Infer(_) => {
226                self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
227            }
228
229            ty::ConstKind::Alias(ty::IsRigid::No, _) => {
230                self.normalize(param_env, ty::Unnormalized::new(ct))?;
231                self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
232            }
233
234            // We can freely ICE here as:
235            // - `Param` gets replaced with a placeholder during canonicalization
236            // - `Bound` cannot exist as we don't have a binder around the self Type
237            // - `Expr` is part of `feature(generic_const_exprs)` and is not implemented yet
238            ty::ConstKind::Param(_) | ty::ConstKind::Bound(_, _) | ty::ConstKind::Expr(_) => {
239                panic!("unexpected const kind: {:?}", ct)
240            }
241        }
242    }
243
244    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::TRACE <=
                ::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("compute_const_arg_has_type_goal",
                                "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(244u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("goal")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("goal");
                                                    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::TRACE <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::TRACE <=
                                ::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(&goal)
                                                        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:
                                QueryResultOrRerunNonErased<I> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let (ct, ty) = goal.predicate;
                        let ct =
                            self.structurally_normalize_const(goal.param_env, ct)?;
                        let ct_ty =
                            match ct.kind() {
                                ty::ConstKind::Infer(_) => {
                                    return self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS);
                                }
                                ty::ConstKind::Error(_) => {
                                    return self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
                                }
                                ty::ConstKind::Alias(ty::IsRigid::Yes, alias_const) => {
                                    alias_const.type_of(self.cx()).skip_norm_wip()
                                }
                                ty::ConstKind::Alias(ty::IsRigid::No, _) => {
                                    ::core::panicking::panic_fmt(format_args!("not implemented: {0}",
                                            format_args!("non-rigid unevaluated constant for compute_const_arg_has_type_goal: {0:?}",
                                                ct)));
                                }
                                ty::ConstKind::Expr(_) => {
                                    ::core::panicking::panic_fmt(format_args!("not implemented: {0}",
                                            format_args!("`feature(generic_const_exprs)` is not supported in the new trait solver")));
                                }
                                ty::ConstKind::Param(_) => {
                                    {
                                        ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
                                                format_args!("`ConstKind::Param` should have been canonicalized to `Placeholder`")));
                                    }
                                }
                                ty::ConstKind::Bound(_, _) => {
                                    ::core::panicking::panic_fmt(format_args!("escaping bound vars in {0:?}",
                                            ct));
                                }
                                ty::ConstKind::Value(cv) => cv.ty(),
                                ty::ConstKind::Placeholder(placeholder) => {
                                    placeholder.find_const_ty_from_env(goal.param_env)
                                }
                            };
                        self.eq(goal.param_env, ct_ty, ty)?;
                        self.evaluate_added_goals_and_make_canonical_response(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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs:244",
                        "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(244u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                        ::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::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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 = "trace", skip(self), ret)]
245    fn compute_const_arg_has_type_goal(
246        &mut self,
247        goal: Goal<I, (Const<I>, I::Ty)>,
248    ) -> QueryResultOrRerunNonErased<I> {
249        let (ct, ty) = goal.predicate;
250        let ct = self.structurally_normalize_const(goal.param_env, ct)?;
251
252        let ct_ty = match ct.kind() {
253            ty::ConstKind::Infer(_) => {
254                return self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS);
255            }
256            ty::ConstKind::Error(_) => {
257                return self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
258            }
259            ty::ConstKind::Alias(ty::IsRigid::Yes, alias_const) => {
260                alias_const.type_of(self.cx()).skip_norm_wip()
261            }
262            ty::ConstKind::Alias(ty::IsRigid::No, _) => unimplemented!(
263                "non-rigid unevaluated constant for compute_const_arg_has_type_goal: {ct:?}"
264            ),
265            ty::ConstKind::Expr(_) => unimplemented!(
266                "`feature(generic_const_exprs)` is not supported in the new trait solver"
267            ),
268            ty::ConstKind::Param(_) => {
269                unreachable!("`ConstKind::Param` should have been canonicalized to `Placeholder`")
270            }
271            ty::ConstKind::Bound(_, _) => panic!("escaping bound vars in {:?}", ct),
272            ty::ConstKind::Value(cv) => cv.ty(),
273            ty::ConstKind::Placeholder(placeholder) => {
274                placeholder.find_const_ty_from_env(goal.param_env)
275            }
276        };
277
278        self.eq(goal.param_env, ct_ty, ty)?;
279        self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
280    }
281}
282
283impl<D, I> EvalCtxt<'_, D>
284where
285    D: SolverDelegate<Interner = I>,
286    I: Interner,
287{
288    /// Try to merge multiple possible ways to prove a goal, if that is not possible returns `None`.
289    /// We only merge candidates which are equal modulo region constraints. Long-term, we want to
290    /// emit an OR of the constraints of all candidates, for now we fail with ambiguity unless all
291    /// candidates have the same constraints or one candidate has no region constraints at all.
292    ///
293    /// In this case we tend to flounder and return ambiguity by calling `[EvalCtxt::flounder]`.
294    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::TRACE <=
                ::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("try_merge_candidates",
                                "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(294u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("candidates")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("candidates");
                                                    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::TRACE <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::TRACE <=
                                ::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(&candidates)
                                                        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<CanonicalResponse<I>> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let Some((first, rest)) =
                            candidates.split_first() else { return None; };
                        if rest.iter().all(|c| first.result == c.result) {
                            return Some(first.result);
                        }
                        if let Some(choice) =
                                candidates.iter().find(|c|
                                        c.result.value.external_constraints.region_constraints.is_empty())
                            {
                            if candidates.iter().all(|c|
                                        self.responses_equal_modulo_region_constraints(&choice.result,
                                            &c.result)) {
                                return Some(choice.result);
                            }
                        }
                        None
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs:294",
                        "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(294u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                        ::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::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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 = "trace", skip(self), ret)]
295    fn try_merge_candidates(
296        &mut self,
297        candidates: &[Candidate<I>],
298    ) -> Option<CanonicalResponse<I>> {
299        let Some((first, rest)) = candidates.split_first() else {
300            return None;
301        };
302
303        // If all candidates are equal, just return that result.
304        if rest.iter().all(|c| first.result == c.result) {
305            return Some(first.result);
306        }
307
308        // If not, check whether one of the candidates has no region constraints.
309        // Long-term we likely want to also handle cases where one candidate has
310        // strictly weaker region constraints or emit an OR of the region constraints
311        // if candidates are otherwise equal.
312        //
313        // While we could also prefer candidates with weaker non-region constraints,
314        // that's currently not necessary. We intentionally do not prefer candidates
315        // if there's still am ambiguous candidate. We do so to potentially better
316        // handle region uniquification at the start of MIR borrowck, see #163928 for
317        // more details.
318        if let Some(choice) = candidates
319            .iter()
320            .find(|c| c.result.value.external_constraints.region_constraints.is_empty())
321        {
322            if candidates
323                .iter()
324                .all(|c| self.responses_equal_modulo_region_constraints(&choice.result, &c.result))
325            {
326                return Some(choice.result);
327            }
328        }
329
330        None
331    }
332
333    fn bail_with_ambiguity(&mut self, candidates: &[Candidate<I>]) -> CanonicalResponse<I> {
334        if true {
    if !(candidates.len() > 1) {
        ::core::panicking::panic("assertion failed: candidates.len() > 1")
    };
};debug_assert!(candidates.len() > 1);
335        let maybe = candidates.iter().fold(MaybeInfo::AMBIGUOUS, |maybe, candidate| {
336            // We pull down the certainty of `Certainty::Yes` to ambiguity when combining
337            // these responses, b/c we're combining more than one response and this we
338            // don't know which one applies.
339            match candidate.result.value.certainty {
340                Certainty::Yes => maybe,
341                Certainty::Maybe(cand_maybe) => maybe.or(cand_maybe),
342            }
343        });
344        self.make_ambiguous_response_no_constraints(maybe)
345    }
346
347    /// If we fail to merge responses we flounder and return overflow or ambiguity.
348    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::TRACE <=
                ::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("flounder",
                                "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(348u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("candidates")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("candidates");
                                                    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::TRACE <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::TRACE <=
                                ::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(&candidates)
                                                        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: QueryResult<I> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if candidates.is_empty() {
                            return Err(NoSolution);
                        } else { Ok(self.bail_with_ambiguity(candidates)) }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs:348",
                        "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(348u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                        ::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::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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 = "trace", skip(self), ret)]
349    fn flounder(&mut self, candidates: &[Candidate<I>]) -> QueryResult<I> {
350        if candidates.is_empty() {
351            return Err(NoSolution);
352        } else {
353            Ok(self.bail_with_ambiguity(candidates))
354        }
355    }
356
357    /// Normalize a type for when it is structurally matched on.
358    ///
359    /// This function is necessary in nearly all cases before matching on a type.
360    /// Not doing so is likely to be incomplete and therefore unsound during
361    /// coherence.
362    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::TRACE <=
                ::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("structurally_normalize_ty",
                                "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(362u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                ::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()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::TRACE <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::TRACE <=
                                ::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))])
                        })
            } 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<I::Ty, NoSolutionOrRerunNonErased> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        self.structurally_normalize_term(param_env,
                                ty.into()).map(|term| term.expect_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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs:362",
                        "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(362u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                        ::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::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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 = "trace", skip(self, param_env), ret)]
363    fn structurally_normalize_ty(
364        &mut self,
365        param_env: I::ParamEnv,
366        ty: I::Ty,
367    ) -> Result<I::Ty, NoSolutionOrRerunNonErased> {
368        self.structurally_normalize_term(param_env, ty.into()).map(|term| term.expect_ty())
369    }
370
371    /// Normalize a const for when it is structurally matched on, or more likely
372    /// when it needs `.try_to_*` called on it (e.g. to turn it into a usize).
373    ///
374    /// This function is necessary in nearly all cases before matching on a const.
375    /// Not doing so is likely to be incomplete and therefore unsound during
376    /// coherence.
377    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::TRACE <=
                ::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("structurally_normalize_const",
                                "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(377u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("ct")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("ct");
                                                    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::TRACE <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::TRACE <=
                                ::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(&ct)
                                                        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:
                                Result<Const<I>, NoSolutionOrRerunNonErased> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        self.structurally_normalize_term(param_env,
                                ct.into()).map(|term| term.expect_const())
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs:377",
                        "rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(377u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                        ::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::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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 = "trace", skip(self, param_env), ret)]
378    fn structurally_normalize_const(
379        &mut self,
380        param_env: I::ParamEnv,
381        ct: Const<I>,
382    ) -> Result<Const<I>, NoSolutionOrRerunNonErased> {
383        self.structurally_normalize_term(param_env, ct.into()).map(|term| term.expect_const())
384    }
385
386    /// Normalize a term for when it is structurally matched on.
387    ///
388    /// This function is necessary in nearly all cases before matching on a ty/const.
389    /// Not doing so is likely to be incomplete and therefore unsound during coherence.
390    fn structurally_normalize_term(
391        &mut self,
392        param_env: I::ParamEnv,
393        term: I::Term,
394    ) -> Result<I::Term, NoSolutionOrRerunNonErased> {
395        if !self.cx().renormalize_rigid_aliases() && !term.is_non_rigid_alias() {
396            return Ok(term);
397        }
398
399        if let Some(alias) = term.to_alias_term() {
400            let normalized_term = self.next_term_infer_of_alias_kind(alias);
401            let projection_goal = Goal::new(
402                self.cx(),
403                param_env,
404                ty::ProjectionClause { projection_term: alias, term: normalized_term },
405            );
406            // We normalize the self type to be able to relate it with
407            // types from candidates.
408            self.add_goal(GoalSource::Normalization, projection_goal)?;
409            self.try_evaluate_added_goals()?;
410            Ok(self.deeply_resolve_ignoring_regions(normalized_term))
411        } else {
412            Ok(term)
413        }
414    }
415}
416
417/// The result of evaluating a goal.
418#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for GoalEvaluation<I> where I: Interner {
    fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
        -> ::core::fmt::Result {
        match self {
            GoalEvaluation {
                goal: ref __field_goal,
                certainty: ref __field_certainty,
                has_changed: ref __field_has_changed,
                stalled_on: ref __field_stalled_on } => {
                let mut __builder =
                    ::core::fmt::Formatter::debug_struct(__f, "GoalEvaluation");
                ::core::fmt::DebugStruct::field(&mut __builder, "goal",
                    __field_goal);
                ::core::fmt::DebugStruct::field(&mut __builder, "certainty",
                    __field_certainty);
                ::core::fmt::DebugStruct::field(&mut __builder, "has_changed",
                    __field_has_changed);
                ::core::fmt::DebugStruct::field(&mut __builder, "stalled_on",
                    __field_stalled_on);
                ::core::fmt::DebugStruct::finish(&mut __builder)
            }
        }
    }
}#[derive_where(Debug; I: Interner)]
419pub struct GoalEvaluation<I: Interner> {
420    /// The goal we've evaluated. This is the input goal, but potentially with its
421    /// inference variables resolved. This never applies any inference constraints
422    /// from evaluating the goal.
423    ///
424    /// We rely on this to check whether root goals in HIR typeck had an unresolved
425    /// type inference variable in the input. We must not resolve this after evaluating
426    /// the goal as even if the inference variable has been resolved by evaluating the
427    /// goal itself, this goal may still end up failing due to region uniquification
428    /// later on.
429    ///
430    /// This is used as a minor optimization to avoid re-resolving inference variables
431    /// when reevaluating ambiguous goals. E.g. if we've got a goal `?x: Trait` with `?x`
432    /// already being constrained to `Vec<?y>`, then the first evaluation resolves it to
433    /// `Vec<?y>: Trait`. If this goal is still ambiguous and we later resolve `?y` to `u32`,
434    /// then reevaluating this goal now only needs to resolve `?y` while it would otherwise
435    /// have to resolve both `?x` and `?y`,
436    pub goal: Goal<I, I::Predicate>,
437    pub certainty: Certainty,
438    pub has_changed: HasChanged,
439    /// If the [`Certainty`] was `Maybe`, then keep track of whether the goal has changed
440    /// before rerunning it.
441    pub stalled_on: Option<GoalStalledOn<I>>,
442}
443
444/// Flatten the `Condition` tree into a conjunction of predicates.
445{}
#[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("flatten_answer_tree",
                                    "rustc_next_trait_solver::solve", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_next_trait_solver/src/solve/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(445u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("cond")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("cond");
                                                        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(&cond)
                                                            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: ThinVec<I::Predicate> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            match cond {
                Condition::IfAll(conds) | Condition::IfAny(conds) =>
                    conds.into_iter().flat_map(|cond|
                                flatten_answer_tree(interner, predicate, cond)).collect(),
                Condition::Immutable { ty } => {
                    let trait_ref =
                        ty::TraitRef::new(interner,
                            interner.require_trait_lang_item(SolverTraitLangItem::Freeze),
                            [I::GenericArg::from(ty)]);
                    {
                        let len = [()].len();
                        let mut vec = ::thin_vec::ThinVec::with_capacity(len);
                        vec.push(trait_ref.upcast(interner));
                        vec
                    }
                }
                Condition::Outlives { long, short } => {
                    let outlives = ty::OutlivesClause(long, short);
                    {
                        let len = [()].len();
                        let mut vec = ::thin_vec::ThinVec::with_capacity(len);
                        vec.push(outlives.upcast(interner));
                        vec
                    }
                }
                Condition::Transmutable { src, dst } => {
                    let transmute_trait = predicate.def_id();
                    let assume = predicate.trait_ref.args.const_at(2);
                    let trait_ref =
                        ty::TraitRef::new(interner, transmute_trait,
                            [I::GenericArg::from(dst), I::GenericArg::from(src),
                                    I::GenericArg::from(assume)]);
                    {
                        let len = [()].len();
                        let mut vec = ::thin_vec::ThinVec::with_capacity(len);
                        vec.push(trait_ref.upcast(interner));
                        vec
                    }
                }
            }
        }
    }
}#[instrument(level = "debug", skip(interner, predicate))]
446pub fn flatten_answer_tree<I: Interner>(
447    interner: I,
448    predicate: TraitClause<I>,
449    cond: Condition<Region<I>, I::Ty>,
450) -> ThinVec<I::Predicate> {
451    match cond {
452        // FIXME(bryangarza): Add separate `IfAny` case, instead of treating as `IfAll`
453        // Not possible until the trait solver supports disjunctions of obligations
454        Condition::IfAll(conds) | Condition::IfAny(conds) => conds
455            .into_iter()
456            .flat_map(|cond| flatten_answer_tree(interner, predicate, cond))
457            .collect(),
458        Condition::Immutable { ty } => {
459            let trait_ref = ty::TraitRef::new(
460                interner,
461                interner.require_trait_lang_item(SolverTraitLangItem::Freeze),
462                [I::GenericArg::from(ty)],
463            );
464            thin_vec![trait_ref.upcast(interner)]
465        }
466        Condition::Outlives { long, short } => {
467            let outlives = ty::OutlivesClause(long, short);
468            thin_vec![outlives.upcast(interner)]
469        }
470        Condition::Transmutable { src, dst } => {
471            let transmute_trait = predicate.def_id();
472            let assume = predicate.trait_ref.args.const_at(2);
473            let trait_ref = ty::TraitRef::new(
474                interner,
475                transmute_trait,
476                [I::GenericArg::from(dst), I::GenericArg::from(src), I::GenericArg::from(assume)],
477            );
478            thin_vec![trait_ref.upcast(interner)]
479        }
480    }
481}