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::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::Projection => "Projection",
                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    /// A `ProjectionGoal`. These are temporarily special wrt to cycle handling.
67    Projection,
68    // FIXME: Consider renaming `PredicateKind::NormalizesTo` to match with this
69    /// Unlike other goals, `NormalizesTo` goals aren't independent goals but just implementation
70    /// details for handling projections of associated terms. When we encounter a `Projection` goal
71    /// whose `projection_term` is an associated term, we create a `NormalizesTo` goal whose
72    /// expected term is fully unconstrained and evaluate it.
73    ///
74    /// This would weaken inference however, as the nested goals of normalizes-to never get the
75    /// inference constraints from the actual expected term. We just gather candidates from the
76    /// normalizes-to goal and return any ambiguous nested goals of it to the caller (`Projection
77    /// goal`). The caller handle and evaluate them as if they were its own nested goals.
78    ///
79    /// Because of this, evaluating a normalizes-to goal is computing candidates for projection of
80    /// an associated term and it never leaks out of the solver.
81    ProjectionComputeAssocTermCandidate,
82}
83
84impl CurrentGoalKind {
85    fn from_query_input<I: Interner>(cx: I, input: QueryInput<I, I::Predicate>) -> CurrentGoalKind {
86        match input.goal.predicate.kind().skip_binder() {
87            ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
88                if cx.trait_is_coinductive(pred.trait_ref.def_id) {
89                    CurrentGoalKind::CoinductiveTrait
90                } else {
91                    CurrentGoalKind::Misc
92                }
93            }
94            ty::PredicateKind::Clause(ty::ClauseKind::Projection(_)) => CurrentGoalKind::Projection,
95            ty::PredicateKind::NormalizesTo(_) => {
96                CurrentGoalKind::ProjectionComputeAssocTermCandidate
97            }
98            _ => CurrentGoalKind::Misc,
99        }
100    }
101}
102
103pub struct EvalCtxt<'a, D, I = <D as SolverDelegate>::Interner>
104where
105    D: SolverDelegate<Interner = I>,
106    I: Interner,
107{
108    /// The inference context that backs (mostly) inference and placeholder terms
109    /// instantiated while solving goals.
110    ///
111    /// NOTE: The `InferCtxt` that backs the `EvalCtxt` is intentionally private,
112    /// because the `InferCtxt` is much more general than `EvalCtxt`. Methods such
113    /// as  `take_registered_region_obligations` can mess up query responses,
114    /// using `At::normalize` is totally wrong, calling `evaluate_root_goal` can
115    /// cause coinductive unsoundness, etc.
116    ///
117    /// Methods that are generally of use for trait solving are *intentionally*
118    /// re-declared through the `EvalCtxt` below, often with cleaner signatures
119    /// since we don't care about things like `ObligationCause`s and `Span`s here.
120    /// If some `InferCtxt` method is missing, please first think defensively about
121    /// the method's compatibility with this solver, or if an existing one does
122    /// the job already.
123    delegate: &'a D,
124
125    /// The variable info for the `var_values`, only used to make an ambiguous response
126    /// with no constraints.
127    var_kinds: I::CanonicalVarKinds,
128
129    /// What kind of goal we're currently computing, see the enum definition
130    /// for more info.
131    current_goal_kind: CurrentGoalKind,
132    pub(super) var_values: CanonicalVarValues<I>,
133
134    /// The highest universe index nameable by the caller.
135    ///
136    /// When we enter a new binder inside of the query we create new universes
137    /// which the caller cannot name. We have to be careful with variables from
138    /// these new universes when creating the query response.
139    ///
140    /// Both because these new universes can prevent us from reaching a fixpoint
141    /// if we have a coinductive cycle and because that's the only way we can return
142    /// new placeholders to the caller.
143    pub(super) max_input_universe: ty::UniverseIndex,
144    /// The opaque types from the canonical input. We only need to return opaque types
145    /// which have been added to the storage while evaluating this goal.
146    pub(super) initial_opaque_types_storage_num_entries:
147        <D::Infcx as InferCtxtLike>::OpaqueTypeStorageEntries,
148
149    pub(super) search_graph: &'a mut SearchGraph<D>,
150
151    nested_goals: Vec<(GoalSource, Goal<I, I::Predicate>, Option<GoalStalledOn<I>>)>,
152
153    pub(super) origin_span: I::Span,
154
155    // Has this `EvalCtxt` errored out with `NoSolution` in `try_evaluate_added_goals`?
156    //
157    // If so, then it can no longer be used to make a canonical query response,
158    // since subsequent calls to `try_evaluate_added_goals` have possibly dropped
159    // ambiguous goals. Instead, a probe needs to be introduced somewhere in the
160    // evaluation code.
161    tainted: Result<(), NoSolution>,
162
163    /// Tracks accesses of opaque types while in [`TypingMode::ErasedNotCoherence`].
164    pub(super) opaque_accesses: AccessedOpaques<I>,
165
166    pub(super) inspect: inspect::EvaluationStepBuilder<D>,
167}
168
169#[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)]
170#[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))]
171pub enum GenerateProofTree {
172    Yes,
173    No,
174}
175
176pub trait SolverDelegateEvalExt: SolverDelegate {
177    /// Evaluates a goal from **outside** of the trait solver.
178    ///
179    /// Using this while inside of the solver is wrong as it uses a new
180    /// search graph which would break cycle detection.
181    fn evaluate_root_goal(
182        &self,
183        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
184        span: <Self::Interner as Interner>::Span,
185        stalled_on: Option<GoalStalledOn<Self::Interner>>,
186    ) -> Result<GoalEvaluation<Self::Interner>, NoSolution>;
187
188    /// Checks whether a stalled goal would remain stalled if re-evaluated, without consuming
189    /// `stalled_on`.
190    fn goal_remains_stalled(&self, stalled_on: &GoalStalledOn<Self::Interner>) -> bool;
191
192    /// Checks whether evaluating `goal` may hold while treating not-yet-defined
193    /// opaque types as being kind of rigid.
194    ///
195    /// See the comment on [OpaqueTypesJank] for more details.
196    fn root_goal_may_hold_opaque_types_jank(
197        &self,
198        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
199    ) -> bool;
200
201    /// Check whether evaluating `goal` with a depth of `root_depth` may
202    /// succeed. This only returns `false` if the goal is guaranteed to
203    /// not hold. In case evaluation overflows and fails with ambiguity this
204    /// returns `true`.
205    ///
206    /// This is only intended to be used as a performance optimization
207    /// in coherence checking.
208    fn root_goal_may_hold_with_depth(
209        &self,
210        root_depth: usize,
211        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
212    ) -> bool;
213
214    // FIXME: This is only exposed because we need to use it in `analyse.rs`
215    // which is not yet uplifted. Once that's done, we should remove this.
216    fn evaluate_root_goal_for_proof_tree(
217        &self,
218        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
219        span: <Self::Interner as Interner>::Span,
220    ) -> (
221        Result<NestedNormalizationGoals<Self::Interner>, NoSolution>,
222        inspect::GoalEvaluation<Self::Interner>,
223    );
224}
225
226impl<D, I> SolverDelegateEvalExt for D
227where
228    D: SolverDelegate<Interner = I>,
229    I: Interner,
230{
231    {}
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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(231u32),
                                ::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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:231",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(231u32),
                        ::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)]
232    fn evaluate_root_goal(
233        &self,
234        goal: Goal<I, I::Predicate>,
235        span: I::Span,
236        stalled_on: Option<GoalStalledOn<I>>,
237    ) -> Result<GoalEvaluation<I>, NoSolution> {
238        // Run fast paths *before* building an `EvalCtxt`, saving a little bit of time.
239        if let RerunStalled::WontMakeProgress(stalled_maybe_info) =
240            rerunning_stalled_goal_may_make_progress(self, stalled_on.as_ref())
241        {
242            return Ok(GoalEvaluation {
243                goal,
244                certainty: Certainty::Maybe(stalled_maybe_info),
245                has_changed: HasChanged::No,
246                stalled_on,
247            });
248        }
249
250        // No need to try the fast path if stalled_on is `None`, since we already try the fast path
251        // immediately when adding new goals. If we didn't check `stalled_on` here we'd be trying
252        // the fast path twice for some goals.
253        if stalled_on.is_some()
254            && let Some(res) = compute_goal_fast_path_cold(self, goal, span)
255        {
256            return Ok(res);
257        }
258
259        let mut result = EvalCtxt::enter_root(self, self.cx().recursion_limit(), span, |ecx| {
260            ecx.evaluate_goal_no_fast_paths(GoalSource::Misc, goal)
261        });
262        maybe_evaluate_root_goal_with_higher_recursion_limit(self, goal, span, &mut result);
263
264        match result {
265            Ok(i) => Ok(i),
266            Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) => Err(NoSolution),
267            Err(NoSolutionOrRerunNonErased::RerunNonErased(_)) => {
268                unreachable!("this never happens at the root, we're never in erased mode here");
269            }
270        }
271    }
272
273    // This function is very hot and has a single call site.
274    #[inline(always)]
275    fn goal_remains_stalled(&self, stalled_on: &GoalStalledOn<Self::Interner>) -> bool {
276        match inlined_rerunning_stalled_goal_may_make_progress(self, Some(stalled_on)) {
277            RerunStalled::WontMakeProgress(_) => true,
278            RerunStalled::MayMakeProgress => false,
279        }
280    }
281
282    {}
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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(282u32),
                                ::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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:282",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(282u32),
                        ::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)]
283    fn root_goal_may_hold_opaque_types_jank(
284        &self,
285        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
286    ) -> bool {
287        self.probe(|| {
288            self.evaluate_root_goal(goal, I::Span::dummy(), None).is_ok_and(|r| match r.certainty {
289                Certainty::Yes => true,
290                Certainty::Maybe(MaybeInfo {
291                    cause: _,
292                    opaque_types_jank,
293                    stalled_on_coroutines: _,
294                }) => match opaque_types_jank {
295                    OpaqueTypesJank::AllGood => true,
296                    OpaqueTypesJank::ErrorIfRigidSelfTy => false,
297                },
298            })
299        })
300    }
301
302    fn root_goal_may_hold_with_depth(
303        &self,
304        root_depth: usize,
305        goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
306    ) -> bool {
307        self.probe(|| {
308            EvalCtxt::enter_root(self, root_depth, I::Span::dummy(), |ecx| {
309                ecx.evaluate_goal(GoalSource::Misc, goal, None)
310            })
311        })
312        .is_ok()
313    }
314
315    {}
#[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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(315u32),
                                    ::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))]
