Skip to main content

rustc_next_trait_solver/solve/eval_ctxt/
mod.rs

1use std::mem;
2use std::ops::ControlFlow;
3
4#[cfg(feature = "nightly")]
5use rustc_macros::StableHash;
6use rustc_type_ir::data_structures::HashSet;
7use rustc_type_ir::inherent::*;
8use rustc_type_ir::region_constraint::{self, RegionConstraint};
9use rustc_type_ir::relate::Relate;
10use rustc_type_ir::relate::solver_relating::RelateExt;
11use rustc_type_ir::search_graph::{
12    CandidateHeadUsages, LowerAvailableDepth, PathKind, RequiredDepth,
13};
14use rustc_type_ir::solve::{
15    AccessedOpaques, ExternalRegionConstraints, FetchEligibleAssocItemResponse, MaybeInfo,
16    NoSolutionOrRerunNonErased, OpaqueTypesJank, QueryResultOrRerunNonErased, RerunCondition,
17    RerunNonErased, RerunReason, RerunResultExt, SmallCopySet, TyOrConstInferVar,
18};
19use rustc_type_ir::{
20    self as ty, CanonicalVarValues, ClauseKind, Const, InferCtxtLike, Interner, MayBeErased,
21    OpaqueTypeKey, PredicateKind, PredicateProxy, Region, RegionVid, TypeFoldable,
22    TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode, max_universe,
23};
24use thin_vec::ThinVec;
25use tracing::{Level, debug, instrument, trace, warn};
26
27use super::has_only_region_constraints;
28use crate::canonical::{
29    canonicalize_goal, canonicalize_response, instantiate_and_apply_query_response,
30    response_no_constraints_raw,
31};
32use crate::coherence;
33use crate::delegate::SolverDelegate;
34use crate::normalize::{NormalizationFolder, NormalizationWasAmbiguous};
35use crate::placeholder::BoundVarReplacer;
36use crate::solve::eval_ctxt::fast_path::{
37    RerunStalled, compute_goal_fast_path, inlined_rerunning_stalled_goal_may_make_progress,
38    rerunning_stalled_goal_may_make_progress,
39};
40use crate::solve::fast_path::compute_goal_fast_path_cold;
41use crate::solve::search_graph::SearchGraph;
42use crate::solve::ty::may_use_unstable_feature;
43use crate::solve::{
44    CanonicalResponse, Certainty, ExternalConstraintsData, FIXPOINT_STEP_LIMIT, Goal,
45    GoalEvaluation, GoalSource, GoalStalledOn, GoalStalledOnOpaques, HasChanged, MaybeCause,
46    NestedNormalizationGoals, NoSolution, QueryInput, QueryResult, Response, SucceededInErased,
47    VisibleForLeakCheck, inspect,
48};
49
50pub mod fast_path;
51mod probe;
52mod solver_region_constraints;
53
54/// The kind of goal we're currently proving.
55///
56/// This has effects on cycle handling handling and on how we compute
57/// query responses, see the variant descriptions for more info.
58#[derive(#[automatically_derived]
impl ::core::fmt::Debug for CurrentGoalKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                CurrentGoalKind::Misc => "Misc",
                CurrentGoalKind::CoinductiveTrait => "CoinductiveTrait",
                CurrentGoalKind::ProjectionComputeAssocTermCandidate =>
                    "ProjectionComputeAssocTermCandidate",
            })
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for CurrentGoalKind { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for CurrentGoalKind { }
#[automatically_derived]
impl ::core::clone::Clone for CurrentGoalKind {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone)]
59enum CurrentGoalKind {
60    Misc,
61    /// We're proving an trait goal for a coinductive trait, either an auto trait or `Sized`.
62    ///
63    /// These are currently the only goals whose impl where-clauses are considered to be
64    /// productive steps.
65    CoinductiveTrait,
66    // FIXME: Consider renaming `PredicateKind::NormalizesTo` to match with this
67    /// Unlike other goals, `NormalizesTo` goals aren't independent goals but just implementation
68    /// details for handling projections of associated terms. When we encounter a `Projection` goal
69    /// whose `projection_term` is an associated term, we create a `NormalizesTo` goal whose
70    /// expected term is fully unconstrained and evaluate it.
71    ///
72    /// This would weaken inference however, as the nested goals of normalizes-to never get the
73    /// inference constraints from the actual expected term. We just gather candidates from the
74    /// normalizes-to goal and return any ambiguous nested goals of it to the caller (`Projection
75    /// goal`). The caller handle and evaluate them as if they were its own nested goals.
76    ///
77    /// Because of this, evaluating a normalizes-to goal is computing candidates for projection of
78    /// an associated term and it never leaks out of the solver.
79    ProjectionComputeAssocTermCandidate,
80}
81
82impl CurrentGoalKind {
83    fn from_query_input<I: Interner>(cx: I, input: QueryInput<I, I::Predicate>) -> CurrentGoalKind {
84        match input.goal.predicate.kind().skip_binder() {
85            ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
86                if cx.trait_is_coinductive(pred.trait_ref.def_id) {
87                    CurrentGoalKind::CoinductiveTrait
88                } else {
89                    CurrentGoalKind::Misc
90                }
91            }
92            ty::PredicateKind::NormalizesTo(_) => {
93                CurrentGoalKind::ProjectionComputeAssocTermCandidate
94            }
95            _ => CurrentGoalKind::Misc,
96        }
97    }
98}
99
100pub struct EvalCtxt<'a, D, I = <D as SolverDelegate>::Interner>
101where
102    D: SolverDelegate<Interner = I>,
103    I: Interner,
104{
105    /// The inference context that backs (mostly) inference and placeholder terms
106    /// instantiated while solving goals.
107    ///
108    /// NOTE: The `InferCtxt` that backs the `EvalCtxt` is intentionally private,
109    /// because the `InferCtxt` is much more general than `EvalCtxt`. Methods such
110    /// as  `take_registered_region_obligations` can mess up query responses,
111    /// using `At::normalize` is totally wrong, calling `evaluate_root_goal` can
112    /// cause coinductive unsoundness, etc.
113    ///
114    /// Methods that are generally of use for trait solving are *intentionally*
115    /// re-declared through the `EvalCtxt` below, often with cleaner signatures
116    /// since we don't care about things like `ObligationCause`s and `Span`s here.
117    /// If some `InferCtxt` method is missing, please first think defensively about
118    /// the method's compatibility with this solver, or if an existing one does
119    /// the job already.
120    delegate: &'a D,
121
122    /// The variable info for the `var_values`, only used to make an ambiguous response
123    /// with no constraints.
124    var_kinds: I::CanonicalVarKinds,
125
126    /// What kind of goal we're currently computing, see the enum definition
127    /// for more info.
128    current_goal_kind: CurrentGoalKind,
129    pub(super) var_values: CanonicalVarValues<I>,
130
131    /// The highest universe index nameable by the caller.
132    ///
133    /// When we enter a new binder inside of the query we create new universes
134    /// which the caller cannot name. We have to be careful with variables from
135    /// these new universes when creating the query response.
136    ///
137    /// Both because these new universes can prevent us from reaching a fixpoint
138    /// if we have a coinductive cycle and because that's the only way we can return
139    /// new placeholders to the caller.
140    pub(super) max_input_universe: ty::UniverseIndex,
141    /// The opaque types from the canonical input. We only need to return opaque types
142    /// which have been added to the storage while evaluating this goal.
143    pub(super) initial_opaque_types_storage_num_entries:
144        <D::Infcx as InferCtxtLike>::OpaqueTypeStorageEntries,
145
146    pub(super) search_graph: &'a mut SearchGraph<D>,
147
148    nested_goals: Vec<(GoalSource, Goal<I, I::Predicate>, Option<GoalStalledOn<I>>)>,
149
150    pub(super) origin_span: I::Span,
151
152    // Has this `EvalCtxt` errored out with `NoSolution` in `try_evaluate_added_goals`?
153    //
154    // If so, then it can no longer be used to make a canonical query response,
155    // since subsequent calls to `try_evaluate_added_goals` have possibly dropped
156    // ambiguous goals. Instead, a probe needs to be introduced somewhere in the
157    // evaluation code.
158    tainted: Result<(), NoSolution>,
159
160    /// Tracks accesses of opaque types while in [`TypingMode::ErasedNotCoherence`].
161    pub(super) opaque_accesses: AccessedOpaques<I>,
162
163    pub(super) inspect: inspect::EvaluationStepBuilder<D>,
164}
165
166#[derive(#[automatically_derived]
impl ::core::marker::StructuralPartialEq for GenerateProofTree { }
#[automatically_derived]
impl ::core::cmp::PartialEq for GenerateProofTree {
    #[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 GenerateProofTree { }Eq, #[automatically_derived]
impl ::core::fmt::Debug for GenerateProofTree {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                GenerateProofTree::Yes => "Yes",
                GenerateProofTree::No => "No",
            })
    }
}Debug, #[automatically_derived]
impl ::core::hash::Hash for GenerateProofTree {
    #[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 GenerateProofTree { }
#[automatically_derived]
impl ::core::clone::Clone for GenerateProofTree {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for GenerateProofTree { }Copy)]
167#[cfg_attr(feature = "nightly", derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            GenerateProofTree {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    GenerateProofTree::Yes => {}
                    GenerateProofTree::No => {}
                }
            }
        }
    };StableHash))]
