Skip to main content

rustc_next_trait_solver/solve/eval_ctxt/
mod.rs

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