316    fn evaluate_root_goal_for_proof_tree(
317        &self,
318        goal: Goal<I, I::Predicate>,
319        span: I::Span,
320    ) -> (Result<NestedNormalizationGoals<I>, NoSolution>, inspect::GoalEvaluation<I>) {
321        let mut result =
322            evaluate_root_goal_for_proof_tree(self, goal, span, self.cx().recursion_limit());
323        maybe_evaluate_root_goal_for_proof_tree_with_higher_recursion_limit(
324            self,
325            goal,
326            span,
327            &mut result,
328        );
329        result
330    }
331}
332
333/// The old solver doesn't check depth requirement when looking up cache while the next solver
334/// does so. Thus the next solver is more prone to overflow. To mitigate breakages, we re-evaluate
335/// the overflowed goal with doubled recursion limit and emit a FCW if doing so prevents overflow.
336///
337/// See the doc comment on `RECURSION_DEPTH_EXCEEDING_LIMIT` and #159228 for more details.
338fn maybe_evaluate_root_goal_with_higher_recursion_limit<D, I>(
339    delegate: &D,
340    goal: Goal<I, I::Predicate>,
341    span: I::Span,
342    initial_result: &mut Result<GoalEvaluation<I>, NoSolutionOrRerunNonErased>,
343) where
344    D: SolverDelegate<Interner = I>,
345    I: Interner,
346{
347    if !delegate.enable_next_solver_overflow_fcw() {
348        return;
349    }
350
351    let predicate = match initial_result {
352        Err(_) => return,
353        Ok(goal_evaluation) if !goal_evaluation.certainty.is_overflow() => return,
354        Ok(goal_evaluation) => goal_evaluation.goal.predicate,
355    };
356
357    let rerun_result = delegate.commit_if_ok(|| {
358        let rerun_result =
359            EvalCtxt::enter_root(delegate, delegate.cx().recursion_limit() * 2, span, |ecx| {
360                ecx.evaluate_goal_no_fast_paths(GoalSource::Misc, goal)
361            });
362
363        if rerun_result.as_ref().is_ok_and(|evaluation| evaluation.certainty.is_overflow()) {
364            Err(())
365        } else {
366            Ok(rerun_result)
367        }
368    });
369    if let Ok(rerun_result) = rerun_result {
370        delegate.emit_next_solver_overflow_fcw(goal.with(delegate.cx(), predicate), span);
371        *initial_result = rerun_result;
372    }
373}
374
375/// The old solver doesn't check depth requirement when looking up cache while the next solver
376/// does so. Thus the next solver is more prone to overflow. To mitigate breakages, we re-evaluate
377/// the overflowed goal with doubled recursion limit and emit a FCW if doing so prevents overflow.
378///
379/// See the doc comment on `RECURSION_DEPTH_EXCEEDING_LIMIT` and #159228 for more details.
380fn maybe_evaluate_root_goal_for_proof_tree_with_higher_recursion_limit<D, I>(
381    delegate: &D,
382    goal: Goal<I, I::Predicate>,
383    span: I::Span,
384    initial_result: &mut (
385        Result<NestedNormalizationGoals<I>, NoSolution>,
386        inspect::GoalEvaluation<I>,
387    ),
388) where
389    D: SolverDelegate<Interner = I>,
390    I: Interner,
391{
392    if !delegate.enable_next_solver_overflow_fcw() {
393        return;
394    }
395
396    let goal_evaluation = &initial_result.1;
397    match goal_evaluation.result {
398        Err(_) => return,
399        Ok(response) if !response.value.certainty.is_overflow() => return,
400        Ok(_) => {}
401    }
402
403    let rerun_result = delegate.commit_if_ok(|| {
404        let (new_result, new_goal_evaluation) = evaluate_root_goal_for_proof_tree(
405            delegate,
406            goal,
407            span,
408            delegate.cx().recursion_limit() * 2,
409        );
410
411        if new_goal_evaluation.result.is_ok_and(|response| response.value.certainty.is_overflow()) {
412            Err(())
413        } else {
414            Ok((new_result, new_goal_evaluation))
415        }
416    });
417    if let Ok(rerun_result) = rerun_result {
418        let predicate: I::Predicate = goal_evaluation.uncanonicalized_goal.predicate;
419        delegate.emit_next_solver_overflow_fcw(goal.with(delegate.cx(), predicate), span);
420        *initial_result = rerun_result;
421    }
422}
423
424impl<'a, D, I> EvalCtxt<'a, D>
425where
426    D: SolverDelegate<Interner = I>,
427    I: Interner,
428{
429    pub(super) fn typing_mode(&self) -> TypingMode<I> {
430        self.delegate.typing_mode_raw()
431    }
432
433    /// Computes the `PathKind` for the step from the current goal to the
434    /// nested goal. See #136824 for a more detailed reasoning for this why we care about
435    /// the step from a goal to its nested goals.
436    ///
437    /// For now we're entirely ignoring the reason why the current goal depends on the
438    /// nested goal and instead only depend on the current goal itself. This closely
439    /// matches the old solver. This is something we'll likely improve as we go forward
440    /// afterwards.
441    // FIXME(-Znext-solver=coinductive): Nothing interesting going on here right now
442    // and we're ignoring the goal source. We should change this going forward.
443    pub(super) fn step_kind_to_nested(&self, _source: GoalSource) -> PathKind {
444        match self.current_goal_kind {
445            // We currently consider a cycle involving a trait goal for a coinductive
446            // trait as coinductive as long as it otherwise only includes normalization.
447            CurrentGoalKind::CoinductiveTrait => PathKind::Coinductive,
448            // We do need to treat cycles involving only coinductive trait goals
449            // and normalization as coinductive due to trait-system-refactor-initiative#10.
450            CurrentGoalKind::ProjectionComputeAssocTermCandidate | CurrentGoalKind::Projection => {
451                PathKind::Unknown
452            }
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 => PathKind::ForcedAmbiguity,
457        }
458    }
459
460    /// Creates a root evaluation context and search graph. This should only be
461    /// used from outside of any evaluation, and other methods should be preferred
462    /// over using this manually (such as [`SolverDelegateEvalExt::evaluate_root_goal`]).
463    pub(super) fn enter_root<R>(
464        delegate: &D,
465        root_depth: usize,
466        origin_span: I::Span,
467        f: impl FnOnce(&mut EvalCtxt<'_, D>) -> R,
468    ) -> R {
469        let mut search_graph = SearchGraph::new(root_depth);
470
471        let mut ecx = EvalCtxt {
472            delegate,
473            search_graph: &mut search_graph,
474            nested_goals: Default::default(),
475            inspect: inspect::EvaluationStepBuilder::new_noop(),
476
477            // Only relevant when canonicalizing the response,
478            // which we don't do within this evaluation context.
479            max_input_universe: ty::UniverseIndex::ROOT,
480            initial_opaque_types_storage_num_entries: Default::default(),
481            var_kinds: Default::default(),
482            var_values: CanonicalVarValues::dummy(),
483            current_goal_kind: CurrentGoalKind::Misc,
484            origin_span,
485            tainted: Ok(()),
486            opaque_accesses: AccessedOpaques::default(),
487        };
488        let result = f(&mut ecx);
489        if !ecx.nested_goals.is_empty() {
    {
        ::core::panicking::panic_fmt(format_args!("root `EvalCtxt` should not have any goals added to it"));
    }
};assert!(
490            ecx.nested_goals.is_empty(),
491            "root `EvalCtxt` should not have any goals added to it"
492        );
493        if !!ecx.opaque_accesses.might_rerun() {
    ::core::panicking::panic("assertion failed: !ecx.opaque_accesses.might_rerun()")
};assert!(!ecx.opaque_accesses.might_rerun());
494        if !search_graph.is_empty() {
    ::core::panicking::panic("assertion failed: search_graph.is_empty()")
};assert!(search_graph.is_empty());
495        result
496    }
497
498    /// Creates a nested evaluation context that shares the same search graph as the
499    /// one passed in. This is suitable for evaluation, granted that the search graph
500    /// has had the nested goal recorded on its stack. This method only be used by
501    /// `search_graph::Delegate::compute_goal`.
502    ///
503    /// This function takes care of setting up the inference context, setting the anchor,
504    /// and registering opaques from the canonicalized input.
505    pub(super) fn enter_canonical<T>(
506        cx: I,
507        search_graph: &'a mut SearchGraph<D>,
508        canonical_input: I::CanonicalInput,
509        proof_tree_builder: &mut inspect::ProofTreeBuilder<D>,
510        f: impl FnOnce(
511            &mut EvalCtxt<'_, D>,
512            Goal<I, I::Predicate>,
513        ) -> Result<T, NoSolutionOrRerunNonErased>,
514    ) -> (Result<T, NoSolution>, AccessedOpaques<I>) {
515        let (ref delegate, input, var_values) = D::build_with_canonical(cx, &canonical_input);
516        for (key, ty) in input.predefined_opaques_in_body.iter() {
517            let prev = delegate.register_hidden_type_in_storage(key, ty, I::Span::dummy());
518            // It may be possible that two entries in the opaque type storage end up
519            // with the same key after resolving contained inference variables.
520            //
521            // We could put them in the duplicate list but don't have to. The opaques we
522            // encounter here are already tracked in the caller, so there's no need to
523            // also store them here. We'd take them out when computing the query response
524            // and then discard them, as they're already present in the input.
525            //
526            // Ideally we'd drop duplicate opaque type definitions when computing
527            // the canonical input. This is more annoying to implement and may cause a
528            // perf regression, so we do it inside of the query for now.
529            if let Some(prev) = prev {
530                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:530",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(530u32),
                        ::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`");
531            }
532        }
533
534        let initial_opaque_types_storage_num_entries = delegate.opaque_types_storage_num_entries();
535        if truecfg!(debug_assertions) && delegate.typing_mode_raw().is_erased_not_coherence() {
536            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());
537        }
538
539        let mut ecx = EvalCtxt {
540            delegate,
541            var_kinds: canonical_input.canonical.var_kinds,
542            var_values,
543            current_goal_kind: CurrentGoalKind::from_query_input(cx, input),
544            max_input_universe: canonical_input.canonical.max_universe,
545            initial_opaque_types_storage_num_entries,
546            search_graph,
547            nested_goals: Default::default(),
548            origin_span: I::Span::dummy(),
549            tainted: Ok(()),
550            inspect: proof_tree_builder.new_evaluation_step(var_values),
551            opaque_accesses: AccessedOpaques::default(),
552        };
553
554        let result = f(&mut ecx, input.goal);
555        ecx.inspect.probe_final_state(ecx.delegate, ecx.max_input_universe);
556        proof_tree_builder.finish_evaluation_step(ecx.inspect);
557
558        if canonical_input.typing_mode.0.is_erased_not_coherence() {
559            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());
560        }
561
562        // When creating a query response we clone the opaque type constraints
563        // instead of taking them. This would cause an ICE here, since we have
564        // assertions against dropping an `InferCtxt` without taking opaques.
565        // FIXME: Once we remove support for the old impl we can remove this.
566        // FIXME: Could we make `build_with_canonical` into `enter_with_canonical` and call this at the end?
567        delegate.reset_opaque_types();
568
569        let opaque_accesses = ecx.opaque_accesses;
570        (
571            match result {
572                Ok(i) => Ok(i),
573                Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) => Err(NoSolution),
574                Err(NoSolutionOrRerunNonErased::RerunNonErased(_)) => {
575                    // Check that the opaque_accesses state mirrors the result we got.
576                    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());
577                    Err(NoSolution)
578                }
579            },
580            opaque_accesses,
581        )
582    }
583
584    pub(super) fn ignore_candidate_head_usages(&mut self, usages: CandidateHeadUsages) {
585        self.search_graph.ignore_candidate_head_usages(usages);
586    }
587
588    /// Recursively evaluates `goal`, returning whether any inference vars have
589    /// been constrained and the certainty of the result.
590    fn evaluate_goal(
591        &mut self,
592        source: GoalSource,
593        goal: Goal<I, I::Predicate>,
594        stalled_on: Option<GoalStalledOn<I>>,
595    ) -> Result<GoalEvaluation<I>, NoSolutionOrRerunNonErased> {
596        if let RerunStalled::WontMakeProgress(stalled_maybe_info) =
597            rerunning_stalled_goal_may_make_progress(self.delegate, stalled_on.as_ref())
598        {
599            return Ok(GoalEvaluation {
600                goal,
601                certainty: Certainty::Maybe(stalled_maybe_info),
602                has_changed: HasChanged::No,
603                stalled_on,
604            });
605        }
606
607        // No need to try the fast path if stalled_on is `None`, since we already try the fast path
608        // immediately when adding new goals. If we didn't check `stalled_on` here we'd be trying
609        // the fast path twice for some goals.
610        if stalled_on.is_some()
611            && let Some(res) = compute_goal_fast_path_cold(self.delegate, goal, self.origin_span)
612        {
613            return Ok(res);
614        }
615
616        self.evaluate_goal_no_fast_paths(source, goal)
617    }
618
619    // Outlining and `#[cold]` matter here because fast paths make it less likely to get here.
620    #[cold]
621    #[inline(never)]
622    fn evaluate_goal_no_fast_paths(
623        &mut self,
624        source: GoalSource,
625        goal: Goal<I, I::Predicate>,
626    ) -> Result<GoalEvaluation<I>, NoSolutionOrRerunNonErased> {
627        let (normalization_nested_goals, goal_evaluation) = self.evaluate_goal_raw(source, goal)?;
628        if !normalization_nested_goals.is_empty() {
    ::core::panicking::panic("assertion failed: normalization_nested_goals.is_empty()")
};assert!(normalization_nested_goals.is_empty());
629        Ok(goal_evaluation)
630    }
631
632    fn evaluate_in_search_graph(
633        &mut self,
634        canonical_goal: I::CanonicalInput,
635        step_kind: PathKind,
636    ) -> (Result<CanonicalResponse<I>, NoSolution>, AccessedOpaques<I>) {
637        let increase_depth_for_nested =
638            match canonical_goal.canonical.value.goal.predicate.kind().skip_binder() {
639                // We don't lower the available depth for the `NormalizesTo` goal, as evaluating
640                // it is an extra step only exists in the new solver that behaves like a function
641                // call rather than an independent nested goal evaluation. So, decreasing the
642                // available depth may end up regressions which hit the recursion limits for crates
643                // compiled well with the old solver.
644                ty::PredicateKind::NormalizesTo(_) => LowerAvailableDepth::No,
645                // We also don't lower depth for witness and rigid opaque when proving auto traits.
646                // This is to mitigate the overflow FCW warnings in deeply nested async calls.
647                // See #159228.
648                //
649                // We're eventually going to remove the witness type so it's okay to ignore the
650                // depth.
651                // For rigid opaques, revealing hidden types can be viewed as normalization so it's
652                // consistent with the `NormalizesTo` reasoning above.
653                ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
654                    if self.cx().trait_is_auto(pred.trait_ref.def_id) {
655                        match pred.self_ty().kind() {
656                            ty::CoroutineWitness(..) => LowerAvailableDepth::No,
657                            ty::Alias(
658                                ty::IsRigid::Yes,
659                                ty::AliasTy { kind: ty::Opaque { def_id, .. }, .. },
660                            ) => {
661                                // We only want to skip lowering depth when the proving is done via
662                                // auto trait leakage. If the goal can be proved via item bounds,
663                                // we should lower depth faithfully.
664                                //
665                                // FIXME: We can have param env candidates via TAIT or RTN.
666                                // Ideally we'd instead lower the depth for the nested goal instead.
667                                // Implementing this is a bit harder.
668                                if self
669                                    .cx()
670                                    .item_self_bounds(def_id.into())
671                                    .skip_binder()
672                                    .into_iter()
673                                    .any(|bound| {
674                                        bound
675                                            .as_trait_clause()
676                                            .is_some_and(|b| b.def_id() == pred.def_id())
677                                    })
678                                {
679                                    LowerAvailableDepth::Yes
680                                } else {
681                                    LowerAvailableDepth::No
682                                }
683                            }
684                            ty::Bool
685                            | ty::Char
686                            | ty::Int(..)
687                            | ty::Uint(..)
688                            | ty::Float(..)
689                            | ty::Str
690                            | ty::Pat(..)
691                            | ty::FnPtr(..)
692                            | ty::Array(..)
693                            | ty::Slice(..)
694                            | ty::RawPtr(..)
695                            | ty::Never
696                            | ty::Tuple(..)
697                            | ty::UnsafeBinder(_)
698                            | ty::Param(..)
699                            | ty::Placeholder(..)
700                            | ty::Bound(..)
701                            | ty::Infer(..)
702                            | ty::Alias(_, _)
703                            | ty::Ref(_, _, _)
704                            | ty::Adt(_, _)
705                            | ty::Foreign(_)
706                            | ty::Dynamic(..)
707                            | ty::Error(_)
708                            | ty::FnDef(..)
709                            | ty::Closure(..)
710                            | ty::CoroutineClosure(..)
711                            | ty::Coroutine(..) => LowerAvailableDepth::Yes,
712                        }
713                    } else {
714                        LowerAvailableDepth::Yes
715                    }
716                }
717                ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(_))
718                | ty::PredicateKind::Clause(ty::ClauseKind::Projection(_))
719                | ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(_))
720                | ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(_))
721                | ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(_, _))
722                | ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_))
723                | ty::PredicateKind::Subtype(_)
724                | ty::PredicateKind::Coerce(_)
725                | ty::PredicateKind::DynCompatible(_)
726                | ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_))
727                | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(_))
728                | ty::PredicateKind::ConstEquate(_, _)
729                | ty::PredicateKind::Ambiguous => LowerAvailableDepth::Yes,
730            };
731        self.search_graph.evaluate_goal(
732            self.cx(),
733            canonical_goal,
734            step_kind,
735            increase_depth_for_nested,
736            &mut inspect::ProofTreeBuilder::new_noop(),
737        )
738    }
739
740    /// Recursively evaluates `goal`, returning the nested goals in case
741    /// the nested goal is a `NormalizesTo` goal.
742    ///
743    /// As all other goal kinds do not return any nested goals and
744    /// `NormalizesTo` is only used by `Projection`, all other callsites
745    /// should use [`EvalCtxt::evaluate_goal`] which discards that empty
746    /// storage.
747    pub(super) fn evaluate_goal_raw(
748        &mut self,
749        source: GoalSource,
750        goal: Goal<I, I::Predicate>,
751    ) -> Result<(NestedNormalizationGoals<I>, GoalEvaluation<I>), NoSolutionOrRerunNonErased> {
752        // We only care about one entry per `OpaqueTypeKey` here,
753        // so we only canonicalize the lookup table and ignore
754        // duplicate entries.
755        let opaque_types = self.delegate.clone_opaque_types_lookup_table();
756
757        let (goal, opaque_types) =
758            self.delegate.deeply_resolve_via_unification_table((goal, opaque_types));
759        let typing_mode = self.typing_mode();
760        let step_kind = self.step_kind_to_nested(source);
761
762        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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(762u32),
                        ::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!(
763            Level::DEBUG,
764            "evaluate_goal_raw in typing mode",
765            "{:?} opaques={:?}",
766            typing_mode,
767            opaque_types
768        )
769        .entered();
770
771        let (result, orig_values, canonical_goal, succeeded_in_erased) = 'retry_canonicalize: {
772            let skip_erased_attempt = match typing_mode {
773                TypingMode::Reflection | TypingMode::Coherence => true,
774                TypingMode::Typeck { .. }
775                | TypingMode::PostTypeckUntilBorrowck { .. }
776                | TypingMode::PostBorrowck { .. }
777                | TypingMode::Codegen
778                | TypingMode::PostAnalysis
779                | TypingMode::ErasedNotCoherence(_) => {
780                    let mut skip = false;
781                    if opaque_types.iter().any(|(_, ty)| ty.is_ty_var())
782                        && let PredicateKind::Clause(ClauseKind::Trait(..)) =
783                            goal.predicate.kind().skip_binder()
784                    {
785                        skip = true;
786                    }
787
788                    if let PredicateKind::Clause(ClauseKind::Trait(tr)) =
789                        goal.predicate.kind().skip_binder()
790                        && tr.self_ty().has_coroutines()
791                        && self.cx().trait_is_auto(tr.trait_ref.def_id)
792                    {
793                        // FIXME(#155443): this doesn't make a difference now, but with eager normalization
794                        // it likely will.
795                        // skip_erased_attempt = true;
796                    }
797
798                    skip
799                }
800            };
801
802            if skip_erased_attempt {
803                if typing_mode.is_erased_not_coherence() {
804                    match self.opaque_accesses.rerun_always(RerunReason::SkipErasedAttempt)? {}
805                } else {
806                    {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:806",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(806u32),
                        ::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");
807                }
808            } else {
809                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:809",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(809u32),
                        ::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:?}");
810
811                let (orig_values, canonical_goal) = canonicalize_goal(
812                    self.delegate,
813                    goal,
814                    &[],
815                    TypingMode::ErasedNotCoherence(MayBeErased),
816                );
817
818                let (canonical_result, accessed_opaques) =
819                    self.evaluate_in_search_graph(canonical_goal, step_kind);
820
821                let should_rerun = should_rerun_after_erased_canonicalization(
822                    accessed_opaques,
823                    self.typing_mode(),
824                    &opaque_types,
825                );
826                match should_rerun {
827                    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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:827",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(827u32),
                        ::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"),
828                    RerunDecision::No => {
829                        break 'retry_canonicalize (
830                            canonical_result,
831                            orig_values,
832                            canonical_goal,
833                            SucceededInErased::Yes { accessed_opaques },
834                        );
835                    }
836                    RerunDecision::EagerlyPropagateToParent => {
837                        self.opaque_accesses.update(accessed_opaques)?;
838                        break 'retry_canonicalize (
839                            canonical_result,
840                            orig_values,
841                            canonical_goal,
842                            // If we're propagating up, we should never retry the goal.
843                            // That means `No` is fine to return, it doesn't really matter.
844                            SucceededInErased::No,
845                        );
846                    }
847                }
848            }
849
850            let (orig_values, canonical_goal) =
851                canonicalize_goal(self.delegate, goal, &opaque_types, typing_mode);
852
853            let (canonical_result, accessed_opaques) =
854                self.evaluate_in_search_graph(canonical_goal, step_kind);
855            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!(
856                !accessed_opaques.might_rerun(),
857                "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:?}"
858            );
859
860            (canonical_result, orig_values, canonical_goal, SucceededInErased::No)
861        };
862
863        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:863",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(863u32),
                        ::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);