168pub enum GenerateProofTree {
169    Yes,
170    No,
171}
172
173pub trait SolverDelegateEvalExt: SolverDelegate {
174    /// Evaluates a goal from **outside** of the trait solver.
175    ///
176    /// Using this while inside of the solver is wrong as it uses a new
177    /// search graph which would break cycle detection.
178    fn evaluate_root_goal(
179        &self,
180        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
181        span: <Self::Interner as Interner>::Span,
182        stalled_on: Option<GoalStalledOn<Self::Interner>>,
183    ) -> Result<GoalEvaluation<Self::Interner>, NoSolution>;
184
185    /// Checks whether a stalled goal would remain stalled if re-evaluated, without consuming
186    /// `stalled_on`.
187    fn goal_remains_stalled(&self, stalled_on: &GoalStalledOn<Self::Interner>) -> bool;
188
189    /// Checks whether evaluating `goal` may hold while treating not-yet-defined
190    /// opaque types as being kind of rigid.
191    ///
192    /// See the comment on [OpaqueTypesJank] for more details.
193    fn root_goal_may_hold_opaque_types_jank(
194        &self,
195        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
196    ) -> bool;
197
198    /// Check whether evaluating `goal` with a depth of `root_depth` may
199    /// succeed. This only returns `false` if the goal is guaranteed to
200    /// not hold. In case evaluation overflows and fails with ambiguity this
201    /// returns `true`.
202    ///
203    /// This is only intended to be used as a performance optimization
204    /// in coherence checking.
205    fn root_goal_may_hold_with_depth(
206        &self,
207        root_depth: usize,
208        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
209    ) -> bool;
210
211    // FIXME: This is only exposed because we need to use it in `analyse.rs`
212    // which is not yet uplifted. Once that's done, we should remove this.
213    fn evaluate_root_goal_for_proof_tree(
214        &self,
215        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
216        span: <Self::Interner as Interner>::Span,
217    ) -> (
218        Result<NestedNormalizationGoals<Self::Interner>, NoSolution>,
219        inspect::GoalEvaluation<Self::Interner>,
220    );
221}
222
223impl<D, I> SolverDelegateEvalExt for D
224where
225    D: SolverDelegate<Interner = I>,
226    I: Interner,
227{
228    {}
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("evaluate_root_goal",
                                "rustc_next_trait_solver::solve::eval_ctxt",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(228u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                ::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()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("span")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("span");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("stalled_on")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("stalled_on");
                                                    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(&goal)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&stalled_on)
                                                        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<GoalEvaluation<I>, NoSolution> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if let RerunStalled::WontMakeProgress(stalled_maybe_info) =
                                rerunning_stalled_goal_may_make_progress(self,
                                    stalled_on.as_ref()) {
                            return Ok(GoalEvaluation {
                                        goal,
                                        certainty: Certainty::Maybe(stalled_maybe_info),
                                        has_changed: HasChanged::No,
                                        stalled_on,
                                    });
                        }
                        if stalled_on.is_some() &&
                                let Some(res) =
                                    compute_goal_fast_path_cold(self, goal, span) {
                            return Ok(res);
                        }
                        let mut result =
                            EvalCtxt::enter_root(self, self.cx().recursion_limit(),
                                span,
                                |ecx|
                                    {
                                        ecx.evaluate_goal_no_fast_paths(GoalSource::Misc, goal)
                                    });
                        maybe_evaluate_root_goal_with_higher_recursion_limit(self,
                            goal, span, &mut result);
                        match result {
                            Ok(i) => Ok(i),
                            Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) =>
                                Err(NoSolution),
                            Err(NoSolutionOrRerunNonErased::RerunNonErased(_)) => {
                                {
                                    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
                                            format_args!("this never happens at the root, we\'re never in erased mode here")));
                                };
                            }
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:228",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(228u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
229    fn evaluate_root_goal(
230        &self,
231        goal: Goal<I, I::Predicate>,
232        span: I::Span,
233        stalled_on: Option<GoalStalledOn<I>>,
234    ) -> Result<GoalEvaluation<I>, NoSolution> {
235        // Run fast paths *before* building an `EvalCtxt`, saving a little bit of time.
236        if let RerunStalled::WontMakeProgress(stalled_maybe_info) =
237            rerunning_stalled_goal_may_make_progress(self, stalled_on.as_ref())
238        {
239            return Ok(GoalEvaluation {
240                goal,
241                certainty: Certainty::Maybe(stalled_maybe_info),
242                has_changed: HasChanged::No,
243                stalled_on,
244            });
245        }
246
247        // No need to try the fast path if stalled_on is `None`, since we already try the fast path
248        // immediately when adding new goals. If we didn't check `stalled_on` here we'd be trying
249        // the fast path twice for some goals.
250        if stalled_on.is_some()
251            && let Some(res) = compute_goal_fast_path_cold(self, goal, span)
252        {
253            return Ok(res);
254        }
255
256        let mut result = EvalCtxt::enter_root(self, self.cx().recursion_limit(), span, |ecx| {
257            ecx.evaluate_goal_no_fast_paths(GoalSource::Misc, goal)
258        });
259        maybe_evaluate_root_goal_with_higher_recursion_limit(self, goal, span, &mut result);
260
261        match result {
262            Ok(i) => Ok(i),
263            Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) => Err(NoSolution),
264            Err(NoSolutionOrRerunNonErased::RerunNonErased(_)) => {
265                unreachable!("this never happens at the root, we're never in erased mode here");
266            }
267        }
268    }
269
270    // This function is very hot and has a single call site.
271    #[inline(always)]
272    fn goal_remains_stalled(&self, stalled_on: &GoalStalledOn<Self::Interner>) -> bool {
273        match inlined_rerunning_stalled_goal_may_make_progress(self, Some(stalled_on)) {
274            RerunStalled::WontMakeProgress(_) => true,
275            RerunStalled::MayMakeProgress => false,
276        }
277    }
278
279    {}
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("root_goal_may_hold_opaque_types_jank",
                                "rustc_next_trait_solver::solve::eval_ctxt",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(279u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                ::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::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(&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: bool = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        self.probe(||
                                {
                                    self.evaluate_root_goal(goal, I::Span::dummy(),
                                            None).is_ok_and(|r|
                                            match r.certainty {
                                                Certainty::Yes => true,
                                                Certainty::Maybe(MaybeInfo {
                                                    cause: _, opaque_types_jank, stalled_on_coroutines: _ }) =>
                                                    match opaque_types_jank {
                                                        OpaqueTypesJank::AllGood => true,
                                                        OpaqueTypesJank::ErrorIfRigidSelfTy => false,
                                                    },
                                            })
                                })
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:279",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(279u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
280    fn root_goal_may_hold_opaque_types_jank(
281        &self,
282        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
283    ) -> bool {
284        self.probe(|| {
285            self.evaluate_root_goal(goal, I::Span::dummy(), None).is_ok_and(|r| match r.certainty {
286                Certainty::Yes => true,
287                Certainty::Maybe(MaybeInfo {
288                    cause: _,
289                    opaque_types_jank,
290                    stalled_on_coroutines: _,
291                }) => match opaque_types_jank {
292                    OpaqueTypesJank::AllGood => true,
293                    OpaqueTypesJank::ErrorIfRigidSelfTy => false,
294                },
295            })
296        })
297    }
298
299    fn root_goal_may_hold_with_depth(
300        &self,
301        root_depth: usize,
302        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
303    ) -> bool {
304        self.probe(|| {
305            EvalCtxt::enter_root(self, root_depth, I::Span::dummy(), |ecx| {
306                ecx.evaluate_goal(GoalSource::Misc, goal, None)
307            })
308        })
309        .is_ok()
310    }
311
312    {}
#[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("evaluate_root_goal_for_proof_tree",
                                    "rustc_next_trait_solver::solve::eval_ctxt",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(312u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                    ::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()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("span")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("span");
                                                        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(&goal)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            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:
                    (Result<NestedNormalizationGoals<I>, NoSolution>,
                    inspect::GoalEvaluation<I>) = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let mut result =
                evaluate_root_goal_for_proof_tree(self, goal, span,
                    self.cx().recursion_limit());
            maybe_evaluate_root_goal_for_proof_tree_with_higher_recursion_limit(self,
                goal, span, &mut result);
            result
        }
    }
}#[instrument(level = "debug", skip(self))]
313    fn evaluate_root_goal_for_proof_tree(
314        &self,
315        goal: Goal<I, I::Predicate>,
316        span: I::Span,
317    ) -> (Result<NestedNormalizationGoals<I>, NoSolution>, inspect::GoalEvaluation<I>) {
318        let mut result =
319            evaluate_root_goal_for_proof_tree(self, goal, span, self.cx().recursion_limit());
320        maybe_evaluate_root_goal_for_proof_tree_with_higher_recursion_limit(
321            self,
322            goal,
323            span,
324            &mut result,
325        );
326        result
327    }
328}
329
330/// The old solver doesn't check depth requirement when looking up cache while the next solver
331/// does so. Thus the next solver is more prone to overflow. To mitigate breakages, we re-evaluate
332/// the overflowed goal with doubled recursion limit and emit a FCW if doing so prevents overflow.
333///
334/// See the doc comment on `RECURSION_DEPTH_EXCEEDING_LIMIT` and #159228 for more details.
335fn maybe_evaluate_root_goal_with_higher_recursion_limit<D, I>(
336    delegate: &D,
337    goal: Goal<I, I::Predicate>,
338    span: I::Span,
339    initial_result: &mut Result<GoalEvaluation<I>, NoSolutionOrRerunNonErased>,
340) where
341    D: SolverDelegate<Interner = I>,
342    I: Interner,
343{
344    if !delegate.enable_next_solver_overflow_fcw() {
345        return;
346    }
347
348    let predicate = match initial_result {
349        Err(_) => return,
350        Ok(goal_evaluation) if !goal_evaluation.certainty.is_overflow() => return,
351        Ok(goal_evaluation) => goal_evaluation.goal.predicate,
352    };
353
354    let rerun_result = delegate.commit_if_ok(|| {
355        let rerun_result =
356            EvalCtxt::enter_root(delegate, delegate.cx().recursion_limit() * 2, span, |ecx| {
357                ecx.evaluate_goal_no_fast_paths(GoalSource::Misc, goal)
358            });
359
360        if rerun_result.as_ref().is_ok_and(|evaluation| evaluation.certainty.is_overflow()) {
361            Err(())
362        } else {
363            Ok(rerun_result)
364        }
365    });
366    if let Ok(rerun_result) = rerun_result {
367        delegate.emit_next_solver_overflow_fcw(goal.with(delegate.cx(), predicate), span);
368        *initial_result = rerun_result;
369    }
370}
371
372/// The old solver doesn't check depth requirement when looking up cache while the next solver
373/// does so. Thus the next solver is more prone to overflow. To mitigate breakages, we re-evaluate
374/// the overflowed goal with doubled recursion limit and emit a FCW if doing so prevents overflow.
375///
376/// See the doc comment on `RECURSION_DEPTH_EXCEEDING_LIMIT` and #159228 for more details.
377fn maybe_evaluate_root_goal_for_proof_tree_with_higher_recursion_limit<D, I>(
378    delegate: &D,
379    goal: Goal<I, I::Predicate>,
380    span: I::Span,
381    initial_result: &mut (
382        Result<NestedNormalizationGoals<I>, NoSolution>,
383        inspect::GoalEvaluation<I>,
384    ),
385) where
386    D: SolverDelegate<Interner = I>,
387    I: Interner,
388{
389    if !delegate.enable_next_solver_overflow_fcw() {
390        return;
391    }
392
393    let goal_evaluation = &initial_result.1;
394    match goal_evaluation.result {
395        Err(_) => return,
396        Ok(response) if !response.value.certainty.is_overflow() => return,
397        Ok(_) => {}
398    }
399
400    let rerun_result = delegate.commit_if_ok(|| {
401        let (new_result, new_goal_evaluation) = evaluate_root_goal_for_proof_tree(
402            delegate,
403            goal,
404            span,
405            delegate.cx().recursion_limit() * 2,
406        );
407
408        if new_goal_evaluation.result.is_ok_and(|response| response.value.certainty.is_overflow()) {
409            Err(())
410        } else {
411            Ok((new_result, new_goal_evaluation))
412        }
413    });
414    if let Ok(rerun_result) = rerun_result {
415        let predicate: I::Predicate = goal_evaluation.uncanonicalized_goal.predicate;
416        delegate.emit_next_solver_overflow_fcw(goal.with(delegate.cx(), predicate), span);
417        *initial_result = rerun_result;
418    }
419}
420
421impl<'a, D, I> EvalCtxt<'a, D>
422where
423    D: SolverDelegate<Interner = I>,
424    I: Interner,
425{
426    pub(super) fn typing_mode(&self) -> TypingMode<I> {
427        self.delegate.typing_mode_raw()
428    }
429
430    /// Computes the `PathKind` for the step from the current goal to the
431    /// nested goal required due to `source`.
432    ///
433    /// See #136824 for a more detailed reasoning for this behavior. We
434    /// consider cycles to be coinductive if they 'step into' a where-clause
435    /// of a coinductive trait. We will likely extend this function in the future
436    /// and will need to clearly document it in the rustc-dev-guide before
437    /// stabilization.
438    pub(super) fn step_kind_for_source(&self, source: GoalSource) -> PathKind {
439        match source {
440            // We treat these goals as unknown for now. It is likely that most miscellaneous
441            // nested goals will be converted to an inductive variant in the future.
442            //
443            // Having unknown cycles is always the safer option, as changing that to either
444            // succeed or hard error is backwards compatible. If we incorrectly treat a cycle
445            // as inductive even though it should not be, it may be unsound during coherence and
446            // fixing it may cause inference breakage or introduce ambiguity.
447            GoalSource::Misc => PathKind::Unknown,
448            GoalSource::NormalizeGoal(path_kind) => path_kind,
449            GoalSource::ImplWhereBound => match self.current_goal_kind {
450                // We currently only consider a cycle coinductive if it steps
451                // into a where-clause of a coinductive trait.
452                CurrentGoalKind::CoinductiveTrait => PathKind::Coinductive,
453                // We probably want to make all traits coinductive in the future,
454                // so we treat cycles involving where-clauses of not-yet coinductive
455                // traits as ambiguous for now.
456                CurrentGoalKind::Misc | CurrentGoalKind::ProjectionComputeAssocTermCandidate => {
457                    PathKind::Unknown
458                }
459            },
460            // Relating types is always unproductive. If we were to map proof trees to
461            // corecursive functions as explained in #136824, relating types never
462            // introduces a constructor which could cause the recursion to be guarded.
463            //
464            // FIXME(-Znext-solver=coinductive): For now we treat all inductive cycles as
465            // `Unknown`. See the comment in `fn initial_provisional_result`.
466            GoalSource::TypeRelating => PathKind::Unknown,
467            // These goal sources are likely unproductive and can be changed to
468            // `PathKind::Inductive`. Keeping them as unknown until we're confident
469            // about this and have an example where it is necessary.
470            GoalSource::AliasBoundConstCondition | GoalSource::AliasWellFormed => PathKind::Unknown,
471        }
472    }
473
474    /// Creates a root evaluation context and search graph. This should only be
475    /// used from outside of any evaluation, and other methods should be preferred
476    /// over using this manually (such as [`SolverDelegateEvalExt::evaluate_root_goal`]).
477    pub(super) fn enter_root<R>(
478        delegate: &D,
479        root_depth: usize,
480        origin_span: I::Span,
481        f: impl FnOnce(&mut EvalCtxt<'_, D>) -> R,
482    ) -> R {
483        let mut search_graph = SearchGraph::new(root_depth);
484
485        let mut ecx = EvalCtxt {
486            delegate,
487            search_graph: &mut search_graph,
488            nested_goals: Default::default(),
489            inspect: inspect::EvaluationStepBuilder::new_noop(),
490
491            // Only relevant when canonicalizing the response,
492            // which we don't do within this evaluation context.
493            max_input_universe: ty::UniverseIndex::ROOT,
494            initial_opaque_types_storage_num_entries: Default::default(),
495            var_kinds: Default::default(),
496            var_values: CanonicalVarValues::dummy(),
497            current_goal_kind: CurrentGoalKind::Misc,
498            origin_span,
499            tainted: Ok(()),
500            opaque_accesses: AccessedOpaques::default(),
501        };
502        let result = f(&mut ecx);
503        if !ecx.nested_goals.is_empty() {
    {
        ::core::panicking::panic_fmt(format_args!("root `EvalCtxt` should not have any goals added to it"));
    }
};assert!(
504            ecx.nested_goals.is_empty(),
505            "root `EvalCtxt` should not have any goals added to it"
506        );
507        if !!ecx.opaque_accesses.might_rerun() {
    ::core::panicking::panic("assertion failed: !ecx.opaque_accesses.might_rerun()")
};assert!(!ecx.opaque_accesses.might_rerun());
508        if !search_graph.is_empty() {
    ::core::panicking::panic("assertion failed: search_graph.is_empty()")
};assert!(search_graph.is_empty());
509        result
510    }
511
512    /// Creates a nested evaluation context that shares the same search graph as the
513    /// one passed in. This is suitable for evaluation, granted that the search graph
514    /// has had the nested goal recorded on its stack. This method only be used by
515    /// `search_graph::Delegate::compute_goal`.
516    ///
517    /// This function takes care of setting up the inference context, setting the anchor,
518    /// and registering opaques from the canonicalized input.
519    pub(super) fn enter_canonical<T>(
520        cx: I,
521        search_graph: &'a mut SearchGraph<D>,
522        canonical_input: I::CanonicalInput,
523        proof_tree_builder: &mut inspect::ProofTreeBuilder<D>,
524        f: impl FnOnce(
525            &mut EvalCtxt<'_, D>,
526            Goal<I, I::Predicate>,
527        ) -> Result<T, NoSolutionOrRerunNonErased>,
528    ) -> (Result<T, NoSolution>, AccessedOpaques<I>) {
529        let (ref delegate, input, var_values) = D::build_with_canonical(cx, &canonical_input);
530        for (key, ty) in input.predefined_opaques_in_body.iter() {
531            let prev = delegate.register_hidden_type_in_storage(key, ty, I::Span::dummy());
532            // It may be possible that two entries in the opaque type storage end up
533            // with the same key after resolving contained inference variables.
534            //
535            // We could put them in the duplicate list but don't have to. The opaques we
536            // encounter here are already tracked in the caller, so there's no need to
537            // also store them here. We'd take them out when computing the query response
538            // and then discard them, as they're already present in the input.
539            //
540            // Ideally we'd drop duplicate opaque type definitions when computing
541            // the canonical input. This is more annoying to implement and may cause a
542            // perf regression, so we do it inside of the query for now.
543            if let Some(prev) = prev {
544                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:544",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(544u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("key")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("key");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("ty")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("ty");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("prev")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("prev");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("ignore duplicate in `opaque_types_storage`")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&key)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&prev)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?key, ?ty, ?prev, "ignore duplicate in `opaque_types_storage`");
545            }
546        }
547
548        let initial_opaque_types_storage_num_entries = delegate.opaque_types_storage_num_entries();
549        if truecfg!(debug_assertions) && delegate.typing_mode_raw().is_erased_not_coherence() {
550            if !delegate.clone_opaque_types_lookup_table().is_empty() {
    ::core::panicking::panic("assertion failed: delegate.clone_opaque_types_lookup_table().is_empty()")
};assert!(delegate.clone_opaque_types_lookup_table().is_empty());
551        }
552
553        let mut ecx = EvalCtxt {
554            delegate,
555            var_kinds: canonical_input.canonical.var_kinds,
556            var_values,
557            current_goal_kind: CurrentGoalKind::from_query_input(cx, input),
558            max_input_universe: canonical_input.canonical.max_universe,
559            initial_opaque_types_storage_num_entries,
560            search_graph,
561            nested_goals: Default::default(),
562            origin_span: I::Span::dummy(),
563            tainted: Ok(()),
564            inspect: proof_tree_builder.new_evaluation_step(var_values),
565            opaque_accesses: AccessedOpaques::default(),
566        };
567
568        let result = f(&mut ecx, input.goal);
569        ecx.inspect.probe_final_state(ecx.delegate, ecx.max_input_universe);
570        proof_tree_builder.finish_evaluation_step(ecx.inspect);
571
572        if canonical_input.typing_mode.0.is_erased_not_coherence() {
573            if true {
    if !delegate.clone_opaque_types_lookup_table().is_empty() {
        ::core::panicking::panic("assertion failed: delegate.clone_opaque_types_lookup_table().is_empty()")
    };
};debug_assert!(delegate.clone_opaque_types_lookup_table().is_empty());
574        }
575
576        // When creating a query response we clone the opaque type constraints
577        // instead of taking them. This would cause an ICE here, since we have
578        // assertions against dropping an `InferCtxt` without taking opaques.
579        // FIXME: Once we remove support for the old impl we can remove this.
580        // FIXME: Could we make `build_with_canonical` into `enter_with_canonical` and call this at the end?
581        delegate.reset_opaque_types();
582
583        let opaque_accesses = ecx.opaque_accesses;
584        (
585            match result {
586                Ok(i) => Ok(i),
587                Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) => Err(NoSolution),
588                Err(NoSolutionOrRerunNonErased::RerunNonErased(_)) => {
589                    // Check that the opaque_accesses state mirrors the result we got.
590                    if !opaque_accesses.should_bail().is_err() {
    ::core::panicking::panic("assertion failed: opaque_accesses.should_bail().is_err()")
};assert!(opaque_accesses.should_bail().is_err());
591                    Err(NoSolution)
592                }
593            },
594            opaque_accesses,
595        )
596    }
597
598    pub(super) fn ignore_candidate_head_usages(&mut self, usages: CandidateHeadUsages) {
599        self.search_graph.ignore_candidate_head_usages(usages);
600    }
601
602    /// Recursively evaluates `goal`, returning whether any inference vars have
603    /// been constrained and the certainty of the result.
604    fn evaluate_goal(
605        &mut self,
606        source: GoalSource,
607        goal: Goal<I, I::Predicate>,
608        stalled_on: Option<GoalStalledOn<I>>,
609    ) -> Result<GoalEvaluation<I>, NoSolutionOrRerunNonErased> {
610        if let RerunStalled::WontMakeProgress(stalled_maybe_info) =
611            rerunning_stalled_goal_may_make_progress(self.delegate, stalled_on.as_ref())
612        {
613            return Ok(GoalEvaluation {
614                goal,
615                certainty: Certainty::Maybe(stalled_maybe_info),
616                has_changed: HasChanged::No,
617                stalled_on,
618            });
619        }
620
621        // No need to try the fast path if stalled_on is `None`, since we already try the fast path
622        // immediately when adding new goals. If we didn't check `stalled_on` here we'd be trying
623        // the fast path twice for some goals.
624        if stalled_on.is_some()
625            && let Some(res) = compute_goal_fast_path_cold(self.delegate, goal, self.origin_span)
626        {
627            return Ok(res);
628        }
629
630        self.evaluate_goal_no_fast_paths(source, goal)
631    }
632
633    // Outlining and `#[cold]` matter here because fast paths make it less likely to get here.
634    #[cold]
635    #[inline(never)]
636    fn evaluate_goal_no_fast_paths(
637        &mut self,
638        source: GoalSource,
639        goal: Goal<I, I::Predicate>,
640    ) -> Result<GoalEvaluation<I>, NoSolutionOrRerunNonErased> {
641        let (normalization_nested_goals, goal_evaluation) = self.evaluate_goal_raw(source, goal)?;
642        if !normalization_nested_goals.is_empty() {
    ::core::panicking::panic("assertion failed: normalization_nested_goals.is_empty()")
};assert!(normalization_nested_goals.is_empty());
643        Ok(goal_evaluation)
644    }
645
646    fn evaluate_in_search_graph(
647        &mut self,
648        canonical_goal: I::CanonicalInput,
649        step_kind: PathKind,
650    ) -> (Result<CanonicalResponse<I>, NoSolution>, AccessedOpaques<I>) {
651        let increase_depth_for_nested =
652            match canonical_goal.canonical.value.goal.predicate.kind().skip_binder() {
653                // We don't lower the available depth for the `NormalizesTo` goal, as evaluating
654                // it is an extra step only exists in the new solver that behaves like a function
655                // call rather than an independent nested goal evaluation. So, decreasing the
656                // available depth may end up regressions which hit the recursion limits for crates
657                // compiled well with the old solver.
658                ty::PredicateKind::NormalizesTo(_) => LowerAvailableDepth::No,
659                // We also don't lower depth for witness and rigid opaque when proving auto traits.
660                // This is to mitigate the overflow FCW warnings in deeply nested async calls.
661                // See #159228.
662                //
663                // We're eventually going to remove the witness type so it's okay to ignore the
664                // depth.
665                // For rigid opaques, revealing hidden types can be viewed as normalization so it's
666                // consistent with the `NormalizesTo` reasoning above.
667                ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
668                    if self.cx().trait_is_auto(pred.trait_ref.def_id) {
669                        match pred.self_ty().kind() {
670                            ty::CoroutineWitness(..) => LowerAvailableDepth::No,
671                            ty::Alias(
672                                ty::IsRigid::Yes,
673                                ty::AliasTy { kind: ty::Opaque { def_id, .. }, .. },
674                            ) => {
675                                // We only want to skip lowering depth when the proving is done via
676                                // auto trait leakage. If the goal can be proved via item bounds,
677                                // we should lower depth faithfully.
678                                //
679                                // FIXME: We can have param env candidates via TAIT or RTN.
680                                // Ideally we'd instead lower the depth for the nested goal instead.
681                                // Implementing this is a bit harder.
682                                if self
683                                    .cx()
684                                    .item_self_bounds(def_id.into())
685                                    .skip_binder()
686                                    .into_iter()
687                                    .any(|bound| {
688                                        bound
689                                            .as_trait_clause()
690                                            .is_some_and(|b| b.def_id() == pred.def_id())
691                                    })
692                                {
693                                    LowerAvailableDepth::Yes
694                                } else {
695                                    LowerAvailableDepth::No
696                                }
697                            }
698                            ty::Bool
699                            | ty::Char
700                            | ty::Int(..)
701                            | ty::Uint(..)
702                            | ty::Float(..)
703                            | ty::Str
704                            | ty::Pat(..)
705                            | ty::FnPtr(..)
706                            | ty::Array(..)
707                            | ty::Slice(..)
708                            | ty::RawPtr(..)
709                            | ty::Never
710                            | ty::Tuple(..)
711                            | ty::UnsafeBinder(_)
712                            | ty::Param(..)
713                            | ty::Placeholder(..)
714                            | ty::Bound(..)
715                            | ty::Infer(..)
716                            | ty::Alias(_, _)
717                            | ty::Ref(_, _, _)
718                            | ty::Adt(_, _)
719                            | ty::Foreign(_)
720                            | ty::Dynamic(..)
721                            | ty::Error(_)
722                            | ty::FnDef(..)
723                            | ty::Closure(..)
724                            | ty::CoroutineClosure(..)
725                            | ty::Coroutine(..) => LowerAvailableDepth::Yes,
726                        }
727                    } else {
728                        LowerAvailableDepth::Yes
729                    }
730                }
731                ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(_))
732                | ty::PredicateKind::Clause(ty::ClauseKind::Projection(_))
733                | ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(_))
734                | ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(_))
735                | ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(_, _))
736                | ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_))
737                | ty::PredicateKind::Subtype(_)
738                | ty::PredicateKind::Coerce(_)
739                | ty::PredicateKind::DynCompatible(_)
740                | ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_))
741                | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(_))
742                | ty::PredicateKind::ConstEquate(_, _)
743                | ty::PredicateKind::Ambiguous => LowerAvailableDepth::Yes,
744            };
745        self.search_graph.evaluate_goal(
746            self.cx(),
747            canonical_goal,
748            step_kind,
749            increase_depth_for_nested,
750            &mut inspect::ProofTreeBuilder::new_noop(),
751        )
752    }
753
754    /// Recursively evaluates `goal`, returning the nested goals in case
755    /// the nested goal is a `NormalizesTo` goal.
756    ///
757    /// As all other goal kinds do not return any nested goals and
758    /// `NormalizesTo` is only used by `Projection`, all other callsites
759    /// should use [`EvalCtxt::evaluate_goal`] which discards that empty
760    /// storage.
761    pub(super) fn evaluate_goal_raw(
762        &mut self,
763        source: GoalSource,
764        goal: Goal<I, I::Predicate>,
765    ) -> Result<(NestedNormalizationGoals<I>, GoalEvaluation<I>), NoSolutionOrRerunNonErased> {
766        // We only care about one entry per `OpaqueTypeKey` here,
767        // so we only canonicalize the lookup table and ignore
768        // duplicate entries.
769        let opaque_types = self.delegate.clone_opaque_types_lookup_table();
770
771        let (goal, opaque_types) =
772            self.delegate.deeply_resolve_via_unification_table((goal, opaque_types));
773        let typing_mode = self.typing_mode();
774        let step_kind = self.step_kind_for_source(source);
775
776        let tracing_span = {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("evaluate_goal_raw in typing mode",
                        "rustc_next_trait_solver::solve::eval_ctxt", Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(776u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::SPAN)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let mut interest = ::tracing::subscriber::Interest::never();
    if Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
                    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(&format_args!("{0:?} opaques={1:?}",
                                                        typing_mode, opaque_types) as
                                                &dyn ::tracing::field::Value))])
                })
    } else {
        let span =
            ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
        {};
        span
    }
}tracing::span!(
777            Level::DEBUG,
778            "evaluate_goal_raw in typing mode",
779            "{:?} opaques={:?}",
780            typing_mode,
781            opaque_types
782        )
783        .entered();
784
785        let (result, orig_values, canonical_goal, succeeded_in_erased) = 'retry_canonicalize: {
786            let skip_erased_attempt = match typing_mode {
787                TypingMode::Reflection | TypingMode::Coherence => true,
788                TypingMode::Typeck { .. }
789                | TypingMode::PostTypeckUntilBorrowck { .. }
790                | TypingMode::PostBorrowck { .. }
791                | TypingMode::Codegen
792                | TypingMode::PostAnalysis
793                | TypingMode::ErasedNotCoherence(_) => {
794                    let mut skip = false;
795                    if opaque_types.iter().any(|(_, ty)| ty.is_ty_var())
796                        && let PredicateKind::Clause(ClauseKind::Trait(..)) =
797                            goal.predicate.kind().skip_binder()
798                    {
799                        skip = true;
800                    }
801
802                    if let PredicateKind::Clause(ClauseKind::Trait(tr)) =
803                        goal.predicate.kind().skip_binder()
804                        && tr.self_ty().has_coroutines()
805                        && self.cx().trait_is_auto(tr.trait_ref.def_id)
806                    {
807                        // FIXME(#155443): this doesn't make a difference now, but with eager normalization
808                        // it likely will.
809                        // skip_erased_attempt = true;
810                    }
811
812                    skip
813                }
814            };
815
816            if skip_erased_attempt {
817                if typing_mode.is_erased_not_coherence() {
818                    match self.opaque_accesses.rerun_always(RerunReason::SkipErasedAttempt)? {}
819                } else {
820                    {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:820",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(820u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("running in original typing mode")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("running in original typing mode");
821                }
822            } else {
823                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:823",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(823u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("trying without opaques: {0:?}",
                                                    goal) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("trying without opaques: {goal:?}");
824
825                let (orig_values, canonical_goal) = canonicalize_goal(
826                    self.delegate,
827                    goal,
828                    &[],
829                    TypingMode::ErasedNotCoherence(MayBeErased),
830                );
831
832                let (canonical_result, accessed_opaques) =
833                    self.evaluate_in_search_graph(canonical_goal, step_kind);
834
835                let should_rerun = should_rerun_after_erased_canonicalization(
836                    accessed_opaques,
837                    self.typing_mode(),
838                    &opaque_types,
839                );
840                match should_rerun {
841                    RerunDecision::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/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:841",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(841u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("rerunning in original typing mode")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
}debug!("rerunning in original typing mode"),
842                    RerunDecision::No => {
843                        break 'retry_canonicalize (
844                            canonical_result,
845                            orig_values,
846                            canonical_goal,
847                            SucceededInErased::Yes { accessed_opaques },
848                        );
849                    }
850                    RerunDecision::EagerlyPropagateToParent => {
851                        self.opaque_accesses.update(accessed_opaques)?;
852                        break 'retry_canonicalize (
853                            canonical_result,
854                            orig_values,
855                            canonical_goal,
856                            // If we're propagating up, we should never retry the goal.
857                            // That means `No` is fine to return, it doesn't really matter.
858                            SucceededInErased::No,
859                        );
860                    }
861                }
862            }
863
864            let (orig_values, canonical_goal) =
865                canonicalize_goal(self.delegate, goal, &opaque_types, typing_mode);
866
867            let (canonical_result, accessed_opaques) =
868                self.evaluate_in_search_graph(canonical_goal, step_kind);
869            if !!accessed_opaques.might_rerun() {
    {
        ::core::panicking::panic_fmt(format_args!("we run without TypingMode::ErasedNotCoherence, so opaques are available, and we don\'t retry if the outer typing mode is ErasedNotCoherence: {0:?} after {1:?}",
                accessed_opaques, goal));
    }
};assert!(
870                !accessed_opaques.might_rerun(),
871                "we run without TypingMode::ErasedNotCoherence, so opaques are available, and we don't retry if the outer typing mode is ErasedNotCoherence: {accessed_opaques:?} after {goal:?}"
872            );
873
874            (canonical_result, orig_values, canonical_goal, SucceededInErased::No)
875        };
876
877        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:877",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(877u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("result")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("result");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&result)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?result);
878        let response = match result {
879            Ok(response) => {
880                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:880",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(880u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("success")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("success");
881                response
882            }
883            Err(NoSolution) => {
884                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:884",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(884u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("normal failure")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("normal failure");
885                return Err(NoSolution.into());
886            }
887        };
888
889        drop(tracing_span);
890
891        let has_changed =
892            if !has_only_region_constraints(response) { HasChanged::Yes } else { HasChanged::No };
893
894        let (normalization_nested_goals, certainty) = instantiate_and_apply_query_response(
895            self.delegate,
896            &orig_values,
897            response,
898            self.origin_span,
899        );
900
901        // FIXME: We previously had an assert here that checked that recomputing
902        // a goal after applying its constraints did not change its response.
903        //
904        // This assert was removed as it did not hold for goals constraining
905        // an inference variable to a recursive alias, e.g. in
906        // tests/ui/traits/next-solver/overflow/recursive-self-normalization.rs.
907        //
908        // Once we have decided on how to handle trait-system-refactor-initiative#75,
909        // we should re-add an assert here.
910
911        let stalled_on = match certainty {
912            Certainty::Yes => None,
913            Certainty::Maybe(maybe_info) => match has_changed {
914                // FIXME: We could recompute a *new* set of stalled variables by walking
915                // through the orig values, resolving, and computing the root vars of anything
916                // that is not resolved. Only when *these* have changed is it meaningful
917                // to recompute this goal.
918                HasChanged::Yes => None,
919                HasChanged::No => Some(self.build_stalled_on(
920                    canonical_goal,
921                    maybe_info,
922                    orig_values,
923                    succeeded_in_erased,
924                )),
925            },
926        };
927
928        Ok((
929            normalization_nested_goals,
930            GoalEvaluation { goal, certainty, has_changed, stalled_on },
931        ))
932    }
933
934    fn build_stalled_on(
935        &self,
936        canonical_goal: I::CanonicalInput,
937        maybe_info: MaybeInfo,
938        stalled_vars: ThinVec<I::GenericArg>,
939        previously_succeeded_in_erased: SucceededInErased<I>,
940    ) -> GoalStalledOn<I> {
941        // Remove the canonicalized universal vars, since we only care about stalled existentials.
942        let mut sub_roots = ThinVec::new();
943        let stalled_vars = stalled_vars
944            .into_iter()
945            .filter_map(|arg| match arg.kind() {
946                // Lifetimes can never stall goals.
947                ty::GenericArgKind::Lifetime(_) => None,
948                ty::GenericArgKind::Type(ty) => match ty.kind() {
949                    ty::Infer(ty::TyVar(vid)) => {
950                        sub_roots.push(self.delegate.sub_unification_table_root_var(vid));
951                        Some(TyOrConstInferVar::Ty(vid))
952                    }
953                    ty::Infer(ty::IntVar(vid)) => Some(TyOrConstInferVar::TyInt(vid)),
954                    ty::Infer(ty::FloatVar(vid)) => Some(TyOrConstInferVar::TyFloat(vid)),
955                    ty::Param(_) | ty::Placeholder(_) => None,
956                    _ => {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("unexpected orig_value: {0:?}", ty)));
}unreachable!("unexpected orig_value: {ty:?}"),
957                },
958                ty::GenericArgKind::Const(ct) => match ct.kind() {
959                    ty::ConstKind::Infer(ty::InferConst::Var(v)) => {
960                        Some(TyOrConstInferVar::Const(v))
961                    }
962                    ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(_) => None,
963                    _ => {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("unexpected orig_value: {0:?}", ct)));
}unreachable!("unexpected orig_value: {ct:?}"),
964                },
965            })
966            .collect();
967
968        GoalStalledOn {
969            stalled_vars,
970            sub_roots,
971            stalled_maybe_info: maybe_info,
972            opaques: GoalStalledOnOpaques::Yes {
973                num_opaques_in_storage: canonical_goal
974                    .canonical
975                    .value
976                    .predefined_opaques_in_body
977                    .len(),
978                previously_succeeded_in_erased,
979            },
980        }
981    }
982
983    pub(super) fn compute_goal(
984        &mut self,
985        goal: Goal<I, I::Predicate>,
986    ) -> QueryResultOrRerunNonErased<I> {
987        let Goal { param_env, predicate } = goal;
988        let kind = predicate.kind();
989        self.enter_forall_with_assumptions(kind, param_env, |ecx, kind| {
990            Ok(match kind {
991                ty::PredicateKind::Clause(ty::ClauseKind::Trait(predicate)) => {
992                    ecx.compute_trait_goal(Goal { param_env, predicate }).map(|(r, _via)| r)?
993                }
994                ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(predicate)) => {
995                    ecx.compute_host_effect_goal(Goal { param_env, predicate })?
996                }
997                ty::PredicateKind::Clause(ty::ClauseKind::Projection(predicate)) => {
998                    ecx.compute_projection_goal(Goal { param_env, predicate })?
999                }
1000                ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(predicate)) => {
1001                    ecx.compute_type_outlives_goal(Goal { param_env, predicate })?
1002                }
1003                ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(predicate)) => {
1004                    ecx.compute_region_outlives_goal(Goal { param_env, predicate })?
1005                }
1006                ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
1007                    ecx.compute_const_arg_has_type_goal(Goal { param_env, predicate: (ct, ty) })?
1008                }
1009                ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
1010                    ecx.compute_unstable_feature_goal(param_env, symbol)?
1011                }
1012                ty::PredicateKind::Subtype(predicate) => {
1013                    ecx.compute_subtype_goal(Goal { param_env, predicate })?
1014                }
1015                ty::PredicateKind::Coerce(predicate) => {
1016                    ecx.compute_coerce_goal(Goal { param_env, predicate })?
1017                }
1018                ty::PredicateKind::DynCompatible(trait_def_id) => {
1019                    ecx.compute_dyn_compatible_goal(trait_def_id)?
1020                }
1021                ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
1022                    ecx.compute_well_formed_goal(Goal { param_env, predicate: term })?
1023                }
1024                ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(ct)) => {
1025                    ecx.compute_const_evaluatable_goal(Goal { param_env, predicate: ct })?
1026                }
1027                ty::PredicateKind::ConstEquate(_, _) => {
1028                    {
    ::core::panicking::panic_fmt(format_args!("ConstEquate should not be emitted when `-Znext-solver` is active"));
}panic!("ConstEquate should not be emitted when `-Znext-solver` is active")
1029                }
1030                ty::PredicateKind::NormalizesTo(predicate) => {
1031                    ecx.compute_normalizes_to_goal(Goal { param_env, predicate })?
1032                }
1033                ty::PredicateKind::Ambiguous => {
1034                    ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)?
1035                }
1036            })
1037        })
1038    }
1039
1040    // Recursively evaluates all the goals added to this `EvalCtxt` to completion, returning
1041    // the certainty of all the goals.
1042    {}
#[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("try_evaluate_added_goals",
                                    "rustc_next_trait_solver::solve::eval_ctxt",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1042u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::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,
                        &{ meta.fields().value_set_all(&[]) })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    Result<Certainty, NoSolutionOrRerunNonErased> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            for _ in 0..FIXPOINT_STEP_LIMIT {
                match self.evaluate_added_goals_step().map_err_to_rerun()? {
                    Ok(None) => {}
                    Ok(Some(cert)) => return Ok(cert),
                    Err(NoSolution) => {
                        self.tainted = Err(NoSolution);
                        return Err(NoSolution.into());
                    }
                }
            }
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1057",
                                    "rustc_next_trait_solver::solve::eval_ctxt",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1057u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                    ::tracing_core::field::FieldSet::new(&["message"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("try_evaluate_added_goals: encountered overflow")
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            Ok(Certainty::overflow(false))
        }
    }
}#[instrument(level = "trace", skip(self))]
1043    pub(super) fn try_evaluate_added_goals(
1044        &mut self,
1045    ) -> Result<Certainty, NoSolutionOrRerunNonErased> {
1046        for _ in 0..FIXPOINT_STEP_LIMIT {
1047            match self.evaluate_added_goals_step().map_err_to_rerun()? {
1048                Ok(None) => {}
1049                Ok(Some(cert)) => return Ok(cert),
1050                Err(NoSolution) => {
1051                    self.tainted = Err(NoSolution);
1052                    return Err(NoSolution.into());
1053                }
1054            }
1055        }
1056
1057        debug!("try_evaluate_added_goals: encountered overflow");
1058        Ok(Certainty::overflow(false))
1059    }
1060
1061    /// Iterate over all added goals: returning `Ok(Some(_))` in case we can stop rerunning.
1062    ///
1063    /// Goals for the next step get directly added to the nested goals of the `EvalCtxt`.
1064    fn evaluate_added_goals_step(
1065        &mut self,
1066    ) -> Result<Option<Certainty>, NoSolutionOrRerunNonErased> {
1067        // If this loop did not result in any progress, what's our final certainty.
1068        let mut unchanged_certainty = Some(Certainty::Yes);
1069        // This mem::take seems super inefficient, given that we push to it again later.
1070        // Despite that, replacing it has no effect on performance. We tried.
1071        // (https://github.com/rust-lang/rust/pull/158126)
1072        for (source, goal, stalled_on) in mem::take(&mut self.nested_goals) {
1073            // We never handle `NormalizesTo` as a nested goal
1074            if true {
    if !!#[allow(non_exhaustive_omitted_patterns)] match goal.predicate.kind().skip_binder()
                    {
                    PredicateKind::NormalizesTo(_) => true,
                    _ => false,
                } {
        ::core::panicking::panic("assertion failed: !matches!(goal.predicate.kind().skip_binder(), PredicateKind::NormalizesTo(_))")
    };
};debug_assert!(!matches!(
1075                goal.predicate.kind().skip_binder(),
1076                PredicateKind::NormalizesTo(_)
1077            ));
1078
1079            let GoalEvaluation { goal, certainty, has_changed, stalled_on } =
1080                self.evaluate_goal(source, goal, stalled_on)?;
1081            if has_changed == HasChanged::Yes {
1082                unchanged_certainty = None;
1083            }
1084
1085            match certainty {
1086                Certainty::Yes => {}
1087                Certainty::Maybe { .. } => {
1088                    self.nested_goals.push((source, goal, stalled_on));
1089                    unchanged_certainty = unchanged_certainty.map(|c| c.and(certainty));
1090                }
1091            }
1092        }
1093
1094        Ok(unchanged_certainty)
1095    }
1096
1097    /// Record impl args in the proof tree for later access by `InspectCandidate`.
1098    pub(crate) fn record_impl_args(&mut self, impl_args: I::GenericArgs) {
1099        self.inspect.record_impl_args(self.delegate, self.max_input_universe, impl_args)
1100    }
1101
1102    pub(super) fn cx(&self) -> I {
1103        self.delegate.cx()
1104    }
1105
1106    {}
#[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("add_goal",
                                    "rustc_next_trait_solver::solve::eval_ctxt",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1106u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("source")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("source");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        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::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(&source)
                                                            as &dyn ::tracing::field::Value)),
                                                (::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:
                    Result<(), NoSolutionOrRerunNonErased> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            goal.predicate =
                self.normalize(GoalSource::NormalizeGoal(self.step_kind_for_source(source)),
                        goal.param_env, ty::Unnormalized::new_wip(goal.predicate))?;
            self.inspect.add_goal(self.delegate, self.max_input_universe,
                source, goal);
            if let Some(GoalEvaluation {
                    goal, certainty, has_changed: _, stalled_on }) =
                    compute_goal_fast_path(self.delegate, goal,
                        self.origin_span) {
                match certainty {
                    Certainty::Yes => {}
                    Certainty::Maybe(_) => {
                        self.nested_goals.push((source, goal, stalled_on));
                    }
                }
            } else { self.nested_goals.push((source, goal, None)); }
            Ok(())
        }
    }
}#[instrument(level = "debug", skip(self))]
1107    pub(super) fn add_goal(
1108        &mut self,
1109        source: GoalSource,
1110        mut goal: Goal<I, I::Predicate>,
1111    ) -> Result<(), NoSolutionOrRerunNonErased> {
1112        goal.predicate = self.normalize(
1113            GoalSource::NormalizeGoal(self.step_kind_for_source(source)),
1114            goal.param_env,
1115            ty::Unnormalized::new_wip(goal.predicate),
1116        )?;
1117        self.inspect.add_goal(self.delegate, self.max_input_universe, source, goal);
1118
1119        if let Some(GoalEvaluation { goal, certainty, has_changed: _, stalled_on }) =
1120            compute_goal_fast_path(self.delegate, goal, self.origin_span)
1121        {
1122            match certainty {
1123                // We're done here
1124                Certainty::Yes => {}
1125                Certainty::Maybe(_) => {
1126                    self.nested_goals.push((source, goal, stalled_on));
1127                }
1128            }
1129        } else {
1130            self.nested_goals.push((source, goal, None));
1131        }
1132        Ok(())
1133    }
1134
1135    {}
#[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("add_goals",
                                    "rustc_next_trait_solver::solve::eval_ctxt",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1135u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("source")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("source");
                                                        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(&source)
                                                            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:
                    Result<(), NoSolutionOrRerunNonErased> = loop {};
            return __tracing_attr_fake_return;
        }
        { for goal in goals { self.add_goal(source, goal)?; } Ok(()) }
    }
}#[instrument(level = "trace", skip(self, goals))]
1136    pub(super) fn add_goals(
1137        &mut self,
1138        source: GoalSource,
1139        goals: impl IntoIterator<Item = Goal<I, I::Predicate>>,
1140    ) -> Result<(), NoSolutionOrRerunNonErased> {
1141        for goal in goals {
1142            self.add_goal(source, goal)?;
1143        }
1144        Ok(())
1145    }
1146
1147    pub(super) fn next_region_var(&mut self) -> Region<I> {
1148        let region = self.delegate.next_region_infer();
1149        self.inspect.add_var_value(region);
1150        region
1151    }
1152
1153    pub(super) fn next_ty_infer(&mut self) -> I::Ty {
1154        let ty = self.delegate.next_ty_infer();
1155        self.inspect.add_var_value(ty);
1156        ty
1157    }
1158
1159    pub(super) fn next_const_infer(&mut self) -> Const<I> {
1160        let ct = self.delegate.next_const_infer();
1161        self.inspect.add_var_value(ct);
1162        ct
1163    }
1164
1165    /// Returns a ty infer or a const infer depending on whether `kind` is a `Ty` or `Const`.
1166    /// If `kind` is an integer inference variable this will still return a ty infer var.
1167    pub(super) fn next_term_infer_of_alias_kind(
1168        &mut self,
1169        alias_term: ty::AliasTerm<I>,
1170    ) -> I::Term {
1171        match alias_term.kind {
1172            ty::AliasTermKind::ProjectionTy { .. }
1173            | ty::AliasTermKind::InherentTy { .. }
1174            | ty::AliasTermKind::OpaqueTy { .. }
1175            | ty::AliasTermKind::FreeTy { .. } => self.next_ty_infer().into(),
1176            ty::AliasTermKind::FreeConst { .. }
1177            | ty::AliasTermKind::InherentConstSelf { .. }
1178            | ty::AliasTermKind::InherentConstImpl { .. }
1179            | ty::AliasTermKind::AnonConst { .. }
1180            | ty::AliasTermKind::ProjectionConst { .. } => self.next_const_infer().into(),
1181        }
1182    }
1183
1184    /// Is the projection predicate is of the form `exists<T> <Ty as Trait>::Assoc = T`.
1185    ///
1186    /// This is the case if the `term` does not occur in any other part of the predicate
1187    /// and is able to name all other placeholder and inference variables.
1188    {}
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("term_is_fully_unconstrained",
                                "rustc_next_trait_solver::solve::eval_ctxt",
                                ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1188u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                ::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: bool = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let universe_of_term =
                            match goal.predicate.term.kind() {
                                ty::TermKind::Ty(ty) => {
                                    if let ty::Infer(ty::TyVar(vid)) = ty.kind() {
                                        self.delegate.universe_of_ty(vid).unwrap()
                                    } else { return false; }
                                }
                                ty::TermKind::Const(ct) => {
                                    if let ty::ConstKind::Infer(ty::InferConst::Var(vid)) =
                                            ct.kind() {
                                        self.delegate.universe_of_const(vid).unwrap()
                                    } else { return false; }
                                }
                            };
                        struct ContainsTermOrNotNameable<'a,
                            D: SolverDelegate<Interner = I>, I: Interner> {
                            term: I::Term,
                            universe_of_term: ty::UniverseIndex,
                            delegate: &'a D,
                            cache: HashSet<I::Ty>,
                        }
                        impl<D: SolverDelegate<Interner = I>, I: Interner>
                            ContainsTermOrNotNameable<'_, D, I> {
                            fn check_nameable(&self, universe: ty::UniverseIndex)
                                -> ControlFlow<()> {
                                if self.universe_of_term.can_name(universe) {
                                    ControlFlow::Continue(())
                                } else { ControlFlow::Break(()) }
                            }
                        }
                        impl<D: SolverDelegate<Interner = I>, I: Interner>
                            TypeVisitor<I> for ContainsTermOrNotNameable<'_, D, I> {
                            type Result = ControlFlow<()>;
                            fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
                                if self.cache.contains(&t) {
                                    return ControlFlow::Continue(());
                                }
                                match t.kind() {
                                    ty::Infer(ty::TyVar(vid)) => {
                                        if let ty::TermKind::Ty(term) = self.term.kind() &&
                                                    let ty::Infer(ty::TyVar(term_vid)) = term.kind() &&
                                                self.delegate.root_ty_var(vid) ==
                                                    self.delegate.root_ty_var(term_vid) {
                                            return ControlFlow::Break(());
                                        }
                                        self.check_nameable(self.delegate.universe_of_ty(vid).unwrap())?;
                                    }
                                    ty::Placeholder(p) => self.check_nameable(p.universe())?,
                                    _ => {
                                        if t.has_non_region_infer() || t.has_placeholders() {
                                            t.super_visit_with(self)?
                                        }
                                    }
                                }
                                if !self.cache.insert(t) {
                                    ::core::panicking::panic("assertion failed: self.cache.insert(t)")
                                };
                                ControlFlow::Continue(())
                            }
                            fn visit_const(&mut self, c: Const<I>) -> Self::Result {
                                match c.kind() {
                                    ty::ConstKind::Infer(ty::InferConst::Var(vid)) => {
                                        if let ty::TermKind::Const(term) = self.term.kind() &&
                                                    let ty::ConstKind::Infer(ty::InferConst::Var(term_vid)) =
                                                        term.kind() &&
                                                self.delegate.root_const_var(vid) ==
                                                    self.delegate.root_const_var(term_vid) {
                                            return ControlFlow::Break(());
                                        }
                                        self.check_nameable(self.delegate.universe_of_const(vid).unwrap())
                                    }
                                    ty::ConstKind::Placeholder(p) =>
                                        self.check_nameable(p.universe()),
                                    _ => {
                                        if c.has_non_region_infer() || c.has_placeholders() {
                                            c.super_visit_with(self)
                                        } else { ControlFlow::Continue(()) }
                                    }
                                }
                            }
                            fn visit_predicate<P: PredicateProxy<I>>(&mut self, p: P)
                                -> Self::Result {
                                if p.has_non_region_infer() || p.has_placeholders() {
                                    p.super_visit_with(self)
                                } else { ControlFlow::Continue(()) }
                            }
                            fn visit_clauses(&mut self, c: I::Clauses) -> Self::Result {
                                if c.has_non_region_infer() || c.has_placeholders() {
                                    c.super_visit_with(self)
                                } else { ControlFlow::Continue(()) }
                            }
                        }
                        let mut visitor =
                            ContainsTermOrNotNameable {
                                delegate: self.delegate,
                                universe_of_term,
                                term: goal.predicate.term,
                                cache: Default::default(),
                            };
                        goal.predicate.alias.visit_with(&mut visitor).is_continue()
                            && goal.param_env.visit_with(&mut visitor).is_continue()
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1188",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1188u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::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)]
1189    pub(super) fn term_is_fully_unconstrained(&self, goal: Goal<I, ty::NormalizesTo<I>>) -> bool {
1190        let universe_of_term = match goal.predicate.term.kind() {
1191            ty::TermKind::Ty(ty) => {
1192                if let ty::Infer(ty::TyVar(vid)) = ty.kind() {
1193                    self.delegate.universe_of_ty(vid).unwrap()
1194                } else {
1195                    return false;
1196                }
1197            }
1198            ty::TermKind::Const(ct) => {
1199                if let ty::ConstKind::Infer(ty::InferConst::Var(vid)) = ct.kind() {
1200                    self.delegate.universe_of_const(vid).unwrap()
1201                } else {
1202                    return false;
1203                }
1204            }
1205        };
1206
1207        struct ContainsTermOrNotNameable<'a, D: SolverDelegate<Interner = I>, I: Interner> {
1208            term: I::Term,
1209            universe_of_term: ty::UniverseIndex,
1210            delegate: &'a D,
1211            cache: HashSet<I::Ty>,
1212        }
1213
1214        impl<D: SolverDelegate<Interner = I>, I: Interner> ContainsTermOrNotNameable<'_, D, I> {
1215            fn check_nameable(&self, universe: ty::UniverseIndex) -> ControlFlow<()> {
1216                if self.universe_of_term.can_name(universe) {
1217                    ControlFlow::Continue(())
1218                } else {
1219                    ControlFlow::Break(())
1220                }
1221            }
1222        }
1223
1224        impl<D: SolverDelegate<Interner = I>, I: Interner> TypeVisitor<I>
1225            for ContainsTermOrNotNameable<'_, D, I>
1226        {
1227            type Result = ControlFlow<()>;
1228            fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
1229                if self.cache.contains(&t) {
1230                    return ControlFlow::Continue(());
1231                }
1232
1233                match t.kind() {
1234                    ty::Infer(ty::TyVar(vid)) => {
1235                        if let ty::TermKind::Ty(term) = self.term.kind()
1236                            && let ty::Infer(ty::TyVar(term_vid)) = term.kind()
1237                            && self.delegate.root_ty_var(vid) == self.delegate.root_ty_var(term_vid)
1238                        {
1239                            return ControlFlow::Break(());
1240                        }
1241
1242                        self.check_nameable(self.delegate.universe_of_ty(vid).unwrap())?;
1243                    }
1244                    ty::Placeholder(p) => self.check_nameable(p.universe())?,
1245                    _ => {
1246                        if t.has_non_region_infer() || t.has_placeholders() {
1247                            t.super_visit_with(self)?
1248                        }
1249                    }
1250                }
1251
1252                assert!(self.cache.insert(t));
1253                ControlFlow::Continue(())
1254            }
1255
1256            fn visit_const(&mut self, c: Const<I>) -> Self::Result {
1257                match c.kind() {
1258                    ty::ConstKind::Infer(ty::InferConst::Var(vid)) => {
1259                        if let ty::TermKind::Const(term) = self.term.kind()
1260                            && let ty::ConstKind::Infer(ty::InferConst::Var(term_vid)) = term.kind()
1261                            && self.delegate.root_const_var(vid)
1262                                == self.delegate.root_const_var(term_vid)
1263                        {
1264                            return ControlFlow::Break(());
1265                        }
1266
1267                        self.check_nameable(self.delegate.universe_of_const(vid).unwrap())
1268                    }
1269                    ty::ConstKind::Placeholder(p) => self.check_nameable(p.universe()),
1270                    _ => {
1271                        if c.has_non_region_infer() || c.has_placeholders() {
1272                            c.super_visit_with(self)
1273                        } else {
1274                            ControlFlow::Continue(())
1275                        }
1276                    }
1277                }
1278            }
1279
1280            fn visit_predicate<P: PredicateProxy<I>>(&mut self, p: P) -> Self::Result {
1281                if p.has_non_region_infer() || p.has_placeholders() {
1282                    p.super_visit_with(self)
1283                } else {
1284                    ControlFlow::Continue(())
1285                }
1286            }
1287
1288            fn visit_clauses(&mut self, c: I::Clauses) -> Self::Result {
1289                if c.has_non_region_infer() || c.has_placeholders() {
1290                    c.super_visit_with(self)
1291                } else {
1292                    ControlFlow::Continue(())
1293                }
1294            }
1295        }
1296
1297        let mut visitor = ContainsTermOrNotNameable {
1298            delegate: self.delegate,
1299            universe_of_term,
1300            term: goal.predicate.term,
1301            cache: Default::default(),
1302        };
1303        goal.predicate.alias.visit_with(&mut visitor).is_continue()
1304            && goal.param_env.visit_with(&mut visitor).is_continue()
1305    }
1306
1307    pub(super) fn sub_unify_ty_vids_raw(&self, a: ty::TyVid, b: ty::TyVid) {
1308        self.delegate.sub_unify_ty_vids_raw(a, b)
1309    }
1310
1311    {}
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("eq",
                                "rustc_next_trait_solver::solve::eval_ctxt",
                                ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1311u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("lhs")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("lhs");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("rhs")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("rhs");
                                                    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(&lhs)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&rhs)
                                                        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<(), NoSolutionOrRerunNonErased> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        self.relate(param_env, lhs, ty::Variance::Invariant, rhs)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1311",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1311u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::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)]
