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