864        let response = match result {
865            Ok(response) => {
866                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:866",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(866u32),
                        ::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");
867                response
868            }
869            Err(NoSolution) => {
870                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:870",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(870u32),
                        ::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");
871                return Err(NoSolution.into());
872            }
873        };
874
875        drop(tracing_span);
876
877        let has_changed =
878            if !has_only_region_constraints(response) { HasChanged::Yes } else { HasChanged::No };
879
880        let (normalization_nested_goals, certainty) = instantiate_and_apply_query_response(
881            self.delegate,
882            &orig_values,
883            response,
884            self.origin_span,
885        );
886
887        // FIXME: We previously had an assert here that checked that recomputing
888        // a goal after applying its constraints did not change its response.
889        //
890        // This assert was removed as it did not hold for goals constraining
891        // an inference variable to a recursive alias, e.g. in
892        // tests/ui/traits/next-solver/overflow/recursive-self-normalization.rs.
893        //
894        // Once we have decided on how to handle trait-system-refactor-initiative#75,
895        // we should re-add an assert here.
896
897        let stalled_on = match certainty {
898            Certainty::Yes => None,
899            Certainty::Maybe(maybe_info) => match has_changed {
900                // FIXME: We could recompute a *new* set of stalled variables by walking
901                // through the orig values, resolving, and computing the root vars of anything
902                // that is not resolved. Only when *these* have changed is it meaningful
903                // to recompute this goal.
904                HasChanged::Yes => None,
905                HasChanged::No => Some(self.build_stalled_on(
906                    canonical_goal,
907                    maybe_info,
908                    orig_values,
909                    succeeded_in_erased,
910                )),
911            },
912        };
913
914        Ok((
915            normalization_nested_goals,
916            GoalEvaluation { goal, certainty, has_changed, stalled_on },
917        ))
918    }
919
920    fn build_stalled_on(
921        &self,
922        canonical_goal: I::CanonicalInput,
923        maybe_info: MaybeInfo,
924        stalled_vars: ThinVec<I::GenericArg>,
925        previously_succeeded_in_erased: SucceededInErased<I>,
926    ) -> GoalStalledOn<I> {
927        // Remove the canonicalized universal vars, since we only care about stalled existentials.
928        let mut sub_roots = ThinVec::new();
929        let stalled_vars = stalled_vars
930            .into_iter()
931            .filter_map(|arg| match arg.kind() {
932                // Lifetimes can never stall goals.
933                ty::GenericArgKind::Lifetime(_) => None,
934                ty::GenericArgKind::Type(ty) => match ty.kind() {
935                    ty::Infer(ty::TyVar(vid)) => {
936                        sub_roots.push(self.delegate.sub_unification_table_root_var(vid));
937                        Some(TyOrConstInferVar::Ty(vid))
938                    }
939                    ty::Infer(ty::IntVar(vid)) => Some(TyOrConstInferVar::TyInt(vid)),
940                    ty::Infer(ty::FloatVar(vid)) => Some(TyOrConstInferVar::TyFloat(vid)),
941                    ty::Param(_) | ty::Placeholder(_) => None,
942                    _ => {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("unexpected orig_value: {0:?}", ty)));
}unreachable!("unexpected orig_value: {ty:?}"),
943                },
944                ty::GenericArgKind::Const(ct) => match ct.kind() {
945                    ty::ConstKind::Infer(ty::InferConst::Var(v)) => {
946                        Some(TyOrConstInferVar::Const(v))
947                    }
948                    ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(_) => None,
949                    _ => {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("unexpected orig_value: {0:?}", ct)));
}unreachable!("unexpected orig_value: {ct:?}"),
950                },
951            })
952            .collect();
953
954        GoalStalledOn {
955            stalled_vars,
956            sub_roots,
957            stalled_maybe_info: maybe_info,
958            opaques: GoalStalledOnOpaques::Yes {
959                num_opaques_in_storage: canonical_goal
960                    .canonical
961                    .value
962                    .predefined_opaques_in_body
963                    .len(),
964                previously_succeeded_in_erased,
965            },
966        }
967    }
968
969    pub(super) fn compute_goal(
970        &mut self,
971        goal: Goal<I, I::Predicate>,
972    ) -> QueryResultOrRerunNonErased<I> {
973        let Goal { param_env, predicate } = goal;
974        let kind = predicate.kind();
975        self.enter_forall_with_assumptions(kind, param_env, |ecx, kind| {
976            Ok(match kind {
977                ty::PredicateKind::Clause(ty::ClauseKind::Trait(predicate)) => {
978                    ecx.compute_trait_goal(Goal { param_env, predicate }).map(|(r, _via)| r)?
979                }
980                ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(predicate)) => {
981                    ecx.compute_host_effect_goal(Goal { param_env, predicate })?
982                }
983                ty::PredicateKind::Clause(ty::ClauseKind::Projection(predicate)) => {
984                    ecx.compute_projection_goal(Goal { param_env, predicate })?
985                }
986                ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(predicate)) => {
987                    ecx.compute_type_outlives_goal(Goal { param_env, predicate })?
988                }
989                ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(predicate)) => {
990                    ecx.compute_region_outlives_goal(Goal { param_env, predicate })?
991                }
992                ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
993                    ecx.compute_const_arg_has_type_goal(Goal { param_env, predicate: (ct, ty) })?
994                }
995                ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
996                    ecx.compute_unstable_feature_goal(param_env, symbol)?
997                }
998                ty::PredicateKind::Subtype(predicate) => {
999                    ecx.compute_subtype_goal(Goal { param_env, predicate })?
1000                }
1001                ty::PredicateKind::Coerce(predicate) => {
1002                    ecx.compute_coerce_goal(Goal { param_env, predicate })?
1003                }
1004                ty::PredicateKind::DynCompatible(trait_def_id) => {
1005                    ecx.compute_dyn_compatible_goal(trait_def_id)?
1006                }
1007                ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
1008                    ecx.compute_well_formed_goal(Goal { param_env, predicate: term })?
1009                }
1010                ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(ct)) => {
1011                    ecx.compute_const_evaluatable_goal(Goal { param_env, predicate: ct })?
1012                }
1013                ty::PredicateKind::ConstEquate(_, _) => {
1014                    {
    ::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")
1015                }
1016                ty::PredicateKind::NormalizesTo(predicate) => {
1017                    ecx.compute_normalizes_to_goal(Goal { param_env, predicate })?
1018                }
1019                ty::PredicateKind::Ambiguous => {
1020                    ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)?
1021                }
1022            })
1023        })
1024    }
1025
1026    // Recursively evaluates all the goals added to this `EvalCtxt` to completion, returning
1027    // the certainty of all the goals.
1028    {}
#[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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1028u32),
                                    ::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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1043",
                                    "rustc_next_trait_solver::solve::eval_ctxt",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1043u32),
                                    ::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))]