1312    pub(super) fn eq<T: Relate<I>>(
1313        &mut self,
1314        param_env: I::ParamEnv,
1315        lhs: T,
1316        rhs: T,
1317    ) -> Result<(), NoSolutionOrRerunNonErased> {
1318        self.relate(param_env, lhs, ty::Variance::Invariant, rhs)
1319    }
1320
1321    {}
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("sub",
                                "rustc_next_trait_solver::solve::eval_ctxt",
                                ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1321u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("sub")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("sub");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("sup")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("sup");
                                                    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(&sub)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sup)
                                                        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<(), NoSolutionOrRerunNonErased> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        self.relate(param_env, sub, ty::Variance::Covariant, sup)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1321",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1321u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::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)]
1322    pub(super) fn sub<T: Relate<I>>(
1323        &mut self,
1324        param_env: I::ParamEnv,
1325        sub: T,
1326        sup: T,
1327    ) -> Result<(), NoSolutionOrRerunNonErased> {
1328        self.relate(param_env, sub, ty::Variance::Covariant, sup)
1329    }
1330
1331    {}
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("relate",
                                "rustc_next_trait_solver::solve::eval_ctxt",
                                ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1331u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("lhs")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("lhs");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("variance")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("variance");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("rhs")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("rhs");
                                                    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(&lhs)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&variance)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&rhs)
                                                        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<(), NoSolutionOrRerunNonErased> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let goals =
                            self.delegate.relate(param_env, lhs, variance, rhs,
                                    self.origin_span)?;
                        for &goal in goals.iter() {
                            let source =
                                match goal.predicate.kind().skip_binder() {
                                    ty::PredicateKind::Subtype { .. } |
                                        ty::PredicateKind::Clause(ty::ClauseKind::Projection(..)) =>
                                        {
                                        GoalSource::TypeRelating
                                    }
                                    ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) =>
                                        GoalSource::Misc,
                                    p => {
                                        ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
                                                format_args!("unexpected nested goal in `relate`: {0:?}",
                                                    p)));
                                    }
                                };
                            self.add_goal(source, goal)?;
                        }
                        Ok(())
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1331",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1331u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::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)]
1332    pub(super) fn relate<T: Relate<I>>(
1333        &mut self,
1334        param_env: I::ParamEnv,
1335        lhs: T,
1336        variance: ty::Variance,
1337        rhs: T,
1338    ) -> Result<(), NoSolutionOrRerunNonErased> {
1339        let goals = self.delegate.relate(param_env, lhs, variance, rhs, self.origin_span)?;
1340        for &goal in goals.iter() {
1341            let source = match goal.predicate.kind().skip_binder() {
1342                ty::PredicateKind::Subtype { .. }
1343                | ty::PredicateKind::Clause(ty::ClauseKind::Projection(..)) => {
1344                    GoalSource::TypeRelating
1345                }
1346                // FIXME(-Znext-solver=coinductive): should these WF goals also be unproductive?
1347                ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => GoalSource::Misc,
1348                p => unreachable!("unexpected nested goal in `relate`: {p:?}"),
1349            };
1350            self.add_goal(source, goal)?;
1351        }
1352        Ok(())
1353    }
1354
1355    /// Equates two values returning the nested goals without adding them
1356    /// to the nested goals of the `EvalCtxt`.
1357    ///
1358    /// If possible, try using `eq` instead which automatically handles nested
1359    /// goals correctly.
1360    {}
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("eq_and_get_goals",
                                "rustc_next_trait_solver::solve::eval_ctxt",
                                ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1360u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("lhs")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("lhs");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("rhs")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("rhs");
                                                    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(&lhs)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&rhs)
                                                        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<Vec<Goal<I, I::Predicate>>, NoSolution> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        Ok(self.delegate.relate(param_env, lhs,
                                    ty::Variance::Invariant, rhs, self.origin_span)?)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1360",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1360u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::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)]