1029    pub(super) fn try_evaluate_added_goals(
1030        &mut self,
1031    ) -> Result<Certainty, NoSolutionOrRerunNonErased> {
1032        for _ in 0..FIXPOINT_STEP_LIMIT {
1033            match self.evaluate_added_goals_step().map_err_to_rerun()? {
1034                Ok(None) => {}
1035                Ok(Some(cert)) => return Ok(cert),
1036                Err(NoSolution) => {
1037                    self.tainted = Err(NoSolution);
1038                    return Err(NoSolution.into());
1039                }
1040            }
1041        }
1042
1043        debug!("try_evaluate_added_goals: encountered overflow");
1044        Ok(Certainty::overflow(false))
1045    }
1046
1047    /// Iterate over all added goals: returning `Ok(Some(_))` in case we can stop rerunning.
1048    ///
1049    /// Goals for the next step get directly added to the nested goals of the `EvalCtxt`.
1050    fn evaluate_added_goals_step(
1051        &mut self,
1052    ) -> Result<Option<Certainty>, NoSolutionOrRerunNonErased> {
1053        // If this loop did not result in any progress, what's our final certainty.
1054        let mut unchanged_certainty = Some(Certainty::Yes);
1055        // This mem::take seems super inefficient, given that we push to it again later.
1056        // Despite that, replacing it has no effect on performance. We tried.
1057        // (https://github.com/rust-lang/rust/pull/158126)
1058        for (source, goal, stalled_on) in mem::take(&mut self.nested_goals) {
1059            // We never handle `NormalizesTo` as a nested goal
1060            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!(
1061                goal.predicate.kind().skip_binder(),
1062                PredicateKind::NormalizesTo(_)
1063            ));
1064
1065            let GoalEvaluation { goal, certainty, has_changed, stalled_on } =
1066                self.evaluate_goal(source, goal, stalled_on)?;
1067            if has_changed == HasChanged::Yes {
1068                unchanged_certainty = None;
1069            }
1070
1071            match certainty {
1072                Certainty::Yes => {}
1073                Certainty::Maybe { .. } => {
1074                    self.nested_goals.push((source, goal, stalled_on));
1075                    unchanged_certainty = unchanged_certainty.map(|c| c.and(certainty));
1076                }
1077            }
1078        }
1079
1080        Ok(unchanged_certainty)
1081    }
1082
1083    /// Record impl args in the proof tree for later access by `InspectCandidate`.
1084    pub(crate) fn record_impl_args(&mut self, impl_args: I::GenericArgs) {
1085        self.inspect.record_impl_args(self.delegate, self.max_input_universe, impl_args)
1086    }
1087
1088    pub(super) fn cx(&self) -> I {
1089        self.delegate.cx()
1090    }
1091
1092    {}
#[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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1092u32),
                                    ::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(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))]