1361    pub(super) fn eq_and_get_goals<T: Relate<I>>(
1362        &self,
1363        param_env: I::ParamEnv,
1364        lhs: T,
1365        rhs: T,
1366    ) -> Result<Vec<Goal<I, I::Predicate>>, NoSolution> {
1367        Ok(self.delegate.relate(param_env, lhs, ty::Variance::Invariant, rhs, self.origin_span)?)
1368    }
1369
1370    pub(super) fn instantiate_binder_with_infer<T: TypeFoldable<I> + Copy>(
1371        &self,
1372        value: ty::Binder<I, T>,
1373    ) -> T {
1374        self.delegate.instantiate_binder_with_infer(value)
1375    }
1376
1377    /// `enter_forall_with_assumptions`, but takes `&mut self` and passes it back through
1378    /// the callback since it can't be aliased during the call.
1379    ///
1380    /// The `param_env` is used to *compute* the assumptions of the binder, not *as* the
1381    /// assumptions associated with the binder.
1382    ///
1383    /// FIXME(inherent_associated_types): fix this?
1384    pub(super) fn enter_forall_with_assumptions<T: TypeFoldable<I>, U>(
1385        &mut self,
1386        value: ty::Binder<I, T>,
1387        param_env: I::ParamEnv,
1388        f: impl FnOnce(&mut Self, T) -> U,
1389    ) -> U {
1390        self.delegate.enter_forall_without_assumptions(value, |value| {
1391            let u = self.delegate.universe();
1392            let assumptions = if self.cx().assumptions_on_binders() {
1393                self.region_assumptions_for_placeholders_in_universe(value.clone(), u, param_env)
1394            } else {
1395                None
1396            };
1397            self.delegate.insert_placeholder_assumptions(u, assumptions);
1398            f(self, value)
1399        })
1400    }
1401
1402    pub(super) fn deeply_resolve_ignoring_regions<T>(&self, value: T) -> T
1403    where
1404        T: TypeFoldable<I>,
1405    {
1406        self.delegate.deeply_resolve_ignoring_regions(value)
1407    }
1408
1409    pub(super) fn shallow_resolve(&self, ty: I::Ty) -> I::Ty {
1410        self.delegate.shallow_resolve(ty)
1411    }
1412
1413    pub(super) fn eager_resolve_region(&self, r: Region<I>) -> Region<I> {
1414        if let ty::ReVar(vid) = r.kind() {
1415            self.delegate.shallow_resolve_region_var(vid)
1416        } else {
1417            r
1418        }
1419    }
1420
1421    pub(super) fn fresh_args_for_item(&mut self, def_id: I::DefId) -> I::GenericArgs {
1422        let args = self.delegate.fresh_args_for_item(def_id);
1423        for arg in args.iter() {
1424            self.inspect.add_var_value(arg);
1425        }
1426        args
1427    }
1428
1429    pub(super) fn register_solver_region_constraint(&self, c: RegionConstraint<I>) {
1430        self.delegate.register_solver_region_constraint(c, self.origin_span);
1431    }
1432
1433    pub(super) fn register_ty_outlives(&self, ty: I::Ty, lt: Region<I>) {
1434        self.delegate.register_ty_outlives(ty, lt, self.origin_span);
1435    }
1436
1437    pub(super) fn register_region_outlives(
1438        &self,
1439        a: Region<I>,
1440        b: Region<I>,
1441        vis: VisibleForLeakCheck,
1442    ) {
1443        // `'a: 'b` ==> `'b <= 'a`
1444        self.delegate.sub_regions(b, a, vis, self.origin_span);
1445    }
1446
1447    /// Computes the list of goals required for `arg` to be well-formed
1448    pub(super) fn well_formed_goals(
1449        &self,
1450        param_env: I::ParamEnv,
1451        term: I::Term,
1452    ) -> Option<Vec<Goal<I, I::Predicate>>> {
1453        self.delegate.well_formed_goals(param_env, term)
1454    }
1455
1456    pub(super) fn trait_ref_is_knowable(
1457        &mut self,
1458        param_env: I::ParamEnv,
1459        trait_ref: ty::TraitRef<I>,
1460    ) -> Result<bool, NoSolutionOrRerunNonErased> {
1461        let delegate = self.delegate;
1462        let lazily_normalize_ty = |ty| self.structurally_normalize_ty(param_env, ty);
1463        coherence::trait_ref_is_knowable(&**delegate, trait_ref, lazily_normalize_ty)
1464            .map(|is_knowable| is_knowable.is_ok())
1465    }
1466
1467    pub(super) fn fetch_eligible_assoc_item(
1468        &self,
1469        goal_trait_ref: ty::TraitRef<I>,
1470        trait_assoc_def_id: I::TraitAssocTermId,
1471        impl_def_id: I::ImplId,
1472    ) -> FetchEligibleAssocItemResponse<I> {
1473        self.delegate.fetch_eligible_assoc_item(goal_trait_ref, trait_assoc_def_id, impl_def_id)
1474    }
1475
1476    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("register_hidden_type_in_storage",
                                "rustc_next_trait_solver::solve::eval_ctxt",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1476u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("opaque_type_key")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("opaque_type_key");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("hidden_ty")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("hidden_ty");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&opaque_type_key)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&hidden_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: Option<I::Ty> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        self.delegate.register_hidden_type_in_storage(opaque_type_key,
                            hidden_ty, self.origin_span)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1476",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1476u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