1093    pub(super) fn add_goal(
1094        &mut self,
1095        source: GoalSource,
1096        mut goal: Goal<I, I::Predicate>,
1097    ) -> Result<(), NoSolutionOrRerunNonErased> {
1098        goal.predicate =
1099            self.normalize(goal.param_env, ty::Unnormalized::new_wip(goal.predicate))?;
1100        self.inspect.add_goal(self.delegate, self.max_input_universe, source, goal);
1101
1102        if let Some(GoalEvaluation { goal, certainty, has_changed: _, stalled_on }) =
1103            compute_goal_fast_path(self.delegate, goal, self.origin_span)
1104        {
1105            match certainty {
1106                // We're done here
1107                Certainty::Yes => {}
1108                Certainty::Maybe(_) => {
1109                    self.nested_goals.push((source, goal, stalled_on));
1110                }
1111            }
1112        } else {
1113            self.nested_goals.push((source, goal, None));
1114        }
1115        Ok(())
1116    }
1117
1118    {}
#[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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1118u32),
                                    ::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))]
1119    pub(super) fn add_goals(
1120        &mut self,
1121        source: GoalSource,
1122        goals: impl IntoIterator<Item = Goal<I, I::Predicate>>,
1123    ) -> Result<(), NoSolutionOrRerunNonErased> {
1124        for goal in goals {
1125            self.add_goal(source, goal)?;
1126        }
1127        Ok(())
1128    }
1129
1130    pub(super) fn next_region_var(&mut self) -> Region<I> {
1131        let region = self.delegate.next_region_infer();
1132        self.inspect.add_var_value(region);
1133        region
1134    }
1135
1136    pub(super) fn next_ty_infer(&mut self) -> I::Ty {
1137        let ty = self.delegate.next_ty_infer();
1138        self.inspect.add_var_value(ty);
1139        ty
1140    }
1141
1142    pub(super) fn next_const_infer(&mut self) -> Const<I> {
1143        let ct = self.delegate.next_const_infer();
1144        self.inspect.add_var_value(ct);
1145        ct
1146    }
1147
1148    /// Returns a ty infer or a const infer depending on whether `kind` is a `Ty` or `Const`.
1149    /// If `kind` is an integer inference variable this will still return a ty infer var.
1150    pub(super) fn next_term_infer_of_alias_kind(
1151        &mut self,
1152        alias_term: ty::AliasTerm<I>,
1153    ) -> I::Term {
1154        match alias_term.kind {
1155            ty::AliasTermKind::ProjectionTy { .. }
1156            | ty::AliasTermKind::InherentTy { .. }
1157            | ty::AliasTermKind::OpaqueTy { .. }
1158            | ty::AliasTermKind::FreeTy { .. } => self.next_ty_infer().into(),
1159            ty::AliasTermKind::FreeConst { .. }
1160            | ty::AliasTermKind::InherentConstSelf { .. }
1161            | ty::AliasTermKind::InherentConstImpl { .. }
1162            | ty::AliasTermKind::AnonConst { .. }
1163            | ty::AliasTermKind::ProjectionConst { .. } => self.next_const_infer().into(),
1164        }
1165    }
1166
1167    /// Is the projection predicate is of the form `exists<T> <Ty as Trait>::Assoc = T`.
1168    ///
1169    /// This is the case if the `term` does not occur in any other part of the predicate
1170    /// and is able to name all other placeholder and inference variables.
1171    {}
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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1171u32),
                                ::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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1171",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1171u32),
                        ::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)]
1172    pub(super) fn term_is_fully_unconstrained(&self, goal: Goal<I, ty::NormalizesTo<I>>) -> bool {
1173        let universe_of_term = match goal.predicate.term.kind() {
1174            ty::TermKind::Ty(ty) => {
1175                if let ty::Infer(ty::TyVar(vid)) = ty.kind() {
1176                    self.delegate.universe_of_ty(vid).unwrap()
1177                } else {
1178                    return false;
1179                }
1180            }
1181            ty::TermKind::Const(ct) => {
1182                if let ty::ConstKind::Infer(ty::InferConst::Var(vid)) = ct.kind() {
1183                    self.delegate.universe_of_const(vid).unwrap()
1184                } else {
1185                    return false;
1186                }
1187            }
1188        };
1189
1190        struct ContainsTermOrNotNameable<'a, D: SolverDelegate<Interner = I>, I: Interner> {
1191            term: I::Term,
1192            universe_of_term: ty::UniverseIndex,
1193            delegate: &'a D,
1194            cache: HashSet<I::Ty>,
1195        }
1196
1197        impl<D: SolverDelegate<Interner = I>, I: Interner> ContainsTermOrNotNameable<'_, D, I> {
1198            fn check_nameable(&self, universe: ty::UniverseIndex) -> ControlFlow<()> {
1199                if self.universe_of_term.can_name(universe) {
1200                    ControlFlow::Continue(())
1201                } else {
1202                    ControlFlow::Break(())
1203                }
1204            }
1205        }
1206
1207        impl<D: SolverDelegate<Interner = I>, I: Interner> TypeVisitor<I>
1208            for ContainsTermOrNotNameable<'_, D, I>
1209        {
1210            type Result = ControlFlow<()>;
1211            fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
1212                if self.cache.contains(&t) {
1213                    return ControlFlow::Continue(());
1214                }
1215
1216                match t.kind() {
1217                    ty::Infer(ty::TyVar(vid)) => {
1218                        if let ty::TermKind::Ty(term) = self.term.kind()
1219                            && let ty::Infer(ty::TyVar(term_vid)) = term.kind()
1220                            && self.delegate.root_ty_var(vid) == self.delegate.root_ty_var(term_vid)
1221                        {
1222                            return ControlFlow::Break(());
1223                        }
1224
1225                        self.check_nameable(self.delegate.universe_of_ty(vid).unwrap())?;
1226                    }
1227                    ty::Placeholder(p) => self.check_nameable(p.universe())?,
1228                    _ => {
1229                        if t.has_non_region_infer() || t.has_placeholders() {
1230                            t.super_visit_with(self)?
1231                        }
1232                    }
1233                }
1234
1235                assert!(self.cache.insert(t));
1236                ControlFlow::Continue(())
1237            }
1238
1239            fn visit_const(&mut self, c: Const<I>) -> Self::Result {
1240                match c.kind() {
1241                    ty::ConstKind::Infer(ty::InferConst::Var(vid)) => {
1242                        if let ty::TermKind::Const(term) = self.term.kind()
1243                            && let ty::ConstKind::Infer(ty::InferConst::Var(term_vid)) = term.kind()
1244                            && self.delegate.root_const_var(vid)
1245                                == self.delegate.root_const_var(term_vid)
1246                        {
1247                            return ControlFlow::Break(());
1248                        }
1249
1250                        self.check_nameable(self.delegate.universe_of_const(vid).unwrap())
1251                    }
1252                    ty::ConstKind::Placeholder(p) => self.check_nameable(p.universe()),
1253                    _ => {
1254                        if c.has_non_region_infer() || c.has_placeholders() {
1255                            c.super_visit_with(self)
1256                        } else {
1257                            ControlFlow::Continue(())
1258                        }
1259                    }
1260                }
1261            }
1262
1263            fn visit_predicate<P: PredicateProxy<I>>(&mut self, p: P) -> Self::Result {
1264                if p.has_non_region_infer() || p.has_placeholders() {
1265                    p.super_visit_with(self)
1266                } else {
1267                    ControlFlow::Continue(())
1268                }
1269            }
1270
1271            fn visit_clauses(&mut self, c: I::Clauses) -> Self::Result {
1272                if c.has_non_region_infer() || c.has_placeholders() {
1273                    c.super_visit_with(self)
1274                } else {
1275                    ControlFlow::Continue(())
1276                }
1277            }
1278        }
1279
1280        let mut visitor = ContainsTermOrNotNameable {
1281            delegate: self.delegate,
1282            universe_of_term,
1283            term: goal.predicate.term,
1284            cache: Default::default(),
1285        };
1286        goal.predicate.alias.visit_with(&mut visitor).is_continue()
1287            && goal.param_env.visit_with(&mut visitor).is_continue()
1288    }
1289
1290    pub(super) fn sub_unify_ty_vids_raw(&self, a: ty::TyVid, b: ty::TyVid) {
1291        self.delegate.sub_unify_ty_vids_raw(a, b)
1292    }
1293
1294    {}
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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1294u32),
                                ::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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1294",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1294u32),
                        ::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)]
1295    pub(super) fn eq<T: Relate<I>>(
1296        &mut self,
1297        param_env: I::ParamEnv,
1298        lhs: T,
1299        rhs: T,
1300    ) -> Result<(), NoSolutionOrRerunNonErased> {
1301        self.relate(param_env, lhs, ty::Variance::Invariant, rhs)
1302    }
1303
1304    {}
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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1304u32),
                                ::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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1304",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1304u32),
                        ::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)]
1305    pub(super) fn sub<T: Relate<I>>(
1306        &mut self,
1307        param_env: I::ParamEnv,
1308        sub: T,
1309        sup: T,
1310    ) -> Result<(), NoSolutionOrRerunNonErased> {
1311        self.relate(param_env, sub, ty::Variance::Covariant, sup)
1312    }
1313
1314    {}
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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1314u32),
                                ::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::Clause(ty::ClauseKind::Projection(..)) =>
                                        {
                                        GoalSource::Normalization
                                    }
                                    ty::PredicateKind::Subtype { .. } => GoalSource::Misc,
                                    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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1314",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1314u32),
                        ::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)]
1315    pub(super) fn relate<T: Relate<I>>(
1316        &mut self,
1317        param_env: I::ParamEnv,
1318        lhs: T,
1319        variance: ty::Variance,
1320        rhs: T,
1321    ) -> Result<(), NoSolutionOrRerunNonErased> {
1322        let goals = self.delegate.relate(param_env, lhs, variance, rhs, self.origin_span)?;
1323        for &goal in goals.iter() {
1324            let source = match goal.predicate.kind().skip_binder() {
1325                ty::PredicateKind::Clause(ty::ClauseKind::Projection(..)) => {
1326                    GoalSource::Normalization
1327                }
1328                // FIXME(-Znext-solver=coinductive): subtyping goals should
1329                // likely be unproductive
1330                ty::PredicateKind::Subtype { .. } => GoalSource::Misc,
1331                // FIXME(-Znext-solver=coinductive): should these WF goals also be unproductive?
1332                ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => GoalSource::Misc,
1333                p => unreachable!("unexpected nested goal in `relate`: {p:?}"),
1334            };
1335            self.add_goal(source, goal)?;
1336        }
1337        Ok(())
1338    }
1339
1340    /// Equates two values returning the nested goals without adding them
1341    /// to the nested goals of the `EvalCtxt`.
1342    ///
1343    /// If possible, try using `eq` instead which automatically handles nested
1344    /// goals correctly.
1345    {}
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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1345u32),
                                ::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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1345",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1345u32),
                        ::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)]