1477    pub(super) fn register_hidden_type_in_storage(
1478        &mut self,
1479        opaque_type_key: ty::OpaqueTypeKey<I>,
1480        hidden_ty: I::Ty,
1481    ) -> Option<I::Ty> {
1482        self.delegate.register_hidden_type_in_storage(opaque_type_key, hidden_ty, self.origin_span)
1483    }
1484
1485    pub(super) fn add_item_bounds_for_hidden_type(
1486        &mut self,
1487        opaque_def_id: I::OpaqueTyId,
1488        opaque_args: I::GenericArgs,
1489        param_env: I::ParamEnv,
1490        hidden_ty: I::Ty,
1491    ) -> Result<(), NoSolutionOrRerunNonErased> {
1492        let mut goals = Vec::new();
1493        self.delegate.add_item_bounds_for_hidden_type(
1494            opaque_def_id,
1495            opaque_args,
1496            param_env,
1497            hidden_ty,
1498            &mut goals,
1499        );
1500        self.add_goals(GoalSource::AliasWellFormed, goals)?;
1501        Ok(())
1502    }
1503
1504    // Try to evaluate a const and normalize the type of the resulting value, or return `None` if
1505    // the const is too generic. This doesn't mean the const isn't evaluatable, though, and should
1506    // be treated as an ambiguity rather than no-solution.
1507    pub(super) fn evaluate_const(
1508        &mut self,
1509        param_env: I::ParamEnv,
1510        alias_const: ty::AliasConst<I>,
1511    ) -> Result<Option<Const<I>>, NoSolutionOrRerunNonErased> {
1512        if self.typing_mode().is_erased_not_coherence() {
1513            match self.opaque_accesses.rerun_always(RerunReason::EvaluateConst)? {}
1514        }
1515
1516        self.delegate.evaluate_const(param_env, alias_const, |ty| {
1517            self.normalize(GoalSource::Misc, param_env, ty)
1518        })
1519    }
1520
1521    pub(super) fn evaluate_const_and_instantiate_projection_term(
1522        &mut self,
1523        param_env: I::ParamEnv,
1524        projection_term: ty::AliasTerm<I>,
1525        expected_term: I::Term,
1526        alias_const: ty::AliasConst<I>,
1527    ) -> QueryResultOrRerunNonErased<I> {
1528        match self.evaluate_const(param_env, alias_const)? {
1529            Some(evaluated) => {
1530                self.eq(param_env, expected_term, evaluated.into())?;
1531                self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
1532            }
1533            None if self.cx().features().gca_const_items() => {
1534                // HACK(khyperia): calling `deeply_resolve_ignoring_regions` here shouldn't be necessary,
1535                // `try_evaluate_const` calls `deeply_resolve_ignoring_regions` already. However, we want
1536                // to check `has_non_region_infer` against the type with vars resolved (i.e. check
1537                // if there are vars we failed to resolve), so we need to call it again here.
1538                // Perhaps we could split EvaluateConstErr::HasGenericsOrInfers into HasGenerics and
1539                // HasInfers or something, make evaluate_const return that, and make this branch be
1540                // based on that, rather than checking `has_non_region_infer`.
1541                if self.deeply_resolve_ignoring_regions(alias_const).has_non_region_infer() {
1542                    self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
1543                } else {
1544                    // Evaluation failed because the const was too generic or was an invalid type
1545                    // for const generics. The result of normalization is the alias itself,
1546                    // unchanged, but marked as rigid.
1547                    //
1548                    // We do not instantiate to the `alias_const` passed in, but rather
1549                    // `projection_term`, which is the unprocessed, original alias contained within
1550                    // the goal. The `alias_const` passed in might be a Projection whose DefId is an
1551                    // impl of the trait, however, we want to structurally instantiate to the
1552                    // original DefId on the trait itself.
1553                    self.eq(
1554                        param_env,
1555                        projection_term.to_term(self.cx(), ty::IsRigid::Yes),
1556                        expected_term,
1557                    )?;
1558                    self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
1559                }
1560            }
1561            None => {
1562                // Legacy behavior: always treat as ambiguous
1563                self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
1564            }
1565        }
1566    }
1567
1568    pub(super) fn is_transmutable(
1569        &mut self,
1570        src: I::Ty,
1571        dst: I::Ty,
1572        assume: Const<I>,
1573    ) -> Result<Certainty, NoSolution> {
1574        self.delegate.is_transmutable(dst, src, assume)
1575    }
1576
1577    pub(super) fn replace_bound_vars<T: TypeFoldable<I>>(
1578        &self,
1579        t: T,
1580        universes: &mut Vec<Option<ty::UniverseIndex>>,
1581    ) -> T {
1582        BoundVarReplacer::replace_bound_vars(&**self.delegate, universes, t).0
1583    }
1584
1585    pub(super) fn may_use_unstable_feature(
1586        &mut self,
1587        param_env: I::ParamEnv,
1588        symbol: I::Symbol,
1589    ) -> Result<bool, RerunNonErased> {
1590        if self.typing_mode().is_erased_not_coherence() {
1591            match self.opaque_accesses.rerun_always(RerunReason::MayUseUnstableFeature)? {}
1592        }
1593
1594        Ok(may_use_unstable_feature(&**self.delegate, param_env, symbol))
1595    }
1596
1597    pub(crate) fn opaques_with_sub_unified_hidden_type(
1598        &self,
1599        self_ty: I::Ty,
1600    ) -> Vec<ty::OpaqueAliasTy<I>> {
1601        if let ty::Infer(ty::TyVar(vid)) = self_ty.kind() {
1602            self.delegate.opaques_with_sub_unified_hidden_type(vid)
1603        } else {
1604            ::alloc::vec::Vec::new()vec![]
1605        }
1606    }
1607
1608    /// To return the constraints of a canonical query to the caller, we canonicalize:
1609    ///
1610    /// - `var_values`: a map from bound variables in the canonical goal to
1611    ///   the values inferred while solving the instantiated goal.
1612    /// - `external_constraints`: additional constraints which aren't expressible
1613    ///   using simple unification of inference variables.
1614    ///
1615    /// This takes the `shallow_certainty` which represents whether we're confident
1616    /// that the final result of the current goal only depends on the nested goals.
1617    ///
1618    /// In case this is `Certainty::Maybe`, there may still be additional nested goals
1619    /// or inference constraints required for this candidate to be hold. The candidate
1620    /// always requires all already added constraints and nested goals.
1621    {}
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("evaluate_added_goals_and_make_canonical_response",
                                "rustc_next_trait_solver::solve::eval_ctxt",
                                ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1621u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("shallow_certainty")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("shallow_certainty");
                                                    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(&shallow_certainty)
                                                        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;
                    }
                    {
                        self.inspect.make_canonical_response(shallow_certainty);
                        let goals_certainty = self.try_evaluate_added_goals()?;
                        {
                            match (&self.tainted, &Ok(())) {
                                (left_val, right_val) => {
                                    if !(*left_val == *right_val) {
                                        let kind = ::core::panicking::AssertKind::Eq;
                                        ::core::panicking::assert_failed(kind, &*left_val,
                                            &*right_val,
                                            ::core::option::Option::Some(format_args!("EvalCtxt is tainted -- nested goals may have been dropped in a previous call to `try_evaluate_added_goals!`")));
                                    }
                                }
                            }
                        };
                        let goals_certainty =
                            match self.delegate.cx().assumptions_on_binders() {
                                true => {
                                    let certainty = self.eagerly_handle_placeholders()?;
                                    certainty.and(goals_certainty)
                                }
                                false => {
                                    self.delegate.leak_check(self.max_input_universe).map_err(|NoSolution|
                                                {
                                                    {
                                                        use ::tracing::__macro_support::Callsite as _;
                                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                                            {
                                                                static META: ::tracing::Metadata<'static> =
                                                                    {
                                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1645",
                                                                            "rustc_next_trait_solver::solve::eval_ctxt",
                                                                            ::tracing::Level::TRACE,
                                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                                                            ::tracing_core::__macro_support::Option::Some(1645u32),
                                                                            ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                                                            ::tracing_core::field::FieldSet::new(&["message"],
                                                                                ::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(&format_args!("failed the leak check")
                                                                                                as &dyn ::tracing::field::Value))])
                                                                });
                                                        } else { ; }
                                                    };
                                                    NoSolution
                                                })?;
                                    goals_certainty
                                }
                            };
                        let (certainty, normalization_nested_goals) =
                            match (self.current_goal_kind, shallow_certainty) {
                                (CurrentGoalKind::ProjectionComputeAssocTermCandidate,
                                    Certainty::Yes) => {
                                    let goals = std::mem::take(&mut self.nested_goals);
                                    if goals.is_empty() {
                                        if !#[allow(non_exhaustive_omitted_patterns)] match goals_certainty
                                                    {
                                                    Certainty::Yes => true,
                                                    _ => false,
                                                } {
                                            ::core::panicking::panic("assertion failed: matches!(goals_certainty, Certainty::Yes)")
                                        };
                                    }
                                    (Certainty::Yes,
                                        NestedNormalizationGoals(goals.into_iter().map(|(s, g, _)|
                                                        (s, g)).collect()))
                                }
                                _ => {
                                    let certainty = shallow_certainty.and(goals_certainty);
                                    (certainty, NestedNormalizationGoals::empty())
                                }
                            };
                        if let Certainty::Maybe(maybe_info @ MaybeInfo {
                                cause: MaybeCause::Overflow { keep_constraints: false, .. },
                                opaque_types_jank: _,
                                stalled_on_coroutines: _ }) = certainty {
                            return Ok(self.make_ambiguous_response_no_constraints(maybe_info));
                        }
                        let external_constraints =
                            self.compute_external_query_constraints(certainty,
                                normalization_nested_goals);
                        let (var_values, mut external_constraints) =
                            self.delegate.deeply_resolve_via_unification_table((self.var_values,
                                    external_constraints));
                        let mut unique = HashSet::default();
                        if let ExternalRegionConstraints::Old(r) =
                                &mut external_constraints.region_constraints {
                            r.retain(|(outlives, _)|
                                    !outlives.is_trivial() && unique.insert(*outlives));
                        }
                        filter_irrelevant_region_constraints(self.delegate,
                            &var_values, &mut external_constraints);
                        let canonical =
                            canonicalize_response(self.delegate,
                                self.max_input_universe,
                                Response {
                                    var_values,
                                    certainty,
                                    external_constraints: self.cx().mk_external_constraints(external_constraints),
                                });
                        Ok(canonical)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1621",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1621u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::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)]