1346    pub(super) fn eq_and_get_goals<T: Relate<I>>(
1347        &self,
1348        param_env: I::ParamEnv,
1349        lhs: T,
1350        rhs: T,
1351    ) -> Result<Vec<Goal<I, I::Predicate>>, NoSolution> {
1352        Ok(self.delegate.relate(param_env, lhs, ty::Variance::Invariant, rhs, self.origin_span)?)
1353    }
1354
1355    pub(super) fn instantiate_binder_with_infer<T: TypeFoldable<I> + Copy>(
1356        &self,
1357        value: ty::Binder<I, T>,
1358    ) -> T {
1359        self.delegate.instantiate_binder_with_infer(value)
1360    }
1361
1362    /// `enter_forall_with_assumptions`, but takes `&mut self` and passes it back through
1363    /// the callback since it can't be aliased during the call.
1364    ///
1365    /// The `param_env` is used to *compute* the assumptions of the binder, not *as* the
1366    /// assumptions associated with the binder.
1367    ///
1368    /// FIXME(inherent_associated_types): fix this?
1369    pub(super) fn enter_forall_with_assumptions<T: TypeFoldable<I>, U>(
1370        &mut self,
1371        value: ty::Binder<I, T>,
1372        param_env: I::ParamEnv,
1373        f: impl FnOnce(&mut Self, T) -> U,
1374    ) -> U {
1375        self.delegate.enter_forall_without_assumptions(value, |value| {
1376            // Invariant: we shouldn't insert empty assumptions if assumptions computation fails.
1377            // When handling placeholder constraints, we rely on vacancies to force ambiguity.
1378            let u = self.delegate.universe();
1379            if self.cx().assumptions_on_binders()
1380                && let Some(assumptions) = self.region_assumptions_for_placeholders_in_universe(
1381                    value.clone(),
1382                    u,
1383                    param_env,
1384                )
1385            {
1386                self.delegate.insert_placeholder_assumptions(u, assumptions);
1387            }
1388
1389            f(self, value)
1390        })
1391    }
1392
1393    pub(super) fn deeply_resolve_ignoring_regions<T>(&self, value: T) -> T
1394    where
1395        T: TypeFoldable<I>,
1396    {
1397        self.delegate.deeply_resolve_ignoring_regions(value)
1398    }
1399
1400    pub(super) fn shallow_resolve(&self, ty: I::Ty) -> I::Ty {
1401        self.delegate.shallow_resolve(ty)
1402    }
1403
1404    pub(super) fn eager_resolve_region(&self, r: Region<I>) -> Region<I> {
1405        if let ty::ReVar(vid) = r.kind() {
1406            self.delegate.shallow_resolve_region_var(vid)
1407        } else {
1408            r
1409        }
1410    }
1411
1412    pub(super) fn fresh_args_for_item(&mut self, def_id: I::DefId) -> I::GenericArgs {
1413        let args = self.delegate.fresh_args_for_item(def_id);
1414        for arg in args.iter() {
1415            self.inspect.add_var_value(arg);
1416        }
1417        args
1418    }
1419
1420    pub(super) fn register_solver_region_constraint(&self, c: RegionConstraint<I>) {
1421        self.delegate.register_solver_region_constraint(c, self.origin_span);
1422    }
1423
1424    pub(super) fn register_ty_outlives(&self, ty: I::Ty, lt: Region<I>) {
1425        self.delegate.register_ty_outlives(ty, lt, self.origin_span);
1426    }
1427
1428    pub(super) fn register_region_outlives(
1429        &self,
1430        a: Region<I>,
1431        b: Region<I>,
1432        vis: VisibleForLeakCheck,
1433    ) {
1434        // `'a: 'b` ==> `'b <= 'a`
1435        self.delegate.sub_regions(b, a, vis, self.origin_span);
1436    }
1437
1438    /// Computes the list of goals required for `arg` to be well-formed
1439    pub(super) fn well_formed_goals(
1440        &self,
1441        param_env: I::ParamEnv,
1442        term: I::Term,
1443    ) -> Option<Vec<Goal<I, I::Predicate>>> {
1444        self.delegate.well_formed_goals(param_env, term)
1445    }
1446
1447    pub(super) fn trait_ref_is_knowable(
1448        &mut self,
1449        param_env: I::ParamEnv,
1450        trait_ref: ty::TraitRef<I>,
1451    ) -> Result<bool, NoSolutionOrRerunNonErased> {
1452        let delegate = self.delegate;
1453        let lazily_normalize_ty = |ty| self.structurally_normalize_ty(param_env, ty);
1454        coherence::trait_ref_is_knowable(&**delegate, trait_ref, lazily_normalize_ty)
1455            .map(|is_knowable| is_knowable.is_ok())
1456    }
1457
1458    pub(super) fn fetch_eligible_assoc_item(
1459        &self,
1460        goal_trait_ref: ty::TraitRef<I>,
1461        trait_assoc_def_id: I::TraitAssocTermId,
1462        impl_def_id: I::ImplId,
1463    ) -> FetchEligibleAssocItemResponse<I> {
1464        self.delegate.fetch_eligible_assoc_item(goal_trait_ref, trait_assoc_def_id, impl_def_id)
1465    }
1466
1467    {}
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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1467u32),
                                ::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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1467",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1467u32),
                        ::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)]
1468    pub(super) fn register_hidden_type_in_storage(
1469        &mut self,
1470        opaque_type_key: ty::OpaqueTypeKey<I>,
1471        hidden_ty: I::Ty,
1472    ) -> Option<I::Ty> {
1473        self.delegate.register_hidden_type_in_storage(opaque_type_key, hidden_ty, self.origin_span)
1474    }
1475
1476    pub(super) fn add_item_bounds_for_hidden_type(
1477        &mut self,
1478        opaque_def_id: I::OpaqueTyId,
1479        opaque_args: I::GenericArgs,
1480        param_env: I::ParamEnv,
1481        hidden_ty: I::Ty,
1482    ) -> Result<(), NoSolutionOrRerunNonErased> {
1483        let mut goals = Vec::new();
1484        self.delegate.add_item_bounds_for_hidden_type(
1485            opaque_def_id,
1486            opaque_args,
1487            param_env,
1488            hidden_ty,
1489            &mut goals,
1490        );
1491        self.add_goals(GoalSource::AliasWellFormed, goals)?;
1492        Ok(())
1493    }
1494
1495    // Try to evaluate a const and normalize the type of the resulting value, or return `None` if
1496    // the const is too generic. This doesn't mean the const isn't evaluatable, though, and should
1497    // be treated as an ambiguity rather than no-solution.
1498    pub(super) fn evaluate_const(
1499        &mut self,
1500        param_env: I::ParamEnv,
1501        alias_const: ty::AliasConst<I>,
1502    ) -> Result<Option<Const<I>>, NoSolutionOrRerunNonErased> {
1503        if self.typing_mode().is_erased_not_coherence() {
1504            let resolved = self.deeply_resolve_ignoring_regions(alias_const);
1505            // FIXME: get rid of this once GCE is removed
1506            let is_gce = self.cx().features().generic_const_exprs();
1507            if resolved.has_opaque_types() || is_gce {
1508                match self.opaque_accesses.rerun_always(RerunReason::EvaluateConst)? {}
1509            }
1510        }
1511
1512        self.delegate.evaluate_const(param_env, alias_const, |ty| self.normalize(param_env, ty))
1513    }
1514
1515    pub(super) fn evaluate_const_and_instantiate_projection_term(
1516        &mut self,
1517        param_env: I::ParamEnv,
1518        projection_term: ty::AliasTerm<I>,
1519        expected_term: I::Term,
1520        alias_const: ty::AliasConst<I>,
1521    ) -> QueryResultOrRerunNonErased<I> {
1522        match self.evaluate_const(param_env, alias_const)? {
1523            Some(evaluated) => {
1524                self.eq(param_env, expected_term, evaluated.into())?;
1525                self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
1526            }
1527            None if self.cx().features().gca_const_items() => {
1528                // HACK(khyperia): calling `deeply_resolve_ignoring_regions` here shouldn't be necessary,
1529                // `try_evaluate_const` calls `deeply_resolve_ignoring_regions` already. However, we want
1530                // to check `has_non_region_infer` against the type with vars resolved (i.e. check
1531                // if there are vars we failed to resolve), so we need to call it again here.
1532                // Perhaps we could split EvaluateConstErr::HasGenericsOrInfers into HasGenerics and
1533                // HasInfers or something, make evaluate_const return that, and make this branch be
1534                // based on that, rather than checking `has_non_region_infer`.
1535                if self.deeply_resolve_ignoring_regions(alias_const).has_non_region_infer() {
1536                    self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
1537                } else {
1538                    // Evaluation failed because the const was too generic or was an invalid type
1539                    // for const generics. The result of normalization is the alias itself,
1540                    // unchanged, but marked as rigid.
1541                    //
1542                    // We do not instantiate to the `alias_const` passed in, but rather
1543                    // `projection_term`, which is the unprocessed, original alias contained within
1544                    // the goal. The `alias_const` passed in might be a Projection whose DefId is an
1545                    // impl of the trait, however, we want to structurally instantiate to the
1546                    // original DefId on the trait itself.
1547                    self.eq(
1548                        param_env,
1549                        projection_term.to_term(self.cx(), ty::IsRigid::Yes),
1550                        expected_term,
1551                    )?;
1552                    self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
1553                }
1554            }
1555            None => {
1556                // Legacy behavior: always treat as ambiguous
1557                self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
1558            }
1559        }
1560    }
1561
1562    pub(super) fn is_transmutable(
1563        &mut self,
1564        src: I::Ty,
1565        dst: I::Ty,
1566        assume: Const<I>,
1567    ) -> Result<Certainty, NoSolution> {
1568        self.delegate.is_transmutable(dst, src, assume)
1569    }
1570
1571    pub(super) fn replace_bound_vars<T: TypeFoldable<I>>(
1572        &self,
1573        t: T,
1574        universes: &mut Vec<Option<ty::UniverseIndex>>,
1575    ) -> T {
1576        BoundVarReplacer::replace_bound_vars(&**self.delegate, universes, t).0
1577    }
1578
1579    pub(super) fn may_use_unstable_feature(
1580        &mut self,
1581        param_env: I::ParamEnv,
1582        symbol: I::Symbol,
1583    ) -> Result<bool, RerunNonErased> {
1584        if self.typing_mode().is_erased_not_coherence() {
1585            match self.opaque_accesses.rerun_always(RerunReason::MayUseUnstableFeature)? {}
1586        }
1587
1588        Ok(may_use_unstable_feature(&**self.delegate, param_env, symbol))
1589    }
1590
1591    pub(crate) fn opaques_with_sub_unified_hidden_type(
1592        &self,
1593        self_ty: I::Ty,
1594    ) -> Vec<ty::OpaqueAliasTy<I>> {
1595        if let ty::Infer(ty::TyVar(vid)) = self_ty.kind() {
1596            self.delegate.opaques_with_sub_unified_hidden_type(vid)
1597        } else {
1598            ::alloc::vec::Vec::new()vec![]
1599        }
1600    }
1601
1602    /// To return the constraints of a canonical query to the caller, we canonicalize:
1603    ///
1604    /// - `var_values`: a map from bound variables in the canonical goal to
1605    ///   the values inferred while solving the instantiated goal.
1606    /// - `external_constraints`: additional constraints which aren't expressible
1607    ///   using simple unification of inference variables.
1608    ///
1609    /// This takes the `shallow_certainty` which represents whether we're confident
1610    /// that the final result of the current goal only depends on the nested goals.
1611    ///
1612    /// In case this is `Certainty::Maybe`, there may still be additional nested goals
1613    /// or inference constraints required for this candidate to be hold. The candidate
1614    /// always requires all already added constraints and nested goals.
1615    {}
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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1615u32),
                                ::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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1639",
                                                                            "rustc_next_trait_solver::solve::eval_ctxt",
                                                                            ::tracing::Level::TRACE,
                                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                                                            ::tracing_core::__macro_support::Option::Some(1639u32),
                                                                            ::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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1615",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1615u32),
                        ::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)]
1616    pub(in crate::solve) fn evaluate_added_goals_and_make_canonical_response(
1617        &mut self,
1618        shallow_certainty: Certainty,
1619    ) -> QueryResultOrRerunNonErased<I> {
1620        self.inspect.make_canonical_response(shallow_certainty);
1621
1622        let goals_certainty = self.try_evaluate_added_goals()?;
1623        assert_eq!(
1624            self.tainted,
1625            Ok(()),
1626            "EvalCtxt is tainted -- nested goals may have been dropped in a \
1627            previous call to `try_evaluate_added_goals!`"
1628        );
1629
1630        let goals_certainty = match self.delegate.cx().assumptions_on_binders() {
1631            true => {
1632                let certainty = self.eagerly_handle_placeholders()?;
1633                certainty.and(goals_certainty)
1634            }
1635            false => {
1636                // We only check for leaks from universes which were entered inside
1637                // of the query.
1638                self.delegate.leak_check(self.max_input_universe).map_err(|NoSolution| {
1639                    trace!("failed the leak check");
1640                    NoSolution
1641                })?;
1642
1643                goals_certainty
1644            }
1645        };
1646
1647        let (certainty, normalization_nested_goals) =
1648            match (self.current_goal_kind, shallow_certainty) {
1649                // When normalizing, we've replaced the expected term with an unconstrained
1650                // inference variable. This means that we dropped information which could
1651                // have been important. We handle this by instead returning the nested goals
1652                // to the caller, where they are then handled. We only do so if we do not
1653                // need to recompute the `NormalizesTo` goal afterwards to avoid repeatedly
1654                // uplifting its nested goals. This is the case if the `shallow_certainty` is
1655                // `Certainty::Yes`.
1656                (CurrentGoalKind::ProjectionComputeAssocTermCandidate, Certainty::Yes) => {
1657                    let goals = std::mem::take(&mut self.nested_goals);
1658                    // As we return all ambiguous nested goals, we can ignore the certainty
1659                    // returned by `self.try_evaluate_added_goals()`.
1660                    if goals.is_empty() {
1661                        assert!(matches!(goals_certainty, Certainty::Yes));
1662                    }
1663                    (
1664                        Certainty::Yes,
1665                        NestedNormalizationGoals(
1666                            goals.into_iter().map(|(s, g, _)| (s, g)).collect(),
1667                        ),
1668                    )
1669                }
1670                _ => {
1671                    let certainty = shallow_certainty.and(goals_certainty);
1672                    (certainty, NestedNormalizationGoals::empty())
1673                }
1674            };
1675
1676        if let Certainty::Maybe(
1677            maybe_info @ MaybeInfo {
1678                cause: MaybeCause::Overflow { keep_constraints: false, .. },
1679                opaque_types_jank: _,
1680                stalled_on_coroutines: _,
1681            },
1682        ) = certainty
1683        {
1684            // If we have overflow, it's probable that we're substituting a type
1685            // into itself infinitely and any partial substitutions in the query
1686            // response are probably not useful anyways, so just return an empty
1687            // query response.
1688            //
1689            // This may prevent us from potentially useful inference, e.g.
1690            // 2 candidates, one ambiguous and one overflow, which both
1691            // have the same inference constraints.
1692            //
1693            // Changing this to retain some constraints in the future
1694            // won't be a breaking change, so this is good enough for now.
1695            return Ok(self.make_ambiguous_response_no_constraints(maybe_info));
1696        }
1697
1698        let external_constraints =
1699            self.compute_external_query_constraints(certainty, normalization_nested_goals);
1700        let (var_values, mut external_constraints) = self
1701            .delegate
1702            .deeply_resolve_via_unification_table((self.var_values, external_constraints));
1703
1704        // Remove any trivial or duplicated region constraints once we've resolved regions
1705        let mut unique = HashSet::default();
1706        if let ExternalRegionConstraints::Old(r) = &mut external_constraints.region_constraints {
1707            r.retain(|(outlives, _)| !outlives.is_trivial() && unique.insert(*outlives));
1708        }
1709
1710        filter_irrelevant_region_constraints(self.delegate, &var_values, &mut external_constraints);
1711
1712        let canonical = canonicalize_response(
1713            self.delegate,
1714            self.max_input_universe,
1715            Response {
1716                var_values,
1717                certainty,
1718                external_constraints: self.cx().mk_external_constraints(external_constraints),
1719            },
1720        );
1721
1722        Ok(canonical)
1723    }
1724
1725    /// Constructs a totally unconstrained, ambiguous response to a goal.
1726    ///
1727    /// Take care when using this, since often it's useful to respond with
1728    /// ambiguity but return constrained variables to guide inference.
1729    pub(in crate::solve) fn make_ambiguous_response_no_constraints(
1730        &self,
1731        maybe: MaybeInfo,
1732    ) -> CanonicalResponse<I> {
1733        response_no_constraints_raw(
1734            self.cx(),
1735            self.max_input_universe,
1736            self.var_kinds,
1737            Certainty::Maybe(maybe),
1738        )
1739    }
1740
1741    /// Computes the region constraints and *new* opaque types registered when
1742    /// proving a goal.
1743    ///
1744    /// If an opaque was already constrained before proving this goal, then the
1745    /// external constraints do not need to record that opaque, since if it is
1746    /// further constrained by inference, that will be passed back in the var
1747    /// values.
1748    {}
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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1748u32),
                                ::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();
                                        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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1748",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1748u32),
                        ::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)]