1622    pub(in crate::solve) fn evaluate_added_goals_and_make_canonical_response(
1623        &mut self,
1624        shallow_certainty: Certainty,
1625    ) -> QueryResultOrRerunNonErased<I> {
1626        self.inspect.make_canonical_response(shallow_certainty);
1627
1628        let goals_certainty = self.try_evaluate_added_goals()?;
1629        assert_eq!(
1630            self.tainted,
1631            Ok(()),
1632            "EvalCtxt is tainted -- nested goals may have been dropped in a \
1633            previous call to `try_evaluate_added_goals!`"
1634        );
1635
1636        let goals_certainty = match self.delegate.cx().assumptions_on_binders() {
1637            true => {
1638                let certainty = self.eagerly_handle_placeholders()?;
1639                certainty.and(goals_certainty)
1640            }
1641            false => {
1642                // We only check for leaks from universes which were entered inside
1643                // of the query.
1644                self.delegate.leak_check(self.max_input_universe).map_err(|NoSolution| {
1645                    trace!("failed the leak check");
1646                    NoSolution
1647                })?;
1648
1649                goals_certainty
1650            }
1651        };
1652
1653        let (certainty, normalization_nested_goals) =
1654            match (self.current_goal_kind, shallow_certainty) {
1655                // When normalizing, we've replaced the expected term with an unconstrained
1656                // inference variable. This means that we dropped information which could
1657                // have been important. We handle this by instead returning the nested goals
1658                // to the caller, where they are then handled. We only do so if we do not
1659                // need to recompute the `NormalizesTo` goal afterwards to avoid repeatedly
1660                // uplifting its nested goals. This is the case if the `shallow_certainty` is
1661                // `Certainty::Yes`.
1662                (CurrentGoalKind::ProjectionComputeAssocTermCandidate, Certainty::Yes) => {
1663                    let goals = std::mem::take(&mut self.nested_goals);
1664                    // As we return all ambiguous nested goals, we can ignore the certainty
1665                    // returned by `self.try_evaluate_added_goals()`.
1666                    if goals.is_empty() {
1667                        assert!(matches!(goals_certainty, Certainty::Yes));
1668                    }
1669                    (
1670                        Certainty::Yes,
1671                        NestedNormalizationGoals(
1672                            goals.into_iter().map(|(s, g, _)| (s, g)).collect(),
1673                        ),
1674                    )
1675                }
1676                _ => {
1677                    let certainty = shallow_certainty.and(goals_certainty);
1678                    (certainty, NestedNormalizationGoals::empty())
1679                }
1680            };
1681
1682        if let Certainty::Maybe(
1683            maybe_info @ MaybeInfo {
1684                cause: MaybeCause::Overflow { keep_constraints: false, .. },
1685                opaque_types_jank: _,
1686                stalled_on_coroutines: _,
1687            },
1688        ) = certainty
1689        {
1690            // If we have overflow, it's probable that we're substituting a type
1691            // into itself infinitely and any partial substitutions in the query
1692            // response are probably not useful anyways, so just return an empty
1693            // query response.
1694            //
1695            // This may prevent us from potentially useful inference, e.g.
1696            // 2 candidates, one ambiguous and one overflow, which both
1697            // have the same inference constraints.
1698            //
1699            // Changing this to retain some constraints in the future
1700            // won't be a breaking change, so this is good enough for now.
1701            return Ok(self.make_ambiguous_response_no_constraints(maybe_info));
1702        }
1703
1704        let external_constraints =
1705            self.compute_external_query_constraints(certainty, normalization_nested_goals);
1706        let (var_values, mut external_constraints) = self
1707            .delegate
1708            .deeply_resolve_via_unification_table((self.var_values, external_constraints));
1709
1710        // Remove any trivial or duplicated region constraints once we've resolved regions
1711        let mut unique = HashSet::default();
1712        if let ExternalRegionConstraints::Old(r) = &mut external_constraints.region_constraints {
1713            r.retain(|(outlives, _)| !outlives.is_trivial() && unique.insert(*outlives));
1714        }
1715
1716        filter_irrelevant_region_constraints(self.delegate, &var_values, &mut external_constraints);
1717
1718        let canonical = canonicalize_response(
1719            self.delegate,
1720            self.max_input_universe,
1721            Response {
1722                var_values,
1723                certainty,
1724                external_constraints: self.cx().mk_external_constraints(external_constraints),
1725            },
1726        );
1727
1728        Ok(canonical)
1729    }
1730
1731    /// Constructs a totally unconstrained, ambiguous response to a goal.
1732    ///
1733    /// Take care when using this, since often it's useful to respond with
1734    /// ambiguity but return constrained variables to guide inference.
1735    pub(in crate::solve) fn make_ambiguous_response_no_constraints(
1736        &self,
1737        maybe: MaybeInfo,
1738    ) -> CanonicalResponse<I> {
1739        response_no_constraints_raw(
1740            self.cx(),
1741            self.max_input_universe,
1742            self.var_kinds,
1743            Certainty::Maybe(maybe),
1744        )
1745    }
1746
1747    /// Computes the region constraints and *new* opaque types registered when
1748    /// proving a goal.
1749    ///
1750    /// If an opaque was already constrained before proving this goal, then the
1751    /// external constraints do not need to record that opaque, since if it is
1752    /// further constrained by inference, that will be passed back in the var
1753    /// values.
1754    {}
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_external_query_constraints",
                                "rustc_next_trait_solver::solve::eval_ctxt",
                                ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1754u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("certainty")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("certainty");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("normalization_nested_goals")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("normalization_nested_goals");
                                                    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(&certainty)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&normalization_nested_goals)
                                                        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: ExternalConstraintsData<I> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let region_constraints =
                            if self.cx().assumptions_on_binders() {
                                ExternalRegionConstraints::NextGen(if let Certainty::Yes =
                                            certainty {
                                        let constraint =
                                            self.delegate.get_solver_region_constraint();
                                        if true {
                                            {
                                                match (&constraint,
                                                        &region_constraint::propagate_ambiguity(constraint.clone()))
                                                    {
                                                    (left_val, right_val) => {
                                                        if !(*left_val == *right_val) {
                                                            let kind = ::core::panicking::AssertKind::Eq;
                                                            ::core::panicking::assert_failed(kind, &*left_val,
                                                                &*right_val, ::core::option::Option::None);
                                                        }
                                                    }
                                                }
                                            };
                                        };
                                        constraint
                                    } else { RegionConstraint::new_true() })
                            } else {
                                ExternalRegionConstraints::Old(if let Certainty::Yes =
                                            certainty {
                                        self.delegate.make_deduplicated_region_constraints()
                                    } else { ::alloc::vec::Vec::new() })
                            };
                        let opaque_types =
                            self.delegate.clone_opaque_types_added_since(self.initial_opaque_types_storage_num_entries);
                        if self.typing_mode().is_erased_not_coherence() {
                            if !opaque_types.is_empty() {
                                ::core::panicking::panic("assertion failed: opaque_types.is_empty()")
                            };
                        }
                        ExternalConstraintsData {
                            region_constraints,
                            opaque_types,
                            normalization_nested_goals,
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1754",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1754u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::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)]
1755    fn compute_external_query_constraints(
1756        &self,
1757        certainty: Certainty,
1758        normalization_nested_goals: NestedNormalizationGoals<I>,
1759    ) -> ExternalConstraintsData<I> {
1760        // We only return region constraints once the certainty is `Yes`. This
1761        // is necessary as we may drop nested goals on ambiguity, which may result
1762        // in unconstrained inference variables in the region constraints. It also
1763        // prevents us from emitting duplicate region constraints, avoiding some
1764        // unnecessary work. This slightly weakens the leak check in case it uses
1765        // region constraints from an ambiguous nested goal. This is tested in both
1766        // `tests/ui/higher-ranked/leak-check/leak-check-in-selection-5-ambig.rs` and
1767        // `tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.rs`.
1768        let region_constraints = if self.cx().assumptions_on_binders() {
1769            ExternalRegionConstraints::NextGen(if let Certainty::Yes = certainty {
1770                let constraint = self.delegate.get_solver_region_constraint();
1771                debug_assert_eq!(
1772                    constraint,
1773                    region_constraint::propagate_ambiguity(constraint.clone())
1774                );
1775                constraint
1776            } else {
1777                RegionConstraint::new_true()
1778            })
1779        } else {
1780            ExternalRegionConstraints::Old(if let Certainty::Yes = certainty {
1781                self.delegate.make_deduplicated_region_constraints()
1782            } else {
1783                vec![]
1784            })
1785        };
1786
1787        // We only return *newly defined* opaque types from canonical queries.
1788        //
1789        // Constraints for any existing opaque types are already tracked by changes
1790        // to the `var_values`.
1791        let opaque_types = self
1792            .delegate
1793            .clone_opaque_types_added_since(self.initial_opaque_types_storage_num_entries);
1794
1795        if self.typing_mode().is_erased_not_coherence() {
1796            assert!(opaque_types.is_empty());
1797        }
1798
1799        ExternalConstraintsData { region_constraints, opaque_types, normalization_nested_goals }
1800    }
1801
1802    pub(super) fn normalize<T: TypeFoldable<I>>(
1803        &mut self,
1804        source: GoalSource,
1805        param_env: I::ParamEnv,
1806        value: ty::Unnormalized<I, T>,
1807    ) -> Result<T, NoSolutionOrRerunNonErased> {
1808        let value = self.delegate.deeply_resolve_ignoring_regions(value.skip_normalization());
1809
1810        if !self.cx().renormalize_rigid_aliases() && !value.has_non_rigid_aliases() {
1811            return Ok(value);
1812        }
1813
1814        // To drop the mutable borrow of self early.
1815        let infcx = self.delegate.deref();
1816        let mut folder = NormalizationFolder::new(infcx, ::alloc::vec::Vec::new()vec![], |alias_term| {
1817            let infer_term = self.next_term_infer_of_alias_kind(alias_term);
1818            let pred = ty::ProjectionClause { projection_term: alias_term, term: infer_term };
1819            let goal = Goal::new(self.cx(), param_env, pred);
1820            self.inspect.add_goal(self.delegate, self.max_input_universe, source, goal);
1821            let GoalEvaluation { goal, certainty, has_changed: _, stalled_on } =
1822                self.evaluate_goal(source, goal, None)?;
1823            let normalization_was_ambiguous = match certainty {
1824                Certainty::Yes => NormalizationWasAmbiguous::No,
1825                Certainty::Maybe(_) => {
1826                    self.nested_goals.push((source, goal, stalled_on));
1827                    NormalizationWasAmbiguous::Yes
1828                }
1829            };
1830
1831            Ok((self.deeply_resolve_ignoring_regions(infer_term), normalization_was_ambiguous))
1832        });
1833        value.try_fold_with(&mut folder)
1834    }
1835}
1836
1837fn filter_irrelevant_region_constraints<D, I>(
1838    delegate: &D,
1839    var_values: &CanonicalVarValues<I>,
1840    external_constraints: &mut ExternalConstraintsData<I>,
1841) where
1842    D: SolverDelegate<Interner = I>,
1843    I: Interner,
1844{
1845    #[derive(#[automatically_derived]
impl ::core::default::Default for NonTrivialVars {
    #[inline]
    fn default() -> Self {
        NonTrivialVars { vars: ::core::default::Default::default() }
    }
}Default)]
1846    struct NonTrivialVars {
1847        vars: HashSet<RegionVid>,
1848    }
1849    impl<I> TypeVisitor<I> for NonTrivialVars
1850    where
1851        I: Interner,
1852    {
1853        type Result = ();
1854        fn visit_ty(&mut self, t: I::Ty) {
1855            // If a nested type doesn't have any `ReVar`s, then we won't insert
1856            // anything into `vars` anyway, so skip for better perf.
1857            if !t.has_infer_regions() {
1858                return;
1859            }
1860            t.super_visit_with(self);
1861        }
1862        fn visit_const(&mut self, c: Const<I>) {
1863            // The same goes for consts.
1864            if !c.has_infer_regions() {
1865                return;
1866            }
1867            c.super_visit_with(self);
1868        }
1869        fn visit_region(&mut self, r: Region<I>) {
1870            if let ty::ReVar(vid) = r.kind() {
1871                self.vars.insert(vid);
1872            }
1873        }
1874    }
1875
1876    let ExternalConstraintsData { region_constraints, opaque_types, normalization_nested_goals } =
1877        external_constraints;
1878
1879    // If we have a constraint like `'re: '?1`, where '?1 can name 're and '?1 appears
1880    // only on the RHS of region constraints, then this kind of constraint is also trivial,
1881    // since we're able to pick '?1 := glb('re, other_regions), and by definition of glb,
1882    // `'re: glb`.
1883    if let ExternalRegionConstraints::Old(r) = region_constraints
1884        && !r.is_empty()
1885    {
1886        let mut vis = NonTrivialVars::default();
1887        var_values.visit_with(&mut vis);
1888        // We have to visit each component of `external_constraints` individually here
1889        // because we skip the RHS of outlives constraints, and `TypeVisitor` doesn't
1890        // have a method we can easily override in order to do this.
1891        opaque_types.visit_with(&mut vis);
1892        normalization_nested_goals.visit_with(&mut vis);
1893        for (constraint, _) in r.iter() {
1894            match constraint {
1895                ty::RegionConstraint::Outlives(ty::OutlivesClause(sup, _)) => {
1896                    sup.visit_with(&mut vis)
1897                }
1898                ty::RegionConstraint::Eq(eq) => eq.visit_with(&mut vis),
1899            }
1900        }
1901
1902        r.retain(|(outlives, _)| {
1903            if let ty::RegionConstraint::Outlives(ty::OutlivesClause(sup, re)) = *outlives
1904                && let Some(sup_re) = sup.as_region()
1905                && let ty::RegionKind::ReVar(vid) = re.kind()
1906                // This is only safe if we call `eager_resolve_vars` before calling,
1907                // this function, which we do.
1908                && delegate.universe_of_region(vid).unwrap()
1909                    .can_name(max_universe(&**delegate, sup_re))
1910            {
1911                vis.vars.contains(&vid)
1912            } else {
1913                true
1914            }
1915        });
1916    }
1917}
1918
1919#[derive(#[automatically_derived]
impl ::core::fmt::Debug for RerunDecision {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                RerunDecision::Yes => "Yes",
                RerunDecision::No => "No",
                RerunDecision::EagerlyPropagateToParent =>
                    "EagerlyPropagateToParent",
            })
    }
}Debug)]
1920enum RerunDecision {
1921    Yes,
1922    No,
1923    EagerlyPropagateToParent,
1924}
1925
1926{}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::INFO <=
                ::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("should_rerun_after_erased_canonicalization",
                                "rustc_next_trait_solver::solve::eval_ctxt",
                                ::tracing::Level::INFO,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1926u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("rerun")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("rerun");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("original_typing_mode")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("original_typing_mode");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("parent_opaque_types")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("parent_opaque_types");
                                                    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::INFO <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::INFO <=
                                ::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(&rerun)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&original_typing_mode)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&parent_opaque_types)
                                                        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: RerunDecision = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let parent_opaque_def_ids =
                            parent_opaque_types.iter().map(|(key, _)|
                                    key.def_id.into());
                        let opaque_in_storage =
                            |opaques: I::LocalDefIds, def_ids: SmallCopySet<_>|
                                {
                                    if def_ids.as_ref().is_empty() {
                                        RerunDecision::No
                                    } else if opaques.iter().chain(parent_opaque_def_ids).any(|opaque|
                                                def_ids.as_ref().contains(&opaque)) {
                                        RerunDecision::Yes
                                    } else { RerunDecision::No }
                                };
                        let any_opaque_has_infer_as_hidden =
                            ||
                                {
                                    if parent_opaque_types.iter().any(|(_, ty)| ty.is_ty_var())
                                        {
                                        RerunDecision::Yes
                                    } else { RerunDecision::No }
                                };
                        match (rerun, original_typing_mode) {
                            (RerunCondition::Never, _) => RerunDecision::No,
                            (_, TypingMode::ErasedNotCoherence(MayBeErased)) =>
                                RerunDecision::EagerlyPropagateToParent,
                            (_, TypingMode::Coherence) =>
                                ::core::panicking::panic("internal error: entered unreachable code"),
                            (RerunCondition::Always, _) => RerunDecision::Yes,
                            (RerunCondition::OpaqueInStorage(..),
                                TypingMode::PostAnalysis | TypingMode::Codegen |
                                TypingMode::Reflection) => RerunDecision::Yes,
                            (RerunCondition::OpaqueInStorage(defids),
                                TypingMode::PostBorrowck { defined_opaque_types: opaques } |
                                TypingMode::Typeck {
                                defining_opaque_types_and_generators: opaques } |
                                TypingMode::PostTypeckUntilBorrowck {
                                defining_opaque_types: opaques }) =>
                                opaque_in_storage(opaques, defids),
                            (RerunCondition::AnyOpaqueHasInferAsHidden,
                                TypingMode::Typeck { .. }) => {
                                any_opaque_has_infer_as_hidden()
                            }
                            (RerunCondition::AnyOpaqueHasInferAsHidden,
                                TypingMode::PostBorrowck { .. } | TypingMode::PostAnalysis |
                                TypingMode::Codegen | TypingMode::Reflection |
                                TypingMode::PostTypeckUntilBorrowck { .. }) =>
                                RerunDecision::No,
                            (RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(_),
                                TypingMode::PostAnalysis | TypingMode::Codegen |
                                TypingMode::Reflection) => RerunDecision::Yes,
                            (RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
                                TypingMode::Typeck {
                                defining_opaque_types_and_generators: opaques }) => {
                                if let RerunDecision::Yes = any_opaque_has_infer_as_hidden()
                                    {
                                    RerunDecision::Yes
                                } else if let RerunDecision::Yes =
                                        opaque_in_storage(opaques, defids) {
                                    RerunDecision::Yes
                                } else { RerunDecision::No }
                            }
                            (RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
                                TypingMode::PostBorrowck { defined_opaque_types: opaques } |
                                TypingMode::PostTypeckUntilBorrowck {
                                defining_opaque_types: opaques }) =>
                                opaque_in_storage(opaques, defids),
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1926",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::INFO,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/fd8e211ae301c84a86d13cf52a6d3ce08c589e2e/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1926u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
                        ::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::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::INFO <=
                    ::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;#[tracing::instrument(ret)]
1927fn should_rerun_after_erased_canonicalization<I: Interner>(
1928    AccessedOpaques { reason: _, rerun }: AccessedOpaques<I>,
1929    original_typing_mode: TypingMode<I>,
1930    parent_opaque_types: &[(OpaqueTypeKey<I>, I::Ty)],
1931) -> RerunDecision {
1932    let parent_opaque_def_ids = parent_opaque_types.iter().map(|(key, _)| key.def_id.into());
1933    let opaque_in_storage = |opaques: I::LocalDefIds, def_ids: SmallCopySet<_>| {
1934        if def_ids.as_ref().is_empty() {
1935            RerunDecision::No
1936        } else if opaques
1937            .iter()
1938            .chain(parent_opaque_def_ids)
1939            .any(|opaque| def_ids.as_ref().contains(&opaque))
1940        {
1941            RerunDecision::Yes
1942        } else {
1943            RerunDecision::No
1944        }
1945    };
1946    let any_opaque_has_infer_as_hidden = || {
1947        if parent_opaque_types.iter().any(|(_, ty)| ty.is_ty_var()) {
1948            RerunDecision::Yes
1949        } else {
1950            RerunDecision::No
1951        }
1952    };
1953
1954    match (rerun, original_typing_mode) {
1955        // =============================
1956        (RerunCondition::Never, _) => RerunDecision::No,
1957        // =============================
1958        (_, TypingMode::ErasedNotCoherence(MayBeErased)) => RerunDecision::EagerlyPropagateToParent,
1959        // =============================
1960        // In coherence, we never switch to erased mode, so we will never register anything
1961        // in the rerun state, so we should've taken the first branch of this match
1962        (_, TypingMode::Coherence) => unreachable!(),
1963        // =============================
1964        (RerunCondition::Always, _) => RerunDecision::Yes,
1965        // =============================
1966        (
1967            RerunCondition::OpaqueInStorage(..),
1968            TypingMode::PostAnalysis | TypingMode::Codegen | TypingMode::Reflection,
1969        ) => RerunDecision::Yes,
1970        (
1971            RerunCondition::OpaqueInStorage(defids),
1972            TypingMode::PostBorrowck { defined_opaque_types: opaques }
1973            | TypingMode::Typeck { defining_opaque_types_and_generators: opaques }
1974            | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types: opaques },
1975        ) => opaque_in_storage(opaques, defids),
1976        // =============================
1977        (RerunCondition::AnyOpaqueHasInferAsHidden, TypingMode::Typeck { .. }) => {
1978            any_opaque_has_infer_as_hidden()
1979        }
1980        (
1981            RerunCondition::AnyOpaqueHasInferAsHidden,
1982            TypingMode::PostBorrowck { .. }
1983            | TypingMode::PostAnalysis
1984            | TypingMode::Codegen
1985            | TypingMode::Reflection
1986            | TypingMode::PostTypeckUntilBorrowck { .. },
1987        ) => RerunDecision::No,
1988        // =============================
1989        (
1990            RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(_),
1991            TypingMode::PostAnalysis | TypingMode::Codegen | TypingMode::Reflection,
1992        ) => RerunDecision::Yes,
1993        (
1994            RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
1995            TypingMode::Typeck { defining_opaque_types_and_generators: opaques },
1996        ) => {
1997            if let RerunDecision::Yes = any_opaque_has_infer_as_hidden() {
1998                RerunDecision::Yes
1999            } else if let RerunDecision::Yes = opaque_in_storage(opaques, defids) {
2000                RerunDecision::Yes
2001            } else {
2002                RerunDecision::No
2003            }
2004        }
2005        (
2006            RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
2007            TypingMode::PostBorrowck { defined_opaque_types: opaques }
2008            | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types: opaques },
2009        ) => opaque_in_storage(opaques, defids),
2010    }
2011}
2012
2013/// Do not call this directly, use the `tcx` query instead.
2014pub fn evaluate_root_goal_for_proof_tree_raw_provider<
2015    D: SolverDelegate<Interner = I>,
2016    I: Interner,
2017>(
2018    cx: I,
2019    canonical_goal: I::CanonicalInput,
2020    root_depth: usize,
2021) -> (QueryResult<I>, I::Probe, RequiredDepth) {
2022    let mut inspect = inspect::ProofTreeBuilder::new();
2023    let ((canonical_result, accessed_opaques), required_depth) =
2024        SearchGraph::<D>::evaluate_root_goal_for_proof_tree(
2025            cx,
2026            root_depth,
2027            canonical_goal,
2028            &mut inspect,
2029        );
2030    let final_revision = inspect.unwrap();
2031
2032    if !!accessed_opaques.might_rerun() {
    ::core::panicking::panic("assertion failed: !accessed_opaques.might_rerun()")
};assert!(!accessed_opaques.might_rerun());
2033    (canonical_result, cx.mk_probe(final_revision), required_depth)
2034}
2035
2036/// Evaluate a goal to build a proof tree.
2037///
2038/// This is a copy of [EvalCtxt::evaluate_goal_raw] which avoids relying on the
2039/// [EvalCtxt] and uses a separate cache.
2040pub(super) fn evaluate_root_goal_for_proof_tree<D: SolverDelegate<Interner = I>, I: Interner>(
2041    delegate: &D,
2042    goal: Goal<I, I::Predicate>,
2043    origin_span: I::Span,
2044    root_depth: usize,
2045) -> (Result<NestedNormalizationGoals<I>, NoSolution>, inspect::GoalEvaluation<I>) {
2046    let opaque_types = delegate.clone_opaque_types_lookup_table();
2047    let (goal, opaque_types) = delegate.deeply_resolve_via_unification_table((goal, opaque_types));
2048    let typing_mode = delegate.typing_mode_raw().assert_not_erased();
2049
2050    let (orig_values, canonical_goal) =
2051        canonicalize_goal(delegate, goal, &opaque_types, typing_mode.into());
2052
2053    let (canonical_result, final_revision, required_depth) =
2054        delegate.cx().evaluate_root_goal_for_proof_tree_raw(canonical_goal, root_depth);
2055
2056    let proof_tree = inspect::GoalEvaluation {
2057        uncanonicalized_goal: goal,
2058        orig_values,
2059        final_revision,
2060        result: canonical_result,
2061        required_depth,
2062    };
2063
2064    let response = match canonical_result {
2065        Err(e) => return (Err(e), proof_tree),
2066        Ok(response) => response,
2067    };
2068
2069    let (normalization_nested_goals, _certainty) = instantiate_and_apply_query_response(
2070        delegate,
2071        &proof_tree.orig_values,
2072        response,
2073        origin_span,
2074    );
2075
2076    (Ok(normalization_nested_goals), proof_tree)
2077}