1749    fn compute_external_query_constraints(
1750        &self,
1751        certainty: Certainty,
1752        normalization_nested_goals: NestedNormalizationGoals<I>,
1753    ) -> ExternalConstraintsData<I> {
1754        // We only return region constraints once the certainty is `Yes`. This
1755        // is necessary as we may drop nested goals on ambiguity, which may result
1756        // in unconstrained inference variables in the region constraints. It also
1757        // prevents us from emitting duplicate region constraints, avoiding some
1758        // unnecessary work. This slightly weakens the leak check in case it uses
1759        // region constraints from an ambiguous nested goal. This is tested in both
1760        // `tests/ui/higher-ranked/leak-check/leak-check-in-selection-5-ambig.rs` and
1761        // `tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.rs`.
1762        let region_constraints = if self.cx().assumptions_on_binders() {
1763            ExternalRegionConstraints::NextGen(if let Certainty::Yes = certainty {
1764                let constraint = self.delegate.get_solver_region_constraint();
1765                constraint
1766            } else {
1767                RegionConstraint::new_true()
1768            })
1769        } else {
1770            ExternalRegionConstraints::Old(if let Certainty::Yes = certainty {
1771                self.delegate.make_deduplicated_region_constraints()
1772            } else {
1773                vec![]
1774            })
1775        };
1776
1777        // We only return *newly defined* opaque types from canonical queries.
1778        //
1779        // Constraints for any existing opaque types are already tracked by changes
1780        // to the `var_values`.
1781        let opaque_types = self
1782            .delegate
1783            .clone_opaque_types_added_since(self.initial_opaque_types_storage_num_entries);
1784
1785        if self.typing_mode().is_erased_not_coherence() {
1786            assert!(opaque_types.is_empty());
1787        }
1788
1789        ExternalConstraintsData { region_constraints, opaque_types, normalization_nested_goals }
1790    }
1791
1792    pub(super) fn normalize<T: TypeFoldable<I>>(
1793        &mut self,
1794        param_env: I::ParamEnv,
1795        value: ty::Unnormalized<I, T>,
1796    ) -> Result<T, NoSolutionOrRerunNonErased> {
1797        let value = self.delegate.deeply_resolve_ignoring_regions(value.skip_normalization());
1798
1799        if !self.cx().renormalize_rigid_aliases() && !value.has_non_rigid_aliases() {
1800            return Ok(value);
1801        }
1802
1803        // To drop the mutable borrow of self early.
1804        let infcx = self.delegate.deref();
1805        let mut folder = NormalizationFolder::new(infcx, ::alloc::vec::Vec::new()vec![], |alias_term| {
1806            let infer_term = self.next_term_infer_of_alias_kind(alias_term);
1807            let pred = ty::ProjectionClause { projection_term: alias_term, term: infer_term };
1808            let goal = Goal::new(self.cx(), param_env, pred);
1809            let source = GoalSource::Normalization;
1810            self.inspect.add_goal(self.delegate, self.max_input_universe, source, goal);
1811            let GoalEvaluation { goal, certainty, has_changed: _, stalled_on } =
1812                self.evaluate_goal(source, goal, None)?;
1813            let normalization_was_ambiguous = match certainty {
1814                Certainty::Yes => NormalizationWasAmbiguous::No,
1815                Certainty::Maybe(_) => {
1816                    self.nested_goals.push((source, goal, stalled_on));
1817                    NormalizationWasAmbiguous::Yes
1818                }
1819            };
1820
1821            Ok((self.deeply_resolve_ignoring_regions(infer_term), normalization_was_ambiguous))
1822        });
1823        value.try_fold_with(&mut folder)
1824    }
1825}
1826
1827fn filter_irrelevant_region_constraints<D, I>(
1828    delegate: &D,
1829    var_values: &CanonicalVarValues<I>,
1830    external_constraints: &mut ExternalConstraintsData<I>,
1831) where
1832    D: SolverDelegate<Interner = I>,
1833    I: Interner,
1834{
1835    #[derive(#[automatically_derived]
impl ::core::default::Default for NonTrivialVars {
    #[inline]
    fn default() -> Self {
        Self { vars: ::core::default::Default::default() }
    }
}Default)]
1836    struct NonTrivialVars {
1837        vars: HashSet<RegionVid>,
1838    }
1839    impl<I> TypeVisitor<I> for NonTrivialVars
1840    where
1841        I: Interner,
1842    {
1843        type Result = ();
1844        fn visit_ty(&mut self, t: I::Ty) {
1845            // If a nested type doesn't have any `ReVar`s, then we won't insert
1846            // anything into `vars` anyway, so skip for better perf.
1847            if !t.has_infer_regions() {
1848                return;
1849            }
1850            t.super_visit_with(self);
1851        }
1852        fn visit_const(&mut self, c: Const<I>) {
1853            // The same goes for consts.
1854            if !c.has_infer_regions() {
1855                return;
1856            }
1857            c.super_visit_with(self);
1858        }
1859        fn visit_region(&mut self, r: Region<I>) {
1860            if let ty::ReVar(vid) = r.kind() {
1861                self.vars.insert(vid);
1862            }
1863        }
1864    }
1865
1866    let ExternalConstraintsData { region_constraints, opaque_types, normalization_nested_goals } =
1867        external_constraints;
1868
1869    // If we have a constraint like `'re: '?1`, where '?1 can name 're and '?1 appears
1870    // only on the RHS of region constraints, then this kind of constraint is also trivial,
1871    // since we're able to pick '?1 := glb('re, other_regions), and by definition of glb,
1872    // `'re: glb`.
1873    if let ExternalRegionConstraints::Old(r) = region_constraints
1874        && !r.is_empty()
1875    {
1876        let mut vis = NonTrivialVars::default();
1877        var_values.visit_with(&mut vis);
1878        // We have to visit each component of `external_constraints` individually here
1879        // because we skip the RHS of outlives constraints, and `TypeVisitor` doesn't
1880        // have a method we can easily override in order to do this.
1881        opaque_types.visit_with(&mut vis);
1882        normalization_nested_goals.visit_with(&mut vis);
1883        for (constraint, _) in r.iter() {
1884            match constraint {
1885                ty::RegionConstraint::Outlives(ty::OutlivesClause(sup, _)) => {
1886                    sup.visit_with(&mut vis)
1887                }
1888                ty::RegionConstraint::Eq(eq) => eq.visit_with(&mut vis),
1889            }
1890        }
1891
1892        r.retain(|(outlives, _)| {
1893            if let ty::RegionConstraint::Outlives(ty::OutlivesClause(sup, re)) = *outlives
1894                && let Some(sup_re) = sup.as_region()
1895                && let ty::RegionKind::ReVar(vid) = re.kind()
1896                // This is only safe if we call `eager_resolve_vars` before calling,
1897                // this function, which we do.
1898                && delegate.universe_of_region(vid).unwrap()
1899                    .can_name(max_universe(&**delegate, sup_re))
1900            {
1901                vis.vars.contains(&vid)
1902            } else {
1903                true
1904            }
1905        });
1906    }
1907}
1908
1909#[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)]
1910enum RerunDecision {
1911    Yes,
1912    No,
1913    EagerlyPropagateToParent,
1914}
1915
1916{}
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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1916u32),
                                ::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/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:1916",
                        "rustc_next_trait_solver::solve::eval_ctxt",
                        ::tracing::Level::INFO,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/28221559263a3976766cf305940e80e30cf9ba8a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1916u32),
                        ::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)]
1917fn should_rerun_after_erased_canonicalization<I: Interner>(
1918    AccessedOpaques { reason: _, rerun }: AccessedOpaques<I>,
1919    original_typing_mode: TypingMode<I>,
1920    parent_opaque_types: &[(OpaqueTypeKey<I>, I::Ty)],
1921) -> RerunDecision {
1922    let parent_opaque_def_ids = parent_opaque_types.iter().map(|(key, _)| key.def_id.into());
1923    let opaque_in_storage = |opaques: I::LocalDefIds, def_ids: SmallCopySet<_>| {
1924        if def_ids.as_ref().is_empty() {
1925            RerunDecision::No
1926        } else if opaques
1927            .iter()
1928            .chain(parent_opaque_def_ids)
1929            .any(|opaque| def_ids.as_ref().contains(&opaque))
1930        {
1931            RerunDecision::Yes
1932        } else {
1933            RerunDecision::No
1934        }
1935    };
1936    let any_opaque_has_infer_as_hidden = || {
1937        if parent_opaque_types.iter().any(|(_, ty)| ty.is_ty_var()) {
1938            RerunDecision::Yes
1939        } else {
1940            RerunDecision::No
1941        }
1942    };
1943
1944    match (rerun, original_typing_mode) {
1945        // =============================
1946        (RerunCondition::Never, _) => RerunDecision::No,
1947        // =============================
1948        (_, TypingMode::ErasedNotCoherence(MayBeErased)) => RerunDecision::EagerlyPropagateToParent,
1949        // =============================
1950        // In coherence, we never switch to erased mode, so we will never register anything
1951        // in the rerun state, so we should've taken the first branch of this match
1952        (_, TypingMode::Coherence) => unreachable!(),
1953        // =============================
1954        (RerunCondition::Always, _) => RerunDecision::Yes,
1955        // =============================
1956        (
1957            RerunCondition::OpaqueInStorage(..),
1958            TypingMode::PostAnalysis | TypingMode::Codegen | TypingMode::Reflection,
1959        ) => RerunDecision::Yes,
1960        (
1961            RerunCondition::OpaqueInStorage(defids),
1962            TypingMode::PostBorrowck { defined_opaque_types: opaques }
1963            | TypingMode::Typeck { defining_opaque_types_and_generators: opaques }
1964            | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types: opaques },
1965        ) => opaque_in_storage(opaques, defids),
1966        // =============================
1967        (RerunCondition::AnyOpaqueHasInferAsHidden, TypingMode::Typeck { .. }) => {
1968            any_opaque_has_infer_as_hidden()
1969        }
1970        (
1971            RerunCondition::AnyOpaqueHasInferAsHidden,
1972            TypingMode::PostBorrowck { .. }
1973            | TypingMode::PostAnalysis
1974            | TypingMode::Codegen
1975            | TypingMode::Reflection
1976            | TypingMode::PostTypeckUntilBorrowck { .. },
1977        ) => RerunDecision::No,
1978        // =============================
1979        (
1980            RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(_),
1981            TypingMode::PostAnalysis | TypingMode::Codegen | TypingMode::Reflection,
1982        ) => RerunDecision::Yes,
1983        (
1984            RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
1985            TypingMode::Typeck { defining_opaque_types_and_generators: opaques },
1986        ) => {
1987            if let RerunDecision::Yes = any_opaque_has_infer_as_hidden() {
1988                RerunDecision::Yes
1989            } else if let RerunDecision::Yes = opaque_in_storage(opaques, defids) {
1990                RerunDecision::Yes
1991            } else {
1992                RerunDecision::No
1993            }
1994        }
1995        (
1996            RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
1997            TypingMode::PostBorrowck { defined_opaque_types: opaques }
1998            | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types: opaques },
1999        ) => opaque_in_storage(opaques, defids),
2000    }
2001}
2002
2003/// Do not call this directly, use the `tcx` query instead.
2004pub fn evaluate_root_goal_for_proof_tree_raw_provider<
2005    D: SolverDelegate<Interner = I>,
2006    I: Interner,
2007>(
2008    cx: I,
2009    canonical_goal: I::CanonicalInput,
2010    root_depth: usize,
2011) -> (QueryResult<I>, I::Probe, RequiredDepth) {
2012    let mut inspect = inspect::ProofTreeBuilder::new();
2013    let ((canonical_result, accessed_opaques), required_depth) =
2014        SearchGraph::<D>::evaluate_root_goal_for_proof_tree(
2015            cx,
2016            root_depth,
2017            canonical_goal,
2018            &mut inspect,
2019        );
2020    let final_revision = inspect.unwrap();
2021
2022    if !!accessed_opaques.might_rerun() {
    ::core::panicking::panic("assertion failed: !accessed_opaques.might_rerun()")
};assert!(!accessed_opaques.might_rerun());
2023    (canonical_result, cx.mk_probe(final_revision), required_depth)
2024}
2025
2026/// Evaluate a goal to build a proof tree.
2027///
2028/// This is a copy of [EvalCtxt::evaluate_goal_raw] which avoids relying on the
2029/// [EvalCtxt] and uses a separate cache.
2030pub(super) fn evaluate_root_goal_for_proof_tree<D: SolverDelegate<Interner = I>, I: Interner>(
2031    delegate: &D,
2032    goal: Goal<I, I::Predicate>,
2033    origin_span: I::Span,
2034    root_depth: usize,
2035) -> (Result<NestedNormalizationGoals<I>, NoSolution>, inspect::GoalEvaluation<I>) {
2036    let opaque_types = delegate.clone_opaque_types_lookup_table();
2037    let (goal, opaque_types) = delegate.deeply_resolve_via_unification_table((goal, opaque_types));
2038    let typing_mode = delegate.typing_mode_raw().assert_not_erased();
2039
2040    let (orig_values, canonical_goal) =
2041        canonicalize_goal(delegate, goal, &opaque_types, typing_mode.into());
2042
2043    let (canonical_result, final_revision, required_depth) =
2044        delegate.cx().evaluate_root_goal_for_proof_tree_raw(canonical_goal, root_depth);
2045
2046    let proof_tree = inspect::GoalEvaluation {
2047        uncanonicalized_goal: goal,
2048        orig_values,
2049        final_revision,
2050        result: canonical_result,
2051        required_depth,
2052    };
2053
2054    let response = match canonical_result {
2055        Err(e) => return (Err(e), proof_tree),
2056        Ok(response) => response,
2057    };
2058
2059    let (normalization_nested_goals, _certainty) = instantiate_and_apply_query_response(
2060        delegate,
2061        &proof_tree.orig_values,
2062        response,
2063        origin_span,
2064    );
2065
2066    (Ok(normalization_nested_goals), proof_tree)
2067}