Skip to main content

rustc_trait_selection/traits/select/
mod.rs

1//! Candidate selection. See the [rustc dev guide] for more information on how this works.
2//!
3//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html#selection
4
5use std::cell::{Cell, RefCell};
6use std::cmp;
7use std::fmt::{self, Display};
8use std::ops::ControlFlow;
9
10use hir::def::DefKind;
11use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
12use rustc_errors::{Diag, EmissionGuarantee};
13use rustc_hir as hir;
14use rustc_hir::attrs::lang_items::LangItem;
15use rustc_hir::def_id::DefId;
16use rustc_infer::infer::BoundRegionConversionTime::{self, HigherRankedType};
17use rustc_infer::infer::DefineOpaqueTypes;
18use rustc_infer::infer::at::ToTrace;
19use rustc_infer::infer::relate::TypeRelation;
20use rustc_infer::traits::{ImplSource, PredicateObligations, TraitObligation};
21use rustc_macros::{TypeFoldable, TypeVisitable};
22use rustc_middle::bug;
23use rustc_middle::dep_graph::{DepKind, DepNodeIndex};
24pub use rustc_middle::traits::select::*;
25use rustc_middle::ty::abstract_const::NotConstEvaluatable;
26use rustc_middle::ty::error::TypeErrorToStringExt;
27use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths};
28use rustc_middle::ty::{
29    self, CandidatePreferenceMode, CantBeErased, DeepRejectCtxt, GenericArgsRef,
30    PolyProjectionClause, SizedTraitKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, TypingMode,
31    Unnormalized, Upcast, elaborate, may_use_unstable_feature,
32};
33use rustc_next_trait_solver::solve::AliasBoundKind;
34use tracing::{debug, instrument, trace};
35
36use self::EvaluationResult::*;
37use self::SelectionCandidate::*;
38use super::coherence::{self, Conflict};
39use super::project::ProjectionTermObligation;
40use super::util::closure_trait_ref_and_return_type;
41use super::{
42    ImplDerivedCause, Normalized, Obligation, ObligationCause, ObligationCauseCode,
43    PolyTraitObligation, PredicateObligation, Selection, SelectionError, SelectionResult,
44    TraitQueryMode, const_evaluatable, project, util, wf,
45};
46use crate::error_reporting::InferCtxtErrorExt;
47use crate::infer::{InferCtxt, InferOk, TypeFreshener};
48use crate::solve::InferCtxtSelectExt as _;
49use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to};
50use crate::traits::project::{ProjectAndUnifyResult, ProjectionCacheKeyExt};
51use crate::traits::{EvaluateConstErr, ProjectionCacheKey, effects, sizedness_fast_path};
52
53mod _match;
54mod candidate_assembly;
55mod confirmation;
56
57#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for IntercrateAmbiguityCause<'tcx> {
    #[inline]
    fn clone(&self) -> IntercrateAmbiguityCause<'tcx> {
        match self {
            IntercrateAmbiguityCause::DownstreamCrate {
                trait_ref: __self_0, self_ty: __self_1 } =>
                IntercrateAmbiguityCause::DownstreamCrate {
                    trait_ref: ::core::clone::Clone::clone(__self_0),
                    self_ty: ::core::clone::Clone::clone(__self_1),
                },
            IntercrateAmbiguityCause::UpstreamCrateUpdate {
                trait_ref: __self_0, self_ty: __self_1 } =>
                IntercrateAmbiguityCause::UpstreamCrateUpdate {
                    trait_ref: ::core::clone::Clone::clone(__self_0),
                    self_ty: ::core::clone::Clone::clone(__self_1),
                },
        }
    }
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for IntercrateAmbiguityCause<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            IntercrateAmbiguityCause::DownstreamCrate {
                trait_ref: __self_0, self_ty: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "DownstreamCrate", "trait_ref", __self_0, "self_ty",
                    &__self_1),
            IntercrateAmbiguityCause::UpstreamCrateUpdate {
                trait_ref: __self_0, self_ty: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "UpstreamCrateUpdate", "trait_ref", __self_0, "self_ty",
                    &__self_1),
        }
    }
}Debug, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for IntercrateAmbiguityCause<'tcx> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<ty::TraitRef<'tcx>>;
        let _: ::core::cmp::AssertParamIsEq<Option<Ty<'tcx>>>;
        let _: ::core::cmp::AssertParamIsEq<ty::TraitRef<'tcx>>;
        let _: ::core::cmp::AssertParamIsEq<Option<Ty<'tcx>>>;
    }
}Eq, #[automatically_derived]
impl<'tcx> ::core::marker::StructuralPartialEq for
    IntercrateAmbiguityCause<'tcx> {
}
#[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for IntercrateAmbiguityCause<'tcx> {
    #[inline]
    fn eq(&self, other: &IntercrateAmbiguityCause<'tcx>) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (IntercrateAmbiguityCause::DownstreamCrate {
                    trait_ref: __self_0, self_ty: __self_1 },
                    IntercrateAmbiguityCause::DownstreamCrate {
                    trait_ref: __arg1_0, self_ty: __arg1_1 }) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (IntercrateAmbiguityCause::UpstreamCrateUpdate {
                    trait_ref: __self_0, self_ty: __self_1 },
                    IntercrateAmbiguityCause::UpstreamCrateUpdate {
                    trait_ref: __arg1_0, self_ty: __arg1_1 }) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::hash::Hash for IntercrateAmbiguityCause<'tcx> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state);
        match self {
            IntercrateAmbiguityCause::DownstreamCrate {
                trait_ref: __self_0, self_ty: __self_1 } => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
            IntercrateAmbiguityCause::UpstreamCrateUpdate {
                trait_ref: __self_0, self_ty: __self_1 } => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
        }
    }
}Hash)]
58pub enum IntercrateAmbiguityCause<'tcx> {
59    DownstreamCrate { trait_ref: ty::TraitRef<'tcx>, self_ty: Option<Ty<'tcx>> },
60    UpstreamCrateUpdate { trait_ref: ty::TraitRef<'tcx>, self_ty: Option<Ty<'tcx>> },
61}
62
63impl<'tcx> IntercrateAmbiguityCause<'tcx> {
64    /// Emits notes when the overlap is caused by complex intercrate ambiguities.
65    /// See #23980 for details.
66    pub fn add_intercrate_ambiguity_hint<G: EmissionGuarantee>(&self, err: &mut Diag<'_, G>) {
67        err.note(self.intercrate_ambiguity_hint());
68    }
69
70    pub fn intercrate_ambiguity_hint(&self) -> String {
71        {
    let _guard = NoTrimmedGuard::new();
    match self {
        IntercrateAmbiguityCause::DownstreamCrate { trait_ref, self_ty } => {
            ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("downstream crates may implement trait `{0}`{1}",
                            trait_ref.print_trait_sugared(),
                            if let Some(self_ty) = self_ty {
                                ::alloc::__export::must_use({
                                        ::alloc::fmt::format(format_args!(" for type `{0}`",
                                                self_ty))
                                    })
                            } else { String::new() }))
                })
        }
        IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_ref, self_ty }
            => {
            ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("upstream crates may add a new impl of trait `{0}`{1} in future versions",
                            trait_ref.print_trait_sugared(),
                            if let Some(self_ty) = self_ty {
                                ::alloc::__export::must_use({
                                        ::alloc::fmt::format(format_args!(" for type `{0}`",
                                                self_ty))
                                    })
                            } else { String::new() }))
                })
        }
    }
}with_no_trimmed_paths!(match self {
72            IntercrateAmbiguityCause::DownstreamCrate { trait_ref, self_ty } => {
73                format!(
74                    "downstream crates may implement trait `{trait_desc}`{self_desc}",
75                    trait_desc = trait_ref.print_trait_sugared(),
76                    self_desc = if let Some(self_ty) = self_ty {
77                        format!(" for type `{self_ty}`")
78                    } else {
79                        String::new()
80                    }
81                )
82            }
83            IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_ref, self_ty } => {
84                format!(
85                    "upstream crates may add a new impl of trait `{trait_desc}`{self_desc} \
86                in future versions",
87                    trait_desc = trait_ref.print_trait_sugared(),
88                    self_desc = if let Some(self_ty) = self_ty {
89                        format!(" for type `{self_ty}`")
90                    } else {
91                        String::new()
92                    }
93                )
94            }
95        })
96    }
97}
98
99pub struct SelectionContext<'cx, 'tcx> {
100    pub infcx: &'cx InferCtxt<'tcx>,
101
102    /// Freshener used specifically for entries on the obligation
103    /// stack. This ensures that all entries on the stack at one time
104    /// will have the same set of placeholder entries, which is
105    /// important for checking for trait bounds that recursively
106    /// require themselves.
107    freshener: TypeFreshener<'cx, 'tcx>,
108
109    /// If `intercrate` is set, we remember predicates which were
110    /// considered ambiguous because of impls potentially added in other crates.
111    /// This is used in coherence to give improved diagnostics.
112    /// We don't do his until we detect a coherence error because it can
113    /// lead to false overflow results (#47139) and because always
114    /// computing it may negatively impact performance.
115    intercrate_ambiguity_causes: Option<FxIndexSet<IntercrateAmbiguityCause<'tcx>>>,
116
117    /// The mode that trait queries run in, which informs our error handling
118    /// policy. In essence, canonicalized queries need their errors propagated
119    /// rather than immediately reported because we do not have accurate spans.
120    query_mode: TraitQueryMode,
121}
122
123// A stack that walks back up the stack frame.
124struct TraitObligationStack<'prev, 'tcx> {
125    obligation: &'prev PolyTraitObligation<'tcx>,
126
127    /// The trait predicate from `obligation` but "freshened" with the
128    /// selection-context's freshener. Used to check for recursion.
129    fresh_trait_pred: ty::PolyTraitClause<'tcx>,
130
131    /// Starts out equal to `depth` -- if, during evaluation, we
132    /// encounter a cycle, then we will set this flag to the minimum
133    /// depth of that cycle for all participants in the cycle. These
134    /// participants will then forego caching their results. This is
135    /// not the most efficient solution, but it addresses #60010. The
136    /// problem we are trying to prevent:
137    ///
138    /// - If you have `A: AutoTrait` requires `B: AutoTrait` and `C: NonAutoTrait`
139    /// - `B: AutoTrait` requires `A: AutoTrait` (coinductive cycle, ok)
140    /// - `C: NonAutoTrait` requires `A: AutoTrait` (non-coinductive cycle, not ok)
141    ///
142    /// you don't want to cache that `B: AutoTrait` or `A: AutoTrait`
143    /// is `EvaluatedToOk`; this is because they were only considered
144    /// ok on the premise that if `A: AutoTrait` held, but we indeed
145    /// encountered a problem (later on) with `A: AutoTrait`. So we
146    /// currently set a flag on the stack node for `B: AutoTrait` (as
147    /// well as the second instance of `A: AutoTrait`) to suppress
148    /// caching.
149    ///
150    /// This is a simple, targeted fix. A more-performant fix requires
151    /// deeper changes, but would permit more caching: we could
152    /// basically defer caching until we have fully evaluated the
153    /// tree, and then cache the entire tree at once. In any case, the
154    /// performance impact here shouldn't be so horrible: every time
155    /// this is hit, we do cache at least one trait, so we only
156    /// evaluate each member of a cycle up to N times, where N is the
157    /// length of the cycle. This means the performance impact is
158    /// bounded and we shouldn't have any terrible worst-cases.
159    reached_depth: Cell<usize>,
160
161    previous: TraitObligationStackList<'prev, 'tcx>,
162
163    /// The number of parent frames plus one (thus, the topmost frame has depth 1).
164    depth: usize,
165
166    /// The depth-first number of this node in the search graph -- a
167    /// pre-order index. Basically, a freshly incremented counter.
168    dfn: usize,
169}
170
171struct SelectionCandidateSet<'tcx> {
172    /// A list of candidates that definitely apply to the current
173    /// obligation (meaning: types unify).
174    vec: Vec<SelectionCandidate<'tcx>>,
175
176    /// If `true`, then there were candidates that might or might
177    /// not have applied, but we couldn't tell. This occurs when some
178    /// of the input types are type variables, in which case there are
179    /// various "builtin" rules that might or might not trigger.
180    ambiguous: bool,
181}
182
183#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::StructuralPartialEq for EvaluatedCandidate<'tcx> {
}
#[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for EvaluatedCandidate<'tcx> {
    #[inline]
    fn eq(&self, other: &EvaluatedCandidate<'tcx>) -> bool {
        self.candidate == other.candidate &&
            self.evaluation == other.evaluation
    }
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for EvaluatedCandidate<'tcx> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<SelectionCandidate<'tcx>>;
        let _: ::core::cmp::AssertParamIsEq<EvaluationResult>;
    }
}Eq, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for EvaluatedCandidate<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "EvaluatedCandidate", "candidate", &self.candidate, "evaluation",
            &&self.evaluation)
    }
}Debug, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for EvaluatedCandidate<'tcx> {
    #[inline]
    fn clone(&self) -> EvaluatedCandidate<'tcx> {
        EvaluatedCandidate {
            candidate: ::core::clone::Clone::clone(&self.candidate),
            evaluation: ::core::clone::Clone::clone(&self.evaluation),
        }
    }
}Clone)]
184struct EvaluatedCandidate<'tcx> {
185    candidate: SelectionCandidate<'tcx>,
186    evaluation: EvaluationResult,
187}
188
189impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
190    pub fn new(infcx: &'cx InferCtxt<'tcx>) -> SelectionContext<'cx, 'tcx> {
191        SelectionContext {
192            infcx,
193            freshener: TypeFreshener::new(infcx),
194            intercrate_ambiguity_causes: None,
195            query_mode: TraitQueryMode::Standard,
196        }
197    }
198
199    pub fn typing_mode(&self) -> TypingMode<'tcx, CantBeErased> {
200        self.infcx.typing_mode_raw().assert_not_erased()
201    }
202
203    pub fn with_query_mode(
204        infcx: &'cx InferCtxt<'tcx>,
205        query_mode: TraitQueryMode,
206    ) -> SelectionContext<'cx, 'tcx> {
207        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:207",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(207u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("query_mode")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("query_mode");
                                            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!("with_query_mode")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&query_mode)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?query_mode, "with_query_mode");
208        SelectionContext { query_mode, ..SelectionContext::new(infcx) }
209    }
210
211    /// Enables tracking of intercrate ambiguity causes. See
212    /// the documentation of [`Self::intercrate_ambiguity_causes`] for more.
213    pub fn enable_tracking_intercrate_ambiguity_causes(&mut self) {
214        if !self.typing_mode().is_coherence() {
    ::core::panicking::panic("assertion failed: self.typing_mode().is_coherence()")
};assert!(self.typing_mode().is_coherence());
215        if !self.intercrate_ambiguity_causes.is_none() {
    ::core::panicking::panic("assertion failed: self.intercrate_ambiguity_causes.is_none()")
};assert!(self.intercrate_ambiguity_causes.is_none());
216
217        self.intercrate_ambiguity_causes = Some(FxIndexSet::default());
218        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:218",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(218u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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!("selcx: enable_tracking_intercrate_ambiguity_causes")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("selcx: enable_tracking_intercrate_ambiguity_causes");
219    }
220
221    /// Gets the intercrate ambiguity causes collected since tracking
222    /// was enabled and disables tracking at the same time. If
223    /// tracking is not enabled, just returns an empty vector.
224    pub fn take_intercrate_ambiguity_causes(
225        &mut self,
226    ) -> FxIndexSet<IntercrateAmbiguityCause<'tcx>> {
227        if !self.typing_mode().is_coherence() {
    ::core::panicking::panic("assertion failed: self.typing_mode().is_coherence()")
};assert!(self.typing_mode().is_coherence());
228
229        self.intercrate_ambiguity_causes.take().unwrap_or_default()
230    }
231
232    pub fn tcx(&self) -> TyCtxt<'tcx> {
233        self.infcx.tcx
234    }
235
236    ///////////////////////////////////////////////////////////////////////////
237    // Selection
238    //
239    // The selection phase tries to identify *how* an obligation will
240    // be resolved. For example, it will identify which impl or
241    // parameter bound is to be used. The process can be inconclusive
242    // if the self type in the obligation is not fully inferred. Selection
243    // can result in an error in one of two ways:
244    //
245    // 1. If no applicable impl or parameter bound can be found.
246    // 2. If the output type parameters in the obligation do not match
247    //    those specified by the impl/bound. For example, if the obligation
248    //    is `Vec<Foo>: Iterable<Bar>`, but the impl specifies
249    //    `impl<T> Iterable<T> for Vec<T>`, than an error would result.
250
251    /// Attempts to satisfy the obligation. If successful, this will affect the surrounding
252    /// type environment by performing unification.
253    {}
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("poly_select",
                                "rustc_trait_selection::traits::select",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(253u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("obligation")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("obligation");
                                                    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(&obligation)
                                                        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:
                                SelectionResult<'tcx, Selection<'tcx>> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if self.infcx.next_trait_solver() {
                            return self.infcx.select_in_new_trait_solver(obligation);
                        }
                        let candidate =
                            match self.select_from_obligation(obligation) {
                                Err(SelectionError::Overflow(OverflowError::Canonical)) => {
                                    if !(self.query_mode == TraitQueryMode::Canonical) {
                                        ::core::panicking::panic("assertion failed: self.query_mode == TraitQueryMode::Canonical")
                                    };
                                    return Err(SelectionError::Overflow(OverflowError::Canonical));
                                }
                                Err(e) => { return Err(e); }
                                Ok(None) => { return Ok(None); }
                                Ok(Some(candidate)) => candidate,
                            };
                        match self.confirm_candidate(obligation, candidate) {
                            Err(SelectionError::Overflow(OverflowError::Canonical)) => {
                                if !(self.query_mode == TraitQueryMode::Canonical) {
                                    ::core::panicking::panic("assertion failed: self.query_mode == TraitQueryMode::Canonical")
                                };
                                Err(SelectionError::Overflow(OverflowError::Canonical))
                            }
                            Err(e) => Err(e),
                            Ok(ImplSource::Builtin(..)) if
                                self.typing_mode().is_reflection() => {
                                Err(SelectionError::Unimplemented)
                            }
                            Ok(candidate) => Ok(Some(candidate)),
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:253",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(253u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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)]
254    pub fn poly_select(
255        &mut self,
256        obligation: &PolyTraitObligation<'tcx>,
257    ) -> SelectionResult<'tcx, Selection<'tcx>> {
258        if self.infcx.next_trait_solver() {
259            return self.infcx.select_in_new_trait_solver(obligation);
260        }
261
262        let candidate = match self.select_from_obligation(obligation) {
263            Err(SelectionError::Overflow(OverflowError::Canonical)) => {
264                // In standard mode, overflow must have been caught and reported
265                // earlier.
266                assert!(self.query_mode == TraitQueryMode::Canonical);
267                return Err(SelectionError::Overflow(OverflowError::Canonical));
268            }
269            Err(e) => {
270                return Err(e);
271            }
272            Ok(None) => {
273                return Ok(None);
274            }
275            Ok(Some(candidate)) => candidate,
276        };
277
278        match self.confirm_candidate(obligation, candidate) {
279            Err(SelectionError::Overflow(OverflowError::Canonical)) => {
280                assert!(self.query_mode == TraitQueryMode::Canonical);
281                Err(SelectionError::Overflow(OverflowError::Canonical))
282            }
283            Err(e) => Err(e),
284            Ok(ImplSource::Builtin(..)) if self.typing_mode().is_reflection() => {
285                // Builtin impls regularly don't satisfy the try_as_dyn requirements, so
286                // we just reject all of them.
287                Err(SelectionError::Unimplemented)
288            }
289            Ok(candidate) => Ok(Some(candidate)),
290        }
291    }
292
293    pub fn select(
294        &mut self,
295        obligation: &TraitObligation<'tcx>,
296    ) -> SelectionResult<'tcx, Selection<'tcx>> {
297        self.poly_select(&Obligation {
298            cause: obligation.cause.clone(),
299            param_env: obligation.param_env,
300            predicate: ty::Binder::dummy(obligation.predicate),
301            recursion_depth: obligation.recursion_depth,
302        })
303    }
304
305    fn select_from_obligation(
306        &mut self,
307        obligation: &PolyTraitObligation<'tcx>,
308    ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
309        if true {
    if !!obligation.predicate.has_escaping_bound_vars() {
        ::core::panicking::panic("assertion failed: !obligation.predicate.has_escaping_bound_vars()")
    };
};debug_assert!(!obligation.predicate.has_escaping_bound_vars());
310
311        let pec = &ProvisionalEvaluationCache::default();
312        let stack = self.push_stack(TraitObligationStackList::empty(pec), obligation);
313
314        self.candidate_from_obligation(&stack)
315    }
316
317    {}
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("candidate_from_obligation",
                                "rustc_trait_selection::traits::select",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(317u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("stack")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("stack");
                                                    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(&stack)
                                                        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:
                                SelectionResult<'tcx, SelectionCandidate<'tcx>> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if true {
                            if !!self.infcx.next_trait_solver() {
                                ::core::panicking::panic("assertion failed: !self.infcx.next_trait_solver()")
                            };
                        };
                        self.check_recursion_limit(stack.obligation,
                                stack.obligation)?;
                        let cache_fresh_trait_pred =
                            stack.obligation.predicate.fold_with(&mut TypeFreshener::new(self.infcx));
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:333",
                                                "rustc_trait_selection::traits::select",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(333u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("cache_fresh_trait_pred")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("cache_fresh_trait_pred");
                                                                    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(&cache_fresh_trait_pred)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        if true {
                            if !!stack.obligation.predicate.has_escaping_bound_vars() {
                                ::core::panicking::panic("assertion failed: !stack.obligation.predicate.has_escaping_bound_vars()")
                            };
                        };
                        if let Some(c) =
                                self.check_candidate_cache(stack.obligation.param_env,
                                    cache_fresh_trait_pred) {
                            {
                                use ::tracing::__macro_support::Callsite as _;
                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                    {
                                        static META: ::tracing::Metadata<'static> =
                                            {
                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:339",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(339u32),
                                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                    ::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!("CACHE HIT")
                                                                        as &dyn ::tracing::field::Value))])
                                        });
                                } else { ; }
                            };
                            return c;
                        }
                        let (candidate, dep_node) =
                            self.in_task(|this|
                                    this.candidate_from_obligation_no_cache(stack));
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:352",
                                                "rustc_trait_selection::traits::select",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(352u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                ::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!("CACHE MISS")
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        self.insert_candidate_cache(stack.obligation.param_env,
                            cache_fresh_trait_pred, dep_node, candidate.clone());
                        candidate
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:317",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(317u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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)]
318    fn candidate_from_obligation<'o>(
319        &mut self,
320        stack: &TraitObligationStack<'o, 'tcx>,
321    ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
322        debug_assert!(!self.infcx.next_trait_solver());
323        // Watch out for overflow. This intentionally bypasses (and does
324        // not update) the cache.
325        self.check_recursion_limit(stack.obligation, stack.obligation)?;
326
327        // Check the cache. Note that we freshen the trait-ref
328        // separately rather than using `stack.fresh_trait_pred` --
329        // this is because we want the unbound variables to be
330        // replaced with fresh types starting from index 0.
331        let cache_fresh_trait_pred =
332            stack.obligation.predicate.fold_with(&mut TypeFreshener::new(self.infcx));
333        debug!(?cache_fresh_trait_pred);
334        debug_assert!(!stack.obligation.predicate.has_escaping_bound_vars());
335
336        if let Some(c) =
337            self.check_candidate_cache(stack.obligation.param_env, cache_fresh_trait_pred)
338        {
339            debug!("CACHE HIT");
340            return c;
341        }
342
343        // If no match, compute result and insert into cache.
344        //
345        // FIXME(nikomatsakis) -- this cache is not taking into
346        // account cycles that may have occurred in forming the
347        // candidate. I don't know of any specific problems that
348        // result but it seems awfully suspicious.
349        let (candidate, dep_node) =
350            self.in_task(|this| this.candidate_from_obligation_no_cache(stack));
351
352        debug!("CACHE MISS");
353        self.insert_candidate_cache(
354            stack.obligation.param_env,
355            cache_fresh_trait_pred,
356            dep_node,
357            candidate.clone(),
358        );
359        candidate
360    }
361
362    fn candidate_from_obligation_no_cache<'o>(
363        &mut self,
364        stack: &TraitObligationStack<'o, 'tcx>,
365    ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
366        if let Err(conflict) = self.is_knowable(stack) {
367            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:367",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(367u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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!("coherence stage: not knowable")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("coherence stage: not knowable");
368            if self.intercrate_ambiguity_causes.is_some() {
369                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:369",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(369u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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!("evaluate_stack: intercrate_ambiguity_causes is some")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("evaluate_stack: intercrate_ambiguity_causes is some");
370                // Heuristics: show the diagnostics when there are no candidates in crate.
371                if let Ok(candidate_set) = self.assemble_candidates(stack) {
372                    let mut no_candidates_apply = true;
373
374                    for c in candidate_set.vec.iter() {
375                        if self.evaluate_candidate(stack, c)?.may_apply() {
376                            no_candidates_apply = false;
377                            break;
378                        }
379                    }
380
381                    if !candidate_set.ambiguous && no_candidates_apply {
382                        let trait_ref = self.infcx.deeply_resolve_ignoring_regions(
383                            stack.obligation.predicate.skip_binder().trait_ref,
384                        );
385                        if !trait_ref.references_error() {
386                            let self_ty = trait_ref.self_ty();
387                            let self_ty = self_ty.has_concrete_skeleton().then(|| self_ty);
388                            let cause = if let Conflict::Upstream = conflict {
389                                IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_ref, self_ty }
390                            } else {
391                                IntercrateAmbiguityCause::DownstreamCrate { trait_ref, self_ty }
392                            };
393                            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:393",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(393u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("cause")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("cause");
                                            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!("evaluate_stack: pushing cause")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&cause)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?cause, "evaluate_stack: pushing cause");
394                            self.intercrate_ambiguity_causes.as_mut().unwrap().insert(cause);
395                        }
396                    }
397                }
398            }
399            return Ok(None);
400        }
401
402        let candidate_set = self.assemble_candidates(stack)?;
403
404        if candidate_set.ambiguous {
405            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:405",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(405u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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!("candidate set contains ambig")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("candidate set contains ambig");
406            return Ok(None);
407        }
408
409        let candidates = candidate_set.vec;
410
411        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:411",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(411u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("stack")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("stack");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("candidates")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("candidates");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::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!("assembled {0} candidates",
                                                    candidates.len()) as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&stack)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidates)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?stack, ?candidates, "assembled {} candidates", candidates.len());
412
413        // At this point, we know that each of the entries in the
414        // candidate set is *individually* applicable. Now we have to
415        // figure out if they contain mutual incompatibilities. This
416        // frequently arises if we have an unconstrained input type --
417        // for example, we are looking for `$0: Eq` where `$0` is some
418        // unconstrained type variable. In that case, we'll get a
419        // candidate which assumes $0 == int, one that assumes `$0 ==
420        // usize`, etc. This spells an ambiguity.
421
422        let mut candidates = self.filter_impls(candidates, stack.obligation);
423
424        // If there is more than one candidate, first winnow them down
425        // by considering extra conditions (nested obligations and so
426        // forth). We don't winnow if there is exactly one
427        // candidate. This is a relatively minor distinction but it
428        // can lead to better inference and error-reporting. An
429        // example would be if there was an impl:
430        //
431        //     impl<T:Clone> Vec<T> { fn push_clone(...) { ... } }
432        //
433        // and we were to see some code `foo.push_clone()` where `boo`
434        // is a `Vec<Bar>` and `Bar` does not implement `Clone`. If
435        // we were to winnow, we'd wind up with zero candidates.
436        // Instead, we select the right impl now but report "`Bar` does
437        // not implement `Clone`".
438        if candidates.len() == 1 {
439            return Ok(candidates.pop());
440        }
441
442        // Winnow, but record the exact outcome of evaluation, which
443        // is needed for specialization. Propagate overflow if it occurs.
444        let candidates = candidates
445            .into_iter()
446            .map(|c| match self.evaluate_candidate(stack, &c) {
447                Ok(eval) if eval.may_apply() => {
448                    Ok(Some(EvaluatedCandidate { candidate: c, evaluation: eval }))
449                }
450                Ok(_) => Ok(None),
451                Err(OverflowError::Canonical) => {
452                    Err(SelectionError::Overflow(OverflowError::Canonical))
453                }
454                Err(OverflowError::Error(e)) => {
455                    Err(SelectionError::Overflow(OverflowError::Error(e)))
456                }
457            })
458            .flat_map(Result::transpose)
459            .collect::<Result<Vec<_>, _>>()?;
460
461        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:461",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(461u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("stack")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("stack");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("candidates")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("candidates");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::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!("{0} potentially applicable candidates",
                                                    candidates.len()) as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&stack)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidates)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?stack, ?candidates, "{} potentially applicable candidates", candidates.len());
462        // If there are *NO* candidates, then there are no impls --
463        // that we know of, anyway. Note that in the case where there
464        // are unbound type variables within the obligation, it might
465        // be the case that you could still satisfy the obligation
466        // from another crate by instantiating the type variables with
467        // a type from another crate that does have an impl. This case
468        // is checked for in `evaluate_stack` (and hence users
469        // who might care about this case, like coherence, should use
470        // that function).
471        if candidates.is_empty() {
472            // If there's an error type, 'downgrade' our result from
473            // `Err(Unimplemented)` to `Ok(None)`. This helps us avoid
474            // emitting additional spurious errors, since we're guaranteed
475            // to have emitted at least one.
476            if stack.obligation.predicate.references_error() {
477                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:477",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(477u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("stack.obligation.predicate")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("stack.obligation.predicate");
                                            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!("found error type in predicate, treating as ambiguous")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&stack.obligation.predicate)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?stack.obligation.predicate, "found error type in predicate, treating as ambiguous");
478                Ok(None)
479            } else {
480                Err(SelectionError::Unimplemented)
481            }
482        } else {
483            let has_non_region_infer = stack.obligation.predicate.has_non_region_infer();
484            let candidate_preference_mode =
485                CandidatePreferenceMode::compute(self.tcx(), stack.obligation.predicate.def_id());
486            Ok(self.winnow_candidates(has_non_region_infer, candidate_preference_mode, candidates))
487        }
488    }
489
490    ///////////////////////////////////////////////////////////////////////////
491    // EVALUATION
492    //
493    // Tests whether an obligation can be selected or whether an impl
494    // can be applied to particular types. It skips the "confirmation"
495    // step and hence completely ignores output type parameters.
496    //
497    // The result is "true" if the obligation *may* hold and "false" if
498    // we can be sure it does not.
499
500    /// Evaluates whether the obligation `obligation` can be satisfied
501    /// and returns an `EvaluationResult`. This is meant for the
502    /// *initial* call.
503    ///
504    /// Do not use this directly, use `infcx.evaluate_obligation` instead.
505    pub fn evaluate_root_obligation(
506        &mut self,
507        obligation: &PredicateObligation<'tcx>,
508    ) -> Result<EvaluationResult, OverflowError> {
509        if true {
    if !!self.infcx.next_trait_solver() {
        ::core::panicking::panic("assertion failed: !self.infcx.next_trait_solver()")
    };
};debug_assert!(!self.infcx.next_trait_solver());
510        self.evaluation_probe(|this| {
511            let goal = this
512                .infcx
513                .deeply_resolve_ignoring_regions((obligation.predicate, obligation.param_env));
514            let mut result = this.evaluate_predicate_recursively(
515                TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
516                obligation.clone(),
517            )?;
518            // If the predicate has done any inference, then downgrade the
519            // result to ambiguous.
520            if this.infcx.deeply_resolve_ignoring_regions(goal) != goal {
521                result = result.max(EvaluatedToAmbig);
522            }
523            Ok(result)
524        })
525    }
526
527    /// Computes the evaluation result of `op`, discarding any constraints.
528    ///
529    /// This also runs for leak check to allow higher ranked region errors to impact
530    /// selection. By default it checks for leaks from all universes created inside of
531    /// `op`, but this can be overwritten if necessary.
532    fn evaluation_probe(
533        &mut self,
534        op: impl FnOnce(&mut Self) -> Result<EvaluationResult, OverflowError>,
535    ) -> Result<EvaluationResult, OverflowError> {
536        self.infcx.probe(|snapshot| -> Result<EvaluationResult, OverflowError> {
537            let outer_universe = self.infcx.universe();
538            let result = op(self)?;
539
540            match self.infcx.leak_check(outer_universe, Some(snapshot)) {
541                Ok(()) => {}
542                Err(_) => return Ok(EvaluatedToErr),
543            }
544
545            if self.infcx.opaque_types_added_in_snapshot(snapshot) {
546                return Ok(result.max(EvaluatedToOkModuloOpaqueTypes));
547            }
548
549            if self.infcx.region_constraints_added_in_snapshot(snapshot) {
550                Ok(result.max(EvaluatedToOkModuloRegions))
551            } else {
552                Ok(result)
553            }
554        })
555    }
556
557    /// Evaluates the predicates in `predicates` recursively. This may
558    /// guide inference. If this is not desired, run it inside of a
559    /// is run within an inference probe.
560    /// `probe`.
561    {}
#[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_predicates_recursively",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(561u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("predicates")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("predicates");
                                                        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(&predicates)
                                                            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<EvaluationResult, OverflowError> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let mut result = EvaluatedToOk;
            for mut obligation in predicates {
                obligation.set_depth_from_parent(stack.depth());
                let eval =
                    self.evaluate_predicate_recursively(stack,
                            obligation.clone())?;
                if let EvaluatedToErr = eval {
                    return Ok(EvaluatedToErr);
                } else { result = cmp::max(result, eval); }
            }
            Ok(result)
        }
    }
}#[instrument(skip(self, stack), level = "debug")]
562    fn evaluate_predicates_recursively<'o, I>(
563        &mut self,
564        stack: TraitObligationStackList<'o, 'tcx>,
565        predicates: I,
566    ) -> Result<EvaluationResult, OverflowError>
567    where
568        I: IntoIterator<Item = PredicateObligation<'tcx>> + std::fmt::Debug,
569    {
570        let mut result = EvaluatedToOk;
571        for mut obligation in predicates {
572            obligation.set_depth_from_parent(stack.depth());
573            let eval = self.evaluate_predicate_recursively(stack, obligation.clone())?;
574            if let EvaluatedToErr = eval {
575                // fast-path - EvaluatedToErr is the top of the lattice,
576                // so we don't need to look on the other predicates.
577                return Ok(EvaluatedToErr);
578            } else {
579                result = cmp::max(result, eval);
580            }
581        }
582        Ok(result)
583    }
584
585    {}
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_predicate_recursively",
                                "rustc_trait_selection::traits::select",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(585u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("obligation")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("obligation");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("previous_stack")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("previous_stack");
                                                    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(&obligation)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&previous_stack.head())
                                                        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<EvaluationResult, OverflowError> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if true {
                            if !!self.infcx.next_trait_solver() {
                                ::core::panicking::panic("assertion failed: !self.infcx.next_trait_solver()")
                            };
                        };
                        match previous_stack.head() {
                            Some(h) =>
                                self.check_recursion_limit(&obligation, h.obligation)?,
                            None =>
                                self.check_recursion_limit(&obligation, &obligation)?,
                        }
                        if !self.infcx.disable_trait_solver_fast_paths() &&
                                sizedness_fast_path(self.tcx(), obligation.predicate,
                                    obligation.param_env) {
                            return Ok(EvaluatedToOk);
                        }
                        let bound_predicate = obligation.predicate.kind();
                        match bound_predicate.skip_binder() {
                            ty::PredicateKind::Clause(ty::ClauseKind::Trait(t)) => {
                                let t = bound_predicate.rebind(t);
                                if true {
                                    if !!t.has_escaping_bound_vars() {
                                        ::core::panicking::panic("assertion failed: !t.has_escaping_bound_vars()")
                                    };
                                };
                                let obligation = obligation.with(self.tcx(), t);
                                self.evaluate_trait_predicate_recursively(previous_stack,
                                    obligation)
                            }
                            ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(data))
                                => {
                                self.infcx.enter_forall(bound_predicate.rebind(data),
                                    |data|
                                        {
                                            match effects::evaluate_host_effect_obligation(self,
                                                    &obligation.with(self.tcx(), data)) {
                                                Ok(nested) =>
                                                    self.evaluate_predicates_recursively(previous_stack,
                                                        nested),
                                                Err(effects::EvaluationFailure::Ambiguous) =>
                                                    Ok(EvaluatedToAmbig),
                                                Err(effects::EvaluationFailure::NoSolution) =>
                                                    Ok(EvaluatedToErr),
                                            }
                                        })
                            }
                            ty::PredicateKind::Subtype(p) => {
                                let p = bound_predicate.rebind(p);
                                match self.infcx.subtype_predicate(&obligation.cause,
                                        obligation.param_env, p) {
                                    Ok(Ok(InferOk { obligations, .. })) => {
                                        self.evaluate_predicates_recursively(previous_stack,
                                            obligations)
                                    }
                                    Ok(Err(_)) => Ok(EvaluatedToErr),
                                    Err(..) => Ok(EvaluatedToAmbig),
                                }
                            }
                            ty::PredicateKind::Coerce(p) => {
                                let p = bound_predicate.rebind(p);
                                match self.infcx.coerce_predicate(&obligation.cause,
                                        obligation.param_env, p) {
                                    Ok(Ok(InferOk { obligations, .. })) => {
                                        self.evaluate_predicates_recursively(previous_stack,
                                            obligations)
                                    }
                                    Ok(Err(_)) => Ok(EvaluatedToErr),
                                    Err(..) => Ok(EvaluatedToAmbig),
                                }
                            }
                            ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term))
                                => {
                                if term.is_trivially_wf(self.tcx()) {
                                    return Ok(EvaluatedToOk);
                                }
                                let cache = previous_stack.cache;
                                let dfn = cache.next_dfn();
                                for stack_term in
                                    previous_stack.cache.wf_args.borrow().iter().rev() {
                                    if stack_term.0 != term { 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/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:690",
                                                            "rustc_trait_selection::traits::select",
                                                            ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(690u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                            ::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!("WellFormed({0:?}) on stack",
                                                                                        term) as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    if let Some(stack) = previous_stack.head {
                                        let cycle =
                                            stack.iter().take_while(|s| s.depth > stack_term.1);
                                        let tcx = self.tcx();
                                        let cycle =
                                            cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
                                        if self.coinductive_match(cycle) {
                                            stack.update_reached_depth(stack_term.1);
                                            return Ok(EvaluatedToOk);
                                        } else { return Ok(EvaluatedToAmbigStackDependent); }
                                    }
                                    return Ok(EvaluatedToOk);
                                }
                                match wf::obligations(self.infcx, obligation.param_env,
                                        obligation.cause.body_def_id,
                                        obligation.recursion_depth + 1, term, obligation.cause.span)
                                    {
                                    Some(obligations) => {
                                        cache.wf_args.borrow_mut().push((term,
                                                previous_stack.depth()));
                                        let result =
                                            self.evaluate_predicates_recursively(previous_stack,
                                                obligations);
                                        cache.wf_args.borrow_mut().pop();
                                        let result = result?;
                                        if !result.must_apply_modulo_regions() {
                                            cache.on_failure(dfn);
                                        }
                                        cache.on_completion(dfn);
                                        Ok(result)
                                    }
                                    None => Ok(EvaluatedToAmbig),
                                }
                            }
                            ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(pred))
                                => {
                                if pred.0.has_free_regions() || pred.0.has_bound_regions()
                                            || pred.0.has_non_region_infer() ||
                                        pred.0.has_non_region_param() {
                                    Ok(EvaluatedToOkModuloRegions)
                                } else { Ok(EvaluatedToOk) }
                            }
                            ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..))
                                => {
                                Ok(EvaluatedToOkModuloRegions)
                            }
                            ty::PredicateKind::DynCompatible(trait_def_id) => {
                                if self.tcx().is_dyn_compatible(trait_def_id) {
                                    Ok(EvaluatedToOk)
                                } else { Ok(EvaluatedToErr) }
                            }
                            ty::PredicateKind::Clause(ty::ClauseKind::Projection(data))
                                => {
                                let data = bound_predicate.rebind(data);
                                let project_obligation = obligation.with(self.tcx(), data);
                                match project::poly_project_and_unify_term(self,
                                        &project_obligation) {
                                    ProjectAndUnifyResult::Holds(mut subobligations) => {
                                        'compute_res:
                                            {
                                            if let Some(key) =
                                                        ProjectionCacheKey::from_poly_projection_obligation(self,
                                                            &project_obligation) &&
                                                    let Some(cached_res) =
                                                        self.infcx.inner.borrow_mut().projection_cache().is_complete(key)
                                                {
                                                break 'compute_res Ok(cached_res);
                                            }
                                            for subobligation in subobligations.iter_mut() {
                                                subobligation.set_depth_from_parent(obligation.recursion_depth);
                                            }
                                            let res =
                                                self.evaluate_predicates_recursively(previous_stack,
                                                    subobligations);
                                            if let Ok(eval_rslt) = res &&
                                                        (eval_rslt == EvaluatedToOk ||
                                                                eval_rslt == EvaluatedToOkModuloRegions) &&
                                                    let Some(key) =
                                                        ProjectionCacheKey::from_poly_projection_obligation(self,
                                                            &project_obligation) {
                                                self.infcx.inner.borrow_mut().projection_cache().complete(key,
                                                    eval_rslt);
                                            }
                                            res
                                        }
                                    }
                                    ProjectAndUnifyResult::FailedNormalization =>
                                        Ok(EvaluatedToAmbig),
                                    ProjectAndUnifyResult::Recursive =>
                                        Ok(EvaluatedToAmbigStackDependent),
                                    ProjectAndUnifyResult::MismatchedProjectionTypes(_) =>
                                        Ok(EvaluatedToErr),
                                }
                            }
                            ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol))
                                => {
                                if may_use_unstable_feature(self.infcx,
                                        obligation.param_env, symbol) {
                                    Ok(EvaluatedToOk)
                                } else { Ok(EvaluatedToAmbig) }
                            }
                            ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(alias_const))
                                => {
                                match const_evaluatable::is_const_evaluatable(self.infcx,
                                        alias_const, obligation.param_env, obligation.cause.span) {
                                    Ok(()) => Ok(EvaluatedToOk),
                                    Err(NotConstEvaluatable::MentionsInfer) =>
                                        Ok(EvaluatedToAmbig),
                                    Err(NotConstEvaluatable::MentionsParam) =>
                                        Ok(EvaluatedToErr),
                                    Err(_) => Ok(EvaluatedToErr),
                                }
                            }
                            ty::PredicateKind::ConstEquate(c1, c2) => {
                                let tcx = self.tcx();
                                if !tcx.features().generic_const_exprs() {
                                    {
                                        ::core::panicking::panic_fmt(format_args!("`ConstEquate` without a feature gate: {0:?} {1:?}",
                                                c1, c2));
                                    }
                                };
                                {
                                    let c1 = tcx.expand_abstract_consts(c1);
                                    let c2 = tcx.expand_abstract_consts(c2);
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:867",
                                                            "rustc_trait_selection::traits::select",
                                                            ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(867u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                            ::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!("evaluate_predicate_recursively: equating consts:\nc1= {0:?}\nc2= {1:?}",
                                                                                        c1, c2) as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    match (c1.kind(), c2.kind()) {
                                        (ty::ConstKind::Alias(_, a), ty::ConstKind::Alias(_, b)) if
                                            a.kind == b.kind &&
                                                #[allow(non_exhaustive_omitted_patterns)] match a.kind {
                                                    ty::AliasConstKind::Projection { .. } |
                                                        ty::AliasConstKind::InherentSelf { .. } |
                                                        ty::AliasConstKind::InherentImpl { .. } => true,
                                                    _ => false,
                                                } => {
                                            if let Ok(InferOk { obligations, value: () }) =
                                                    self.infcx.at(&obligation.cause,
                                                            obligation.param_env).eq(DefineOpaqueTypes::Yes,
                                                        ty::AliasTerm::from(a), ty::AliasTerm::from(b)) {
                                                return self.evaluate_predicates_recursively(previous_stack,
                                                        obligations);
                                            }
                                        }
                                        (_, ty::ConstKind::Alias(_, _)) |
                                            (ty::ConstKind::Alias(_, _), _) => (),
                                        (_, _) => {
                                            if let Ok(InferOk { obligations, value: () }) =
                                                    self.infcx.at(&obligation.cause,
                                                            obligation.param_env).eq(DefineOpaqueTypes::Yes, c1, c2) {
                                                return self.evaluate_predicates_recursively(previous_stack,
                                                        obligations);
                                            }
                                        }
                                    }
                                }
                                let evaluate =
                                    |c: ty::Const<'tcx>|
                                        {
                                            if let ty::ConstKind::Alias(_, _) = c.kind() {
                                                crate::traits::try_evaluate_const(self.infcx, c,
                                                    obligation.param_env, |v| Ok::<_, !>(v.skip_norm_wip()))
                                            } else { Ok(c) }
                                        };
                                match (evaluate(c1), evaluate(c2)) {
                                    (Ok(c1), Ok(c2)) => {
                                        match self.infcx.at(&obligation.cause,
                                                    obligation.param_env).eq(DefineOpaqueTypes::Yes, c1, c2) {
                                            Ok(inf_ok) =>
                                                self.evaluate_predicates_recursively(previous_stack,
                                                    inf_ok.into_obligations()),
                                            Err(_) => Ok(EvaluatedToErr),
                                        }
                                    }
                                    (Err(EvaluateConstErr::InvalidConstParamTy(..)), _) |
                                        (_, Err(EvaluateConstErr::InvalidConstParamTy(..))) =>
                                        Ok(EvaluatedToErr),
                                    (Err(EvaluateConstErr::EvaluationFailure(..)), _) |
                                        (_, Err(EvaluateConstErr::EvaluationFailure(..))) =>
                                        Ok(EvaluatedToErr),
                                    (Err(EvaluateConstErr::HasGenericsOrInfers), _) |
                                        (_, Err(EvaluateConstErr::HasGenericsOrInfers)) => {
                                        if c1.has_non_region_infer() || c2.has_non_region_infer() {
                                            Ok(EvaluatedToAmbig)
                                        } else { Ok(EvaluatedToErr) }
                                    }
                                }
                            }
                            ty::PredicateKind::NormalizesTo(..) => {
                                ::rustc_middle::util::bug::bug_fmt(format_args!("NormalizesTo is only used by the new solver"))
                            }
                            ty::PredicateKind::Ambiguous => Ok(EvaluatedToAmbig),
                            ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct,
                                ty)) => {
                                let ct = self.infcx.shallow_resolve_const(ct);
                                let ct_ty =
                                    match ct.kind() {
                                        ty::ConstKind::Infer(_) => { return Ok(EvaluatedToAmbig); }
                                        ty::ConstKind::Error(_) => return Ok(EvaluatedToOk),
                                        ty::ConstKind::Value(cv) => cv.ty,
                                        ty::ConstKind::Alias(_, alias_const) => {
                                            alias_const.type_of(self.tcx()).skip_norm_wip()
                                        }
                                        ty::ConstKind::Expr(_) => return Ok(EvaluatedToOk),
                                        ty::ConstKind::Placeholder(_) => {
                                            ::rustc_middle::util::bug::bug_fmt(format_args!("placeholder const {0:?} in old solver",
                                                    ct))
                                        }
                                        ty::ConstKind::Bound(_, _) =>
                                            ::rustc_middle::util::bug::bug_fmt(format_args!("escaping bound vars in {0:?}",
                                                    ct)),
                                        ty::ConstKind::Param(param_ct) => {
                                            param_ct.find_const_ty_from_env(obligation.param_env)
                                        }
                                    };
                                match self.infcx.at(&obligation.cause,
                                            obligation.param_env).eq(DefineOpaqueTypes::Yes, ct_ty, ty)
                                    {
                                    Ok(inf_ok) =>
                                        self.evaluate_predicates_recursively(previous_stack,
                                            inf_ok.into_obligations()),
                                    Err(_) => Ok(EvaluatedToErr),
                                }
                            }
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:585",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(585u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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(
586        level = "debug",
587        skip(self, previous_stack),
588        fields(previous_stack = ?previous_stack.head())
589        ret,
590    )]
591    fn evaluate_predicate_recursively<'o>(
592        &mut self,
593        previous_stack: TraitObligationStackList<'o, 'tcx>,
594        obligation: PredicateObligation<'tcx>,
595    ) -> Result<EvaluationResult, OverflowError> {
596        debug_assert!(!self.infcx.next_trait_solver());
597        // `previous_stack` stores a `PolyTraitObligation`, while `obligation` is
598        // a `PredicateObligation`. These are distinct types, so we can't
599        // use any `Option` combinator method that would force them to be
600        // the same.
601        match previous_stack.head() {
602            Some(h) => self.check_recursion_limit(&obligation, h.obligation)?,
603            None => self.check_recursion_limit(&obligation, &obligation)?,
604        }
605
606        if !self.infcx.disable_trait_solver_fast_paths()
607            && sizedness_fast_path(self.tcx(), obligation.predicate, obligation.param_env)
608        {
609            return Ok(EvaluatedToOk);
610        }
611
612        let bound_predicate = obligation.predicate.kind();
613        match bound_predicate.skip_binder() {
614            ty::PredicateKind::Clause(ty::ClauseKind::Trait(t)) => {
615                let t = bound_predicate.rebind(t);
616                debug_assert!(!t.has_escaping_bound_vars());
617                let obligation = obligation.with(self.tcx(), t);
618                self.evaluate_trait_predicate_recursively(previous_stack, obligation)
619            }
620
621            ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(data)) => {
622                self.infcx.enter_forall(bound_predicate.rebind(data), |data| {
623                    match effects::evaluate_host_effect_obligation(
624                        self,
625                        &obligation.with(self.tcx(), data),
626                    ) {
627                        Ok(nested) => self.evaluate_predicates_recursively(previous_stack, nested),
628                        Err(effects::EvaluationFailure::Ambiguous) => Ok(EvaluatedToAmbig),
629                        Err(effects::EvaluationFailure::NoSolution) => Ok(EvaluatedToErr),
630                    }
631                })
632            }
633
634            ty::PredicateKind::Subtype(p) => {
635                let p = bound_predicate.rebind(p);
636                // Does this code ever run?
637                match self.infcx.subtype_predicate(&obligation.cause, obligation.param_env, p) {
638                    Ok(Ok(InferOk { obligations, .. })) => {
639                        self.evaluate_predicates_recursively(previous_stack, obligations)
640                    }
641                    Ok(Err(_)) => Ok(EvaluatedToErr),
642                    Err(..) => Ok(EvaluatedToAmbig),
643                }
644            }
645
646            ty::PredicateKind::Coerce(p) => {
647                let p = bound_predicate.rebind(p);
648                // Does this code ever run?
649                match self.infcx.coerce_predicate(&obligation.cause, obligation.param_env, p) {
650                    Ok(Ok(InferOk { obligations, .. })) => {
651                        self.evaluate_predicates_recursively(previous_stack, obligations)
652                    }
653                    Ok(Err(_)) => Ok(EvaluatedToErr),
654                    Err(..) => Ok(EvaluatedToAmbig),
655                }
656            }
657
658            ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
659                if term.is_trivially_wf(self.tcx()) {
660                    return Ok(EvaluatedToOk);
661                }
662
663                // So, there is a bit going on here. First, `WellFormed` predicates
664                // are coinductive, like trait predicates with auto traits.
665                // This means that we need to detect if we have recursively
666                // evaluated `WellFormed(X)`. Otherwise, we would run into
667                // a "natural" overflow error.
668                //
669                // Now, the next question is whether we need to do anything
670                // special with caching. Considering the following tree:
671                // - `WF(Foo<T>)`
672                //   - `Bar<T>: Send`
673                //     - `WF(Foo<T>)`
674                //   - `Foo<T>: Trait`
675                // In this case, the innermost `WF(Foo<T>)` should return
676                // `EvaluatedToOk`, since it's coinductive. Then if
677                // `Bar<T>: Send` is resolved to `EvaluatedToOk`, it can be
678                // inserted into a cache (because without thinking about `WF`
679                // goals, it isn't in a cycle). If `Foo<T>: Trait` later doesn't
680                // hold, then `Bar<T>: Send` shouldn't hold. Therefore, we
681                // *do* need to keep track of coinductive cycles.
682
683                let cache = previous_stack.cache;
684                let dfn = cache.next_dfn();
685
686                for stack_term in previous_stack.cache.wf_args.borrow().iter().rev() {
687                    if stack_term.0 != term {
688                        continue;
689                    }
690                    debug!("WellFormed({:?}) on stack", term);
691                    if let Some(stack) = previous_stack.head {
692                        // Okay, let's imagine we have two different stacks:
693                        //   `T: NonAutoTrait -> WF(T) -> T: NonAutoTrait`
694                        //   `WF(T) -> T: NonAutoTrait -> WF(T)`
695                        // Because of this, we need to check that all
696                        // predicates between the WF goals are coinductive.
697                        // Otherwise, we can say that `T: NonAutoTrait` is
698                        // true.
699                        // Let's imagine we have a predicate stack like
700                        //         `Foo: Bar -> WF(T) -> T: NonAutoTrait -> T: Auto`
701                        // depth   ^1                    ^2                 ^3
702                        // and the current predicate is `WF(T)`. `wf_args`
703                        // would contain `(T, 1)`. We want to check all
704                        // trait predicates greater than `1`. The previous
705                        // stack would be `T: Auto`.
706                        let cycle = stack.iter().take_while(|s| s.depth > stack_term.1);
707                        let tcx = self.tcx();
708                        let cycle = cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
709                        if self.coinductive_match(cycle) {
710                            stack.update_reached_depth(stack_term.1);
711                            return Ok(EvaluatedToOk);
712                        } else {
713                            return Ok(EvaluatedToAmbigStackDependent);
714                        }
715                    }
716                    return Ok(EvaluatedToOk);
717                }
718
719                match wf::obligations(
720                    self.infcx,
721                    obligation.param_env,
722                    obligation.cause.body_def_id,
723                    obligation.recursion_depth + 1,
724                    term,
725                    obligation.cause.span,
726                ) {
727                    Some(obligations) => {
728                        cache.wf_args.borrow_mut().push((term, previous_stack.depth()));
729                        let result =
730                            self.evaluate_predicates_recursively(previous_stack, obligations);
731                        cache.wf_args.borrow_mut().pop();
732
733                        let result = result?;
734
735                        if !result.must_apply_modulo_regions() {
736                            cache.on_failure(dfn);
737                        }
738
739                        cache.on_completion(dfn);
740
741                        Ok(result)
742                    }
743                    None => Ok(EvaluatedToAmbig),
744                }
745            }
746
747            ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(pred)) => {
748                // A global type with no free lifetimes or generic parameters
749                // outlives anything.
750                if pred.0.has_free_regions()
751                    || pred.0.has_bound_regions()
752                    || pred.0.has_non_region_infer()
753                    || pred.0.has_non_region_param()
754                {
755                    Ok(EvaluatedToOkModuloRegions)
756                } else {
757                    Ok(EvaluatedToOk)
758                }
759            }
760
761            ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..)) => {
762                // We do not consider region relationships when evaluating trait matches.
763                Ok(EvaluatedToOkModuloRegions)
764            }
765
766            ty::PredicateKind::DynCompatible(trait_def_id) => {
767                // `DynCompatible` obligations are only emitted as
768                // nested obligations of `WellFormed` goals. It is quite
769                // rare, but possible, that we encounter them during
770                // evaluation. See #158665 for more details here.
771                if self.tcx().is_dyn_compatible(trait_def_id) {
772                    Ok(EvaluatedToOk)
773                } else {
774                    Ok(EvaluatedToErr)
775                }
776            }
777
778            ty::PredicateKind::Clause(ty::ClauseKind::Projection(data)) => {
779                let data = bound_predicate.rebind(data);
780                let project_obligation = obligation.with(self.tcx(), data);
781                match project::poly_project_and_unify_term(self, &project_obligation) {
782                    ProjectAndUnifyResult::Holds(mut subobligations) => {
783                        'compute_res: {
784                            // If we've previously marked this projection as 'complete', then
785                            // use the final cached result (either `EvaluatedToOk` or
786                            // `EvaluatedToOkModuloRegions`), and skip re-evaluating the
787                            // sub-obligations.
788                            if let Some(key) = ProjectionCacheKey::from_poly_projection_obligation(
789                                self,
790                                &project_obligation,
791                            ) && let Some(cached_res) =
792                                self.infcx.inner.borrow_mut().projection_cache().is_complete(key)
793                            {
794                                break 'compute_res Ok(cached_res);
795                            }
796
797                            // Need to explicitly set the depth of nested goals here as
798                            // projection obligations can cycle by themselves and in
799                            // `evaluate_predicates_recursively` we only add the depth
800                            // for parent trait goals because only these get added to the
801                            // `TraitObligationStackList`.
802                            for subobligation in subobligations.iter_mut() {
803                                subobligation.set_depth_from_parent(obligation.recursion_depth);
804                            }
805                            let res = self
806                                .evaluate_predicates_recursively(previous_stack, subobligations);
807                            if let Ok(eval_rslt) = res
808                                && (eval_rslt == EvaluatedToOk
809                                    || eval_rslt == EvaluatedToOkModuloRegions)
810                                && let Some(key) =
811                                    ProjectionCacheKey::from_poly_projection_obligation(
812                                        self,
813                                        &project_obligation,
814                                    )
815                            {
816                                // If the result is something that we can cache, then mark this
817                                // entry as 'complete'. This will allow us to skip evaluating the
818                                // subobligations at all the next time we evaluate the projection
819                                // predicate.
820                                self.infcx
821                                    .inner
822                                    .borrow_mut()
823                                    .projection_cache()
824                                    .complete(key, eval_rslt);
825                            }
826                            res
827                        }
828                    }
829                    ProjectAndUnifyResult::FailedNormalization => Ok(EvaluatedToAmbig),
830                    ProjectAndUnifyResult::Recursive => Ok(EvaluatedToAmbigStackDependent),
831                    ProjectAndUnifyResult::MismatchedProjectionTypes(_) => Ok(EvaluatedToErr),
832                }
833            }
834
835            ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
836                if may_use_unstable_feature(self.infcx, obligation.param_env, symbol) {
837                    Ok(EvaluatedToOk)
838                } else {
839                    Ok(EvaluatedToAmbig)
840                }
841            }
842
843            ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(alias_const)) => {
844                match const_evaluatable::is_const_evaluatable(
845                    self.infcx,
846                    alias_const,
847                    obligation.param_env,
848                    obligation.cause.span,
849                ) {
850                    Ok(()) => Ok(EvaluatedToOk),
851                    Err(NotConstEvaluatable::MentionsInfer) => Ok(EvaluatedToAmbig),
852                    Err(NotConstEvaluatable::MentionsParam) => Ok(EvaluatedToErr),
853                    Err(_) => Ok(EvaluatedToErr),
854                }
855            }
856
857            ty::PredicateKind::ConstEquate(c1, c2) => {
858                let tcx = self.tcx();
859                assert!(
860                    tcx.features().generic_const_exprs(),
861                    "`ConstEquate` without a feature gate: {c1:?} {c2:?}",
862                );
863
864                {
865                    let c1 = tcx.expand_abstract_consts(c1);
866                    let c2 = tcx.expand_abstract_consts(c2);
867                    debug!(
868                        "evaluate_predicate_recursively: equating consts:\nc1= {:?}\nc2= {:?}",
869                        c1, c2
870                    );
871
872                    match (c1.kind(), c2.kind()) {
873                        (ty::ConstKind::Alias(_, a), ty::ConstKind::Alias(_, b))
874                            if a.kind == b.kind
875                                && matches!(
876                                    a.kind,
877                                    ty::AliasConstKind::Projection { .. }
878                                        | ty::AliasConstKind::InherentSelf { .. }
879                                        | ty::AliasConstKind::InherentImpl { .. }
880                                ) =>
881                        {
882                            if let Ok(InferOk { obligations, value: () }) = self
883                                .infcx
884                                .at(&obligation.cause, obligation.param_env)
885                                // Can define opaque types as this is only reachable with
886                                // `generic_const_exprs`
887                                .eq(
888                                    DefineOpaqueTypes::Yes,
889                                    ty::AliasTerm::from(a),
890                                    ty::AliasTerm::from(b),
891                                )
892                            {
893                                return self
894                                    .evaluate_predicates_recursively(previous_stack, obligations);
895                            }
896                        }
897                        (_, ty::ConstKind::Alias(_, _)) | (ty::ConstKind::Alias(_, _), _) => (),
898                        (_, _) => {
899                            if let Ok(InferOk { obligations, value: () }) = self
900                                .infcx
901                                .at(&obligation.cause, obligation.param_env)
902                                // Can define opaque types as this is only reachable with
903                                // `generic_const_exprs`
904                                .eq(DefineOpaqueTypes::Yes, c1, c2)
905                            {
906                                return self
907                                    .evaluate_predicates_recursively(previous_stack, obligations);
908                            }
909                        }
910                    }
911                }
912
913                let evaluate = |c: ty::Const<'tcx>| {
914                    if let ty::ConstKind::Alias(_, _) = c.kind() {
915                        crate::traits::try_evaluate_const(
916                            self.infcx,
917                            c,
918                            obligation.param_env,
919                            |v| Ok::<_, !>(v.skip_norm_wip()),
920                        )
921                    } else {
922                        Ok(c)
923                    }
924                };
925
926                match (evaluate(c1), evaluate(c2)) {
927                    (Ok(c1), Ok(c2)) => {
928                        match self.infcx.at(&obligation.cause, obligation.param_env).eq(
929                            // Can define opaque types as this is only reachable with
930                            // `generic_const_exprs`
931                            DefineOpaqueTypes::Yes,
932                            c1,
933                            c2,
934                        ) {
935                            Ok(inf_ok) => self.evaluate_predicates_recursively(
936                                previous_stack,
937                                inf_ok.into_obligations(),
938                            ),
939                            Err(_) => Ok(EvaluatedToErr),
940                        }
941                    }
942                    (Err(EvaluateConstErr::InvalidConstParamTy(..)), _)
943                    | (_, Err(EvaluateConstErr::InvalidConstParamTy(..))) => Ok(EvaluatedToErr),
944                    (Err(EvaluateConstErr::EvaluationFailure(..)), _)
945                    | (_, Err(EvaluateConstErr::EvaluationFailure(..))) => Ok(EvaluatedToErr),
946                    (Err(EvaluateConstErr::HasGenericsOrInfers), _)
947                    | (_, Err(EvaluateConstErr::HasGenericsOrInfers)) => {
948                        if c1.has_non_region_infer() || c2.has_non_region_infer() {
949                            Ok(EvaluatedToAmbig)
950                        } else {
951                            // Two different constants using generic parameters ~> error.
952                            Ok(EvaluatedToErr)
953                        }
954                    }
955                }
956            }
957            ty::PredicateKind::NormalizesTo(..) => {
958                bug!("NormalizesTo is only used by the new solver")
959            }
960            ty::PredicateKind::Ambiguous => Ok(EvaluatedToAmbig),
961            ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
962                let ct = self.infcx.shallow_resolve_const(ct);
963                let ct_ty = match ct.kind() {
964                    ty::ConstKind::Infer(_) => {
965                        return Ok(EvaluatedToAmbig);
966                    }
967                    ty::ConstKind::Error(_) => return Ok(EvaluatedToOk),
968                    ty::ConstKind::Value(cv) => cv.ty,
969                    ty::ConstKind::Alias(_, alias_const) => {
970                        alias_const.type_of(self.tcx()).skip_norm_wip()
971                    }
972                    // FIXME(generic_const_exprs): See comment in `fulfill.rs`
973                    ty::ConstKind::Expr(_) => return Ok(EvaluatedToOk),
974                    ty::ConstKind::Placeholder(_) => {
975                        bug!("placeholder const {:?} in old solver", ct)
976                    }
977                    ty::ConstKind::Bound(_, _) => bug!("escaping bound vars in {:?}", ct),
978                    ty::ConstKind::Param(param_ct) => {
979                        param_ct.find_const_ty_from_env(obligation.param_env)
980                    }
981                };
982
983                match self.infcx.at(&obligation.cause, obligation.param_env).eq(
984                    // Only really exercised by generic_const_exprs
985                    DefineOpaqueTypes::Yes,
986                    ct_ty,
987                    ty,
988                ) {
989                    Ok(inf_ok) => self
990                        .evaluate_predicates_recursively(previous_stack, inf_ok.into_obligations()),
991                    Err(_) => Ok(EvaluatedToErr),
992                }
993            }
994        }
995    }
996
997    {}
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_trait_predicate_recursively",
                                "rustc_trait_selection::traits::select",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(997u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("obligation")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("obligation");
                                                    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(&obligation)
                                                        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<EvaluationResult, OverflowError> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if !self.typing_mode().is_coherence() &&
                                    obligation.is_global() &&
                                obligation.param_env.caller_bounds().all(|bound|
                                        bound.has_param()) {
                            {
                                use ::tracing::__macro_support::Callsite as _;
                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                    {
                                        static META: ::tracing::Metadata<'static> =
                                            {
                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1010",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(1010u32),
                                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                    ::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!("in global")
                                                                        as &dyn ::tracing::field::Value))])
                                        });
                                } else { ; }
                            };
                            obligation.param_env = ty::ParamEnv::empty();
                        }
                        let stack = self.push_stack(previous_stack, &obligation);
                        let fresh_trait_pred = stack.fresh_trait_pred;
                        let param_env = obligation.param_env;
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1018",
                                                "rustc_trait_selection::traits::select",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(1018u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("fresh_trait_pred")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("fresh_trait_pred");
                                                                    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(&fresh_trait_pred)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        if let Some(result) =
                                self.check_evaluation_cache(param_env, fresh_trait_pred) {
                            {
                                use ::tracing::__macro_support::Callsite as _;
                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                    {
                                        static META: ::tracing::Metadata<'static> =
                                            {
                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1023",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(1023u32),
                                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                    ::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!("CACHE HIT")
                                                                        as &dyn ::tracing::field::Value))])
                                        });
                                } else { ; }
                            };
                            return Ok(result);
                        }
                        if let Some(result) =
                                stack.cache().get_provisional(fresh_trait_pred) {
                            {
                                use ::tracing::__macro_support::Callsite as _;
                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                    {
                                        static META: ::tracing::Metadata<'static> =
                                            {
                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1028",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(1028u32),
                                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                    ::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!("PROVISIONAL CACHE HIT")
                                                                        as &dyn ::tracing::field::Value))])
                                        });
                                } else { ; }
                            };
                            stack.update_reached_depth(result.reached_depth);
                            return Ok(result.result);
                        }
                        if let Some(cycle_result) =
                                self.check_evaluation_cycle(&stack) {
                            return Ok(cycle_result);
                        }
                        let (result, dep_node) =
                            self.in_task(|this|
                                    {
                                        let mut result = this.evaluate_stack(&stack)?;
                                        if EvaluationResult::EvaluatedToErr == result &&
                                                    fresh_trait_pred.has_aliases() &&
                                                fresh_trait_pred.is_global() {
                                            let mut nested_obligations = PredicateObligations::new();
                                            let predicate =
                                                normalize_with_depth_to(this, param_env,
                                                    obligation.cause.clone(), obligation.recursion_depth + 1,
                                                    Unnormalized::new_wip(obligation.predicate),
                                                    &mut nested_obligations);
                                            if predicate != obligation.predicate {
                                                let mut nested_result = EvaluationResult::EvaluatedToOk;
                                                for obligation in nested_obligations {
                                                    nested_result =
                                                        cmp::max(this.evaluate_predicate_recursively(previous_stack,
                                                                    obligation)?, nested_result);
                                                }
                                                if nested_result.must_apply_modulo_regions() {
                                                    let obligation = obligation.with(this.tcx(), predicate);
                                                    result =
                                                        cmp::max(nested_result,
                                                            this.evaluate_trait_predicate_recursively(previous_stack,
                                                                    obligation)?);
                                                }
                                            }
                                        }
                                        Ok::<_, OverflowError>(result)
                                    });
                        let result = result?;
                        if !result.must_apply_modulo_regions() {
                            stack.cache().on_failure(stack.dfn);
                        }
                        let reached_depth = stack.reached_depth.get();
                        if reached_depth >= stack.depth {
                            {
                                use ::tracing::__macro_support::Callsite as _;
                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                    {
                                        static META: ::tracing::Metadata<'static> =
                                            {
                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1095",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(1095u32),
                                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                    ::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!("CACHE MISS")
                                                                        as &dyn ::tracing::field::Value))])
                                        });
                                } else { ; }
                            };
                            self.insert_evaluation_cache(param_env, fresh_trait_pred,
                                dep_node, result);
                            stack.cache().on_completion(stack.dfn);
                        } else if let Some(_guar) = self.infcx.tainted_by_errors() {
                            {
                                use ::tracing::__macro_support::Callsite as _;
                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                    {
                                        static META: ::tracing::Metadata<'static> =
                                            {
                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1103",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(1103u32),
                                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                    ::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!("CACHE MISS (tainted by errors)")
                                                                        as &dyn ::tracing::field::Value))])
                                        });
                                } else { ; }
                            };
                            self.insert_evaluation_cache(param_env, fresh_trait_pred,
                                dep_node, result);
                            stack.cache().on_completion(stack.dfn);
                        } else {
                            {
                                use ::tracing::__macro_support::Callsite as _;
                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                    {
                                        static META: ::tracing::Metadata<'static> =
                                            {
                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1107",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(1107u32),
                                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                    ::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!("PROVISIONAL")
                                                                        as &dyn ::tracing::field::Value))])
                                        });
                                } else { ; }
                            };
                            {
                                use ::tracing::__macro_support::Callsite as _;
                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                    {
                                        static META: ::tracing::Metadata<'static> =
                                            {
                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1108",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(1108u32),
                                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                    ::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!("caching provisionally because {0:?} is a cycle participant (at depth {1}, reached depth {2})",
                                                                                fresh_trait_pred, stack.depth, reached_depth) as
                                                                        &dyn ::tracing::field::Value))])
                                        });
                                } else { ; }
                            };
                            stack.cache().insert_provisional(stack.dfn, reached_depth,
                                fresh_trait_pred, result);
                        }
                        Ok(result)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:997",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(997u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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(skip(self, previous_stack), level = "debug", ret)]
998    fn evaluate_trait_predicate_recursively<'o>(
999        &mut self,
1000        previous_stack: TraitObligationStackList<'o, 'tcx>,
1001        mut obligation: PolyTraitObligation<'tcx>,
1002    ) -> Result<EvaluationResult, OverflowError> {
1003        if !self.typing_mode().is_coherence()
1004            && obligation.is_global()
1005            && obligation.param_env.caller_bounds().all(|bound| bound.has_param())
1006        {
1007            // If a param env has no global bounds, global obligations do not
1008            // depend on its particular value in order to work, so we can clear
1009            // out the param env and get better caching.
1010            debug!("in global");
1011            obligation.param_env = ty::ParamEnv::empty();
1012        }
1013
1014        let stack = self.push_stack(previous_stack, &obligation);
1015        let fresh_trait_pred = stack.fresh_trait_pred;
1016        let param_env = obligation.param_env;
1017
1018        debug!(?fresh_trait_pred);
1019
1020        // If a trait predicate is in the (local or global) evaluation cache,
1021        // then we know it holds without cycles.
1022        if let Some(result) = self.check_evaluation_cache(param_env, fresh_trait_pred) {
1023            debug!("CACHE HIT");
1024            return Ok(result);
1025        }
1026
1027        if let Some(result) = stack.cache().get_provisional(fresh_trait_pred) {
1028            debug!("PROVISIONAL CACHE HIT");
1029            stack.update_reached_depth(result.reached_depth);
1030            return Ok(result.result);
1031        }
1032
1033        // Check if this is a match for something already on the
1034        // stack. If so, we don't want to insert the result into the
1035        // main cache (it is cycle dependent) nor the provisional
1036        // cache (which is meant for things that have completed but
1037        // for a "backedge" -- this result *is* the backedge).
1038        if let Some(cycle_result) = self.check_evaluation_cycle(&stack) {
1039            return Ok(cycle_result);
1040        }
1041
1042        let (result, dep_node) = self.in_task(|this| {
1043            let mut result = this.evaluate_stack(&stack)?;
1044
1045            // fix issue #103563, we don't normalize
1046            // nested obligations which produced by `TraitDef` candidate
1047            // (i.e. using bounds on assoc items as assumptions).
1048            // because we don't have enough information to
1049            // normalize these obligations before evaluating.
1050            // so we will try to normalize the obligation and evaluate again.
1051            // we will replace it with new solver in the future.
1052            if EvaluationResult::EvaluatedToErr == result
1053                && fresh_trait_pred.has_aliases()
1054                && fresh_trait_pred.is_global()
1055            {
1056                let mut nested_obligations = PredicateObligations::new();
1057                let predicate = normalize_with_depth_to(
1058                    this,
1059                    param_env,
1060                    obligation.cause.clone(),
1061                    obligation.recursion_depth + 1,
1062                    Unnormalized::new_wip(obligation.predicate),
1063                    &mut nested_obligations,
1064                );
1065                if predicate != obligation.predicate {
1066                    let mut nested_result = EvaluationResult::EvaluatedToOk;
1067                    for obligation in nested_obligations {
1068                        nested_result = cmp::max(
1069                            this.evaluate_predicate_recursively(previous_stack, obligation)?,
1070                            nested_result,
1071                        );
1072                    }
1073
1074                    if nested_result.must_apply_modulo_regions() {
1075                        let obligation = obligation.with(this.tcx(), predicate);
1076                        result = cmp::max(
1077                            nested_result,
1078                            this.evaluate_trait_predicate_recursively(previous_stack, obligation)?,
1079                        );
1080                    }
1081                }
1082            }
1083
1084            Ok::<_, OverflowError>(result)
1085        });
1086
1087        let result = result?;
1088
1089        if !result.must_apply_modulo_regions() {
1090            stack.cache().on_failure(stack.dfn);
1091        }
1092
1093        let reached_depth = stack.reached_depth.get();
1094        if reached_depth >= stack.depth {
1095            debug!("CACHE MISS");
1096            self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
1097            stack.cache().on_completion(stack.dfn);
1098        } else if let Some(_guar) = self.infcx.tainted_by_errors() {
1099            // When an error has occurred, we allow global caching of results even if they
1100            // appear stack-dependent. This prevents exponential re-evaluation of cycles
1101            // in the presence of errors, avoiding compiler hangs like #150907.
1102            // This is safe because compilation will fail anyway.
1103            debug!("CACHE MISS (tainted by errors)");
1104            self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
1105            stack.cache().on_completion(stack.dfn);
1106        } else {
1107            debug!("PROVISIONAL");
1108            debug!(
1109                "caching provisionally because {:?} \
1110                 is a cycle participant (at depth {}, reached depth {})",
1111                fresh_trait_pred, stack.depth, reached_depth,
1112            );
1113
1114            stack.cache().insert_provisional(stack.dfn, reached_depth, fresh_trait_pred, result);
1115        }
1116
1117        Ok(result)
1118    }
1119
1120    /// If there is any previous entry on the stack that precisely
1121    /// matches this obligation, then we can assume that the
1122    /// obligation is satisfied for now (still all other conditions
1123    /// must be met of course). One obvious case this comes up is
1124    /// marker traits like `Send`. Think of a linked list:
1125    ///
1126    ///     struct List<T> { data: T, next: Option<Box<List<T>>> }
1127    ///
1128    /// `Box<List<T>>` will be `Send` if `T` is `Send` and
1129    /// `Option<Box<List<T>>>` is `Send`, and in turn
1130    /// `Option<Box<List<T>>>` is `Send` if `Box<List<T>>` is
1131    /// `Send`.
1132    ///
1133    /// Note that we do this comparison using the `fresh_trait_pred`
1134    /// fields. Because these have all been freshened using
1135    /// `self.freshener`, we can be sure that (a) this will not
1136    /// affect the inferencer state and (b) that if we see two
1137    /// fresh regions with the same index, they refer to the same
1138    /// unbound type variable.
1139    fn check_evaluation_cycle(
1140        &mut self,
1141        stack: &TraitObligationStack<'_, 'tcx>,
1142    ) -> Option<EvaluationResult> {
1143        if let Some(cycle_depth) = stack
1144            .iter()
1145            .skip(1) // Skip top-most frame.
1146            .find(|prev| {
1147                stack.obligation.param_env == prev.obligation.param_env
1148                    && stack.fresh_trait_pred == prev.fresh_trait_pred
1149            })
1150            .map(|stack| stack.depth)
1151        {
1152            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1152",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1152u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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!("evaluate_stack --> recursive at depth {0}",
                                                    cycle_depth) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("evaluate_stack --> recursive at depth {}", cycle_depth);
1153
1154            // If we have a stack like `A B C D E A`, where the top of
1155            // the stack is the final `A`, then this will iterate over
1156            // `A, E, D, C, B` -- i.e., all the participants apart
1157            // from the cycle head. We mark them as participating in a
1158            // cycle. This suppresses caching for those nodes. See
1159            // `in_cycle` field for more details.
1160            stack.update_reached_depth(cycle_depth);
1161
1162            // Subtle: when checking for a coinductive cycle, we do
1163            // not compare using the "freshened trait refs" (which
1164            // have erased regions) but rather the fully explicit
1165            // trait refs. This is important because it's only a cycle
1166            // if the regions match exactly.
1167            let cycle = stack.iter().skip(1).take_while(|s| s.depth >= cycle_depth);
1168            let tcx = self.tcx();
1169            let cycle = cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
1170            if self.coinductive_match(cycle) {
1171                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1171",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1171u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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!("evaluate_stack --> recursive, coinductive")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("evaluate_stack --> recursive, coinductive");
1172                Some(EvaluatedToOk)
1173            } else {
1174                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1174",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1174u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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!("evaluate_stack --> recursive, inductive")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("evaluate_stack --> recursive, inductive");
1175                Some(EvaluatedToAmbigStackDependent)
1176            }
1177        } else {
1178            None
1179        }
1180    }
1181
1182    fn evaluate_stack<'o>(
1183        &mut self,
1184        stack: &TraitObligationStack<'o, 'tcx>,
1185    ) -> Result<EvaluationResult, OverflowError> {
1186        if true {
    if !!self.infcx.next_trait_solver() {
        ::core::panicking::panic("assertion failed: !self.infcx.next_trait_solver()")
    };
};debug_assert!(!self.infcx.next_trait_solver());
1187        // In intercrate mode, whenever any of the generics are unbound,
1188        // there can always be an impl. Even if there are no impls in
1189        // this crate, perhaps the type would be unified with
1190        // something from another crate that does provide an impl.
1191        //
1192        // In intra mode, we must still be conservative. The reason is
1193        // that we want to avoid cycles. Imagine an impl like:
1194        //
1195        //     impl<T:Eq> Eq for Vec<T>
1196        //
1197        // and a trait reference like `$0 : Eq` where `$0` is an
1198        // unbound variable. When we evaluate this trait-reference, we
1199        // will unify `$0` with `Vec<$1>` (for some fresh variable
1200        // `$1`), on the condition that `$1 : Eq`. We will then wind
1201        // up with many candidates (since that are other `Eq` impls
1202        // that apply) and try to winnow things down. This results in
1203        // a recursive evaluation that `$1 : Eq` -- as you can
1204        // imagine, this is just where we started. To avoid that, we
1205        // check for unbound variables and return an ambiguous (hence possible)
1206        // match if we've seen this trait before.
1207        //
1208        // This suffices to allow chains like `FnMut` implemented in
1209        // terms of `Fn` etc, but we could probably make this more
1210        // precise still.
1211        //
1212        // FIXME(min_generic_const_args): Consider consts as well?
1213        let unbound_input_types =
1214            stack.fresh_trait_pred.skip_binder().trait_ref.args.types().any(|ty| ty.is_fresh());
1215
1216        if unbound_input_types
1217            && stack.iter().skip(1).any(|prev| {
1218                stack.obligation.param_env == prev.obligation.param_env
1219                    && self.match_fresh_trait_preds(stack.fresh_trait_pred, prev.fresh_trait_pred)
1220            })
1221        {
1222            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1222",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1222u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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!("evaluate_stack --> unbound argument, recursive --> giving up")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("evaluate_stack --> unbound argument, recursive --> giving up");
1223            return Ok(EvaluatedToAmbigStackDependent);
1224        }
1225
1226        match self.candidate_from_obligation(stack) {
1227            Ok(Some(c)) => self.evaluate_candidate(stack, &c),
1228            Ok(None) => Ok(EvaluatedToAmbig),
1229            Err(SelectionError::Overflow(OverflowError::Canonical)) => {
1230                Err(OverflowError::Canonical)
1231            }
1232            Err(..) => Ok(EvaluatedToErr),
1233        }
1234    }
1235
1236    /// For defaulted traits, we use a co-inductive strategy to solve, so
1237    /// that recursion is ok. This routine returns `true` if the top of the
1238    /// stack (`cycle[0]`):
1239    ///
1240    /// - is a coinductive trait: an auto-trait or `Sized`,
1241    /// - it also appears in the backtrace at some position `X`,
1242    /// - all the predicates at positions `X..` between `X` and the top are
1243    ///   also coinductive traits.
1244    pub(crate) fn coinductive_match<I>(&mut self, mut cycle: I) -> bool
1245    where
1246        I: Iterator<Item = ty::Predicate<'tcx>>,
1247    {
1248        cycle.all(|p| match p.kind().skip_binder() {
1249            ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
1250                self.infcx.tcx.trait_is_coinductive(data.def_id())
1251            }
1252            ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => {
1253                // FIXME(generic_const_exprs): GCE needs well-formedness predicates to be
1254                // coinductive, but GCE is on the way out anyways, so this should eventually
1255                // be replaced with `false`.
1256                self.infcx.tcx.features().generic_const_exprs()
1257            }
1258            _ => false,
1259        })
1260    }
1261
1262    /// Further evaluates `candidate` to decide whether all type parameters match and whether nested
1263    /// obligations are met. Returns whether `candidate` remains viable after this further
1264    /// scrutiny.
1265    {}
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_candidate",
                                "rustc_trait_selection::traits::select",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1265u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("candidate")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("candidate");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("depth")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("depth");
                                                    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(&candidate)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&stack.obligation.recursion_depth
                                                        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<EvaluationResult, OverflowError> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let mut result =
                            self.evaluation_probe(|this|
                                        {
                                            match this.confirm_candidate(stack.obligation,
                                                    candidate.clone()) {
                                                Ok(selection) => {
                                                    {
                                                        use ::tracing::__macro_support::Callsite as _;
                                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                                            {
                                                                static META: ::tracing::Metadata<'static> =
                                                                    {
                                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1279",
                                                                            "rustc_trait_selection::traits::select",
                                                                            ::tracing::Level::DEBUG,
                                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                                            ::tracing_core::__macro_support::Option::Some(1279u32),
                                                                            ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                                            ::tracing_core::field::FieldSet::new(&[{
                                                                                                const NAME:
                                                                                                    ::tracing::__macro_support::FieldName<{
                                                                                                        ::tracing::__macro_support::FieldName::len("selection")
                                                                                                    }> =
                                                                                                    ::tracing::__macro_support::FieldName::new("selection");
                                                                                                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(&selection)
                                                                                                as &dyn ::tracing::field::Value))])
                                                                });
                                                        } else { ; }
                                                    };
                                                    if let ImplSource::Builtin(..) = selection &&
                                                            this.typing_mode().is_reflection() {
                                                        return Ok(EvaluatedToErr);
                                                    }
                                                    this.evaluate_predicates_recursively(stack.list(),
                                                        selection.nested_obligations().into_iter())
                                                }
                                                Err(..) => Ok(EvaluatedToErr),
                                            }
                                        })?;
                        if stack.fresh_trait_pred.has_erased_regions() {
                            result = result.max(EvaluatedToOkModuloRegions);
                        }
                        Ok(result)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1265",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1265u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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(
1266        level = "debug",
1267        skip(self, stack),
1268        fields(depth = stack.obligation.recursion_depth),
1269        ret
1270    )]
1271    fn evaluate_candidate<'o>(
1272        &mut self,
1273        stack: &TraitObligationStack<'o, 'tcx>,
1274        candidate: &SelectionCandidate<'tcx>,
1275    ) -> Result<EvaluationResult, OverflowError> {
1276        let mut result = self.evaluation_probe(|this| {
1277            match this.confirm_candidate(stack.obligation, candidate.clone()) {
1278                Ok(selection) => {
1279                    debug!(?selection);
1280                    if let ImplSource::Builtin(..) = selection
1281                        && this.typing_mode().is_reflection()
1282                    {
1283                        return Ok(EvaluatedToErr);
1284                    }
1285                    this.evaluate_predicates_recursively(
1286                        stack.list(),
1287                        selection.nested_obligations().into_iter(),
1288                    )
1289                }
1290                Err(..) => Ok(EvaluatedToErr),
1291            }
1292        })?;
1293
1294        // If we erased any lifetimes, then we want to use
1295        // `EvaluatedToOkModuloRegions` instead of `EvaluatedToOk`
1296        // as your final result. The result will be cached using
1297        // the freshened trait predicate as a key, so we need
1298        // our result to be correct by *any* choice of original lifetimes,
1299        // not just the lifetime choice for this particular (non-erased)
1300        // predicate.
1301        // See issue #80691
1302        if stack.fresh_trait_pred.has_erased_regions() {
1303            result = result.max(EvaluatedToOkModuloRegions);
1304        }
1305
1306        Ok(result)
1307    }
1308
1309    fn check_evaluation_cache(
1310        &self,
1311        param_env: ty::ParamEnv<'tcx>,
1312        trait_pred: ty::PolyTraitClause<'tcx>,
1313    ) -> Option<EvaluationResult> {
1314        let infcx = self.infcx;
1315        let tcx = infcx.tcx;
1316        if self.can_use_global_caches(param_env, trait_pred) {
1317            let key = (infcx.typing_env(param_env), trait_pred);
1318            if let Some(res) = tcx.caches.evaluation_cache.get(&key, tcx) {
1319                Some(res)
1320            } else {
1321                if true {
    {
        match (&infcx.evaluation_cache.get(&(param_env, trait_pred), tcx),
                &None) {
            (left_val, right_val) => {
                if !(*left_val == *right_val) {
                    let kind = ::core::panicking::AssertKind::Eq;
                    ::core::panicking::assert_failed(kind, &*left_val,
                        &*right_val, ::core::option::Option::None);
                }
            }
        }
    };
};debug_assert_eq!(infcx.evaluation_cache.get(&(param_env, trait_pred), tcx), None);
1322                None
1323            }
1324        } else {
1325            self.infcx.evaluation_cache.get(&(param_env, trait_pred), tcx)
1326        }
1327    }
1328
1329    fn insert_evaluation_cache(
1330        &mut self,
1331        param_env: ty::ParamEnv<'tcx>,
1332        trait_pred: ty::PolyTraitClause<'tcx>,
1333        dep_node: DepNodeIndex,
1334        result: EvaluationResult,
1335    ) {
1336        // Avoid caching results that depend on more than just the trait-ref
1337        // - the stack can create recursion.
1338        if result.is_stack_dependent() {
1339            return;
1340        }
1341
1342        let infcx = self.infcx;
1343        let tcx = infcx.tcx;
1344        if self.can_use_global_caches(param_env, trait_pred) {
1345            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1345",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1345u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("trait_pred")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("trait_pred");
                                            NAME.as_str()
                                        },
                                        {
                                            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(&format_args!("insert_evaluation_cache global")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_pred)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&result)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?trait_pred, ?result, "insert_evaluation_cache global");
1346            // This may overwrite the cache with the same value
1347            tcx.caches.evaluation_cache.insert(
1348                (infcx.typing_env(param_env), trait_pred),
1349                dep_node,
1350                result,
1351            );
1352            return;
1353        } else {
1354            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1354",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1354u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("trait_pred")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("trait_pred");
                                            NAME.as_str()
                                        },
                                        {
                                            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(&format_args!("insert_evaluation_cache local")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_pred)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&result)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?trait_pred, ?result, "insert_evaluation_cache local");
1355            self.infcx.evaluation_cache.insert((param_env, trait_pred), dep_node, result);
1356        }
1357    }
1358
1359    fn check_recursion_depth<T>(
1360        &self,
1361        depth: usize,
1362        error_obligation: &Obligation<'tcx, T>,
1363    ) -> Result<(), OverflowError>
1364    where
1365        T: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + Clone,
1366    {
1367        if !self.infcx.tcx.recursion_limit().value_within_limit(depth) {
1368            match self.query_mode {
1369                TraitQueryMode::Standard => {
1370                    if let Some(e) = self.infcx.tainted_by_errors() {
1371                        return Err(OverflowError::Error(e));
1372                    }
1373                    self.infcx.err_ctxt().report_overflow_obligation(error_obligation, true);
1374                }
1375                TraitQueryMode::Canonical => {
1376                    return Err(OverflowError::Canonical);
1377                }
1378            }
1379        }
1380        Ok(())
1381    }
1382
1383    /// Checks that the recursion limit has not been exceeded.
1384    ///
1385    /// The weird return type of this function allows it to be used with the `try` (`?`)
1386    /// operator within certain functions.
1387    #[inline(always)]
1388    fn check_recursion_limit<T: Display + TypeFoldable<TyCtxt<'tcx>>, V>(
1389        &self,
1390        obligation: &Obligation<'tcx, T>,
1391        error_obligation: &Obligation<'tcx, V>,
1392    ) -> Result<(), OverflowError>
1393    where
1394        V: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + Clone,
1395    {
1396        self.check_recursion_depth(obligation.recursion_depth, error_obligation)
1397    }
1398
1399    fn in_task<OP, R>(&mut self, op: OP) -> (R, DepNodeIndex)
1400    where
1401        OP: FnOnce(&mut Self) -> R,
1402    {
1403        self.tcx().dep_graph.with_anon_task(self.tcx(), DepKind::TraitSelect, || op(self))
1404    }
1405
1406    /// filter_impls filters candidates that have a positive impl for a negative
1407    /// goal and a negative impl for a positive goal
1408    {}
#[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("filter_impls",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1408u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("obligation");
                                                        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(&obligation)
                                                            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: Vec<SelectionCandidate<'tcx>> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1414",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1414u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                    ::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!("{0:#?}",
                                                                candidates) as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let tcx = self.tcx();
            candidates.retain(|candidate|
                    {
                        if let &ImplCandidate(def_id) = candidate {
                            match (tcx.impl_polarity(def_id), obligation.polarity()) {
                                (ty::ImplPolarity::Positive, ty::ClausePolarity::Positive) |
                                    (ty::ImplPolarity::Negative, ty::ClausePolarity::Negative)
                                    => true,
                                _ => false,
                            }
                        } else { true }
                    });
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1431",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1431u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                    ::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!("{0:#?}",
                                                                candidates) as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            candidates
        }
    }
}#[instrument(level = "debug", skip(self, candidates))]
1409    fn filter_impls(
1410        &mut self,
1411        mut candidates: Vec<SelectionCandidate<'tcx>>,
1412        obligation: &PolyTraitObligation<'tcx>,
1413    ) -> Vec<SelectionCandidate<'tcx>> {
1414        trace!("{candidates:#?}");
1415        let tcx = self.tcx();
1416
1417        candidates.retain(|candidate| {
1418            if let &ImplCandidate(def_id) = candidate {
1419                match (tcx.impl_polarity(def_id), obligation.polarity()) {
1420                    (ty::ImplPolarity::Positive, ty::ClausePolarity::Positive)
1421                    | (ty::ImplPolarity::Negative, ty::ClausePolarity::Negative) => true,
1422
1423                    // remove impl candidates with mismatched polarity to the obligation
1424                    _ => false,
1425                }
1426            } else {
1427                true
1428            }
1429        });
1430
1431        trace!("{candidates:#?}");
1432        candidates
1433    }
1434
1435    fn is_knowable<'o>(&mut self, stack: &TraitObligationStack<'o, 'tcx>) -> Result<(), Conflict> {
1436        let obligation = &stack.obligation;
1437        match self.typing_mode() {
1438            TypingMode::Coherence => {}
1439            TypingMode::Typeck { .. }
1440            | TypingMode::PostTypeckUntilBorrowck { .. }
1441            | TypingMode::Reflection
1442            | TypingMode::PostBorrowck { .. }
1443            | TypingMode::PostAnalysis
1444            | TypingMode::Codegen => return Ok(()),
1445        }
1446
1447        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1447",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1447u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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!("is_knowable()")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("is_knowable()");
1448
1449        let predicate = self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
1450
1451        // Okay to skip binder because of the nature of the
1452        // trait-ref-is-knowable check, which does not care about
1453        // bound regions.
1454        let trait_ref = predicate.skip_binder().trait_ref;
1455
1456        coherence::trait_ref_is_knowable(self.infcx, trait_ref, |ty| Ok::<_, !>(ty)).into_ok()
1457    }
1458
1459    /// Returns `true` if the global caches can be used.
1460    fn can_use_global_caches(
1461        &self,
1462        param_env: ty::ParamEnv<'tcx>,
1463        pred: ty::PolyTraitClause<'tcx>,
1464    ) -> bool {
1465        // If there are any inference variables in the `ParamEnv`, then we
1466        // always use a cache local to this particular scope. Otherwise, we
1467        // switch to a global cache.
1468        if param_env.has_infer() || pred.has_infer() {
1469            return false;
1470        }
1471
1472        match self.typing_mode() {
1473            // Avoid using the global cache during coherence and just rely
1474            // on the local cache. It is really just a simplification to
1475            // avoid us having to fear that coherence results "pollute"
1476            // the master cache. Since coherence executes pretty quickly,
1477            // it's not worth going to more trouble to increase the
1478            // hit-rate, I don't think.
1479            TypingMode::Coherence => false,
1480            // Avoid using the global cache when we're defining opaque types
1481            // as their hidden type may impact the result of candidate selection.
1482            //
1483            // HACK: This is still theoretically unsound. Goals can indirectly rely
1484            // on opaques in the defining scope, and it's easier to do so with TAIT.
1485            // However, if we disqualify *all* goals from being cached, perf suffers.
1486            // This is likely fixed by better caching in general in the new solver.
1487            // See: <https://github.com/rust-lang/rust/issues/132064>.
1488            TypingMode::Typeck { defining_opaque_types_and_generators: defining_opaque_types }
1489            | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types } => {
1490                defining_opaque_types.is_empty()
1491                    || (!pred.has_opaque_types() && !pred.has_coroutines())
1492            }
1493            // Impls that are not fully generic are completely ignored as "nonexistent"
1494            // in this mode, so the results wildly differ from normal trait solving.
1495            TypingMode::Reflection => false,
1496            // The hidden types of `defined_opaque_types` is not local to the current
1497            // inference context, so we can freely move this to the global cache.
1498            TypingMode::PostBorrowck { .. } => true,
1499            // The global cache is only used if there are no opaque types in
1500            // the defining scope or we're outside of analysis.
1501            //
1502            // FIXME(#132279): This is still incorrect as we treat opaque types
1503            // and default associated items differently between these two modes.
1504            TypingMode::PostAnalysis | TypingMode::Codegen => true,
1505        }
1506    }
1507
1508    fn check_candidate_cache(
1509        &mut self,
1510        param_env: ty::ParamEnv<'tcx>,
1511        cache_fresh_trait_pred: ty::PolyTraitClause<'tcx>,
1512    ) -> Option<SelectionResult<'tcx, SelectionCandidate<'tcx>>> {
1513        let infcx = self.infcx;
1514        let tcx = infcx.tcx;
1515        let pred = cache_fresh_trait_pred.skip_binder();
1516
1517        if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
1518            if let Some(res) =
1519                tcx.caches.selection_cache.get(&(infcx.typing_env(param_env), pred), tcx)
1520            {
1521                return Some(res);
1522            } else if truecfg!(debug_assertions) {
1523                match infcx.selection_cache.get(&(param_env, pred), tcx) {
1524                    None | Some(Err(SelectionError::Overflow(OverflowError::Canonical))) => {}
1525                    res => ::rustc_middle::util::bug::bug_fmt(format_args!("unexpected local cache result: {0:?}",
        res))bug!("unexpected local cache result: {res:?}"),
1526                }
1527            }
1528        }
1529
1530        // Subtle: we need to check the local cache even if we're able to use the
1531        // global cache as we don't cache overflow in the global cache but need to
1532        // cache it as otherwise rustdoc hangs when compiling diesel.
1533        infcx.selection_cache.get(&(param_env, pred), tcx)
1534    }
1535
1536    /// Determines whether can we safely cache the result
1537    /// of selecting an obligation. This is almost always `true`,
1538    /// except when dealing with certain `ParamCandidate`s.
1539    ///
1540    /// Ordinarily, a `ParamCandidate` will contain no inference variables,
1541    /// since it was usually produced directly from a `DefId`. However,
1542    /// certain cases (currently only librustdoc's blanket impl finder),
1543    /// a `ParamEnv` may be explicitly constructed with inference types.
1544    /// When this is the case, we do *not* want to cache the resulting selection
1545    /// candidate. This is due to the fact that it might not always be possible
1546    /// to equate the obligation's trait ref and the candidate's trait ref,
1547    /// if more constraints end up getting added to an inference variable.
1548    ///
1549    /// Because of this, we always want to re-run the full selection
1550    /// process for our obligation the next time we see it, since
1551    /// we might end up picking a different `SelectionCandidate` (or none at all).
1552    fn can_cache_candidate(
1553        &self,
1554        result: &SelectionResult<'tcx, SelectionCandidate<'tcx>>,
1555    ) -> bool {
1556        match result {
1557            Ok(Some(SelectionCandidate::ParamCandidate(trait_ref))) => !trait_ref.has_infer(),
1558            _ => true,
1559        }
1560    }
1561
1562    {}
#[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("insert_candidate_cache",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1562u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("candidate")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("candidate");
                                                        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(&candidate)
                                                            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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let infcx = self.infcx;
            let tcx = infcx.tcx;
            let pred = cache_fresh_trait_pred.skip_binder();
            if !self.can_cache_candidate(&candidate) {
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1575",
                                        "rustc_trait_selection::traits::select",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                        ::tracing_core::__macro_support::Option::Some(1575u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                        ::tracing_core::field::FieldSet::new(&["message",
                                                        {
                                                            const NAME:
                                                                ::tracing::__macro_support::FieldName<{
                                                                    ::tracing::__macro_support::FieldName::len("pred")
                                                                }> =
                                                                ::tracing::__macro_support::FieldName::new("pred");
                                                            NAME.as_str()
                                                        },
                                                        {
                                                            const NAME:
                                                                ::tracing::__macro_support::FieldName<{
                                                                    ::tracing::__macro_support::FieldName::len("candidate")
                                                                }> =
                                                                ::tracing::__macro_support::FieldName::new("candidate");
                                                            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!("insert_candidate_cache - candidate is not cacheable")
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&pred)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
                                                            as &dyn ::tracing::field::Value))])
                            });
                    } else { ; }
                };
                return;
            }
            if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
                if let Err(SelectionError::Overflow(OverflowError::Canonical))
                        = candidate
                    {} else {
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1583",
                                            "rustc_trait_selection::traits::select",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                            ::tracing_core::__macro_support::Option::Some(1583u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                            ::tracing_core::field::FieldSet::new(&["message",
                                                            {
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("pred")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("pred");
                                                                NAME.as_str()
                                                            },
                                                            {
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("candidate")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("candidate");
                                                                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!("insert_candidate_cache global")
                                                                as &dyn ::tracing::field::Value)),
                                                    (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&pred)
                                                                as &dyn ::tracing::field::Value)),
                                                    (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
                                                                as &dyn ::tracing::field::Value))])
                                });
                        } else { ; }
                    };
                    if true {
                        if !!candidate.has_infer() {
                            ::core::panicking::panic("assertion failed: !candidate.has_infer()")
                        };
                    };
                    tcx.caches.selection_cache.insert((infcx.typing_env(param_env),
                            pred), dep_node, candidate);
                    return;
                }
            }
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1596",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1596u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                    ::tracing_core::field::FieldSet::new(&["message",
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("pred")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("pred");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("candidate")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("candidate");
                                                        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!("insert_candidate_cache local")
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&pred)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            self.infcx.selection_cache.insert((param_env, pred), dep_node,
                candidate);
        }
    }
}#[instrument(skip(self, param_env, cache_fresh_trait_pred, dep_node), level = "debug")]
1563    fn insert_candidate_cache(
1564        &mut self,
1565        param_env: ty::ParamEnv<'tcx>,
1566        cache_fresh_trait_pred: ty::PolyTraitClause<'tcx>,
1567        dep_node: DepNodeIndex,
1568        candidate: SelectionResult<'tcx, SelectionCandidate<'tcx>>,
1569    ) {
1570        let infcx = self.infcx;
1571        let tcx = infcx.tcx;
1572        let pred = cache_fresh_trait_pred.skip_binder();
1573
1574        if !self.can_cache_candidate(&candidate) {
1575            debug!(?pred, ?candidate, "insert_candidate_cache - candidate is not cacheable");
1576            return;
1577        }
1578
1579        if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
1580            if let Err(SelectionError::Overflow(OverflowError::Canonical)) = candidate {
1581                // Don't cache overflow globally; we only produce this in certain modes.
1582            } else {
1583                debug!(?pred, ?candidate, "insert_candidate_cache global");
1584                debug_assert!(!candidate.has_infer());
1585
1586                // This may overwrite the cache with the same value.
1587                tcx.caches.selection_cache.insert(
1588                    (infcx.typing_env(param_env), pred),
1589                    dep_node,
1590                    candidate,
1591                );
1592                return;
1593            }
1594        }
1595
1596        debug!(?pred, ?candidate, "insert_candidate_cache local");
1597        self.infcx.selection_cache.insert((param_env, pred), dep_node, candidate);
1598    }
1599
1600    /// Looks at the item bounds of the projection or opaque type.
1601    /// If this is a nested rigid projection, such as
1602    /// `<<T as Tr1>::Assoc as Tr2>::Assoc`, consider the item bounds
1603    /// on both `Tr1::Assoc` and `Tr2::Assoc`, since we may encounter
1604    /// relative bounds on both via the `associated_type_bounds` feature.
1605    pub(super) fn for_each_item_bound<T>(
1606        &mut self,
1607        mut self_ty: Ty<'tcx>,
1608        mut for_each: impl FnMut(
1609            &mut Self,
1610            ty::Clause<'tcx>,
1611            usize,
1612            AliasBoundKind,
1613        ) -> ControlFlow<T, ()>,
1614        on_ambiguity: impl FnOnce(),
1615    ) -> ControlFlow<T, ()> {
1616        let mut idx = 0;
1617        let mut alias_bound_kind = AliasBoundKind::SelfBounds;
1618
1619        loop {
1620            let (alias_ty, def_id) = match *self_ty.kind() {
1621                ty::Alias(
1622                    _,
1623                    alias_ty @ ty::AliasTy {
1624                        kind: ty::Projection { def_id } | ty::Opaque { def_id },
1625                        ..
1626                    },
1627                ) => (alias_ty, def_id),
1628                ty::Infer(ty::TyVar(_)) => {
1629                    on_ambiguity();
1630                    return ControlFlow::Continue(());
1631                }
1632                _ => return ControlFlow::Continue(()),
1633            };
1634
1635            // HACK: On subsequent recursions, we only care about bounds that don't
1636            // share the same type as `self_ty`. This is because for truly rigid
1637            // projections, we will never be able to equate, e.g. `<T as Tr>::A`
1638            // with `<<T as Tr>::A as Tr>::A`.
1639            let relevant_bounds = if alias_bound_kind == AliasBoundKind::NonSelfBounds {
1640                self.tcx().item_non_self_bounds(def_id)
1641            } else {
1642                self.tcx().item_self_bounds(def_id)
1643            };
1644
1645            for bound in relevant_bounds.instantiate(self.tcx(), alias_ty.args).skip_norm_wip() {
1646                for_each(self, bound, idx, alias_bound_kind)?;
1647                idx += 1;
1648            }
1649
1650            if #[allow(non_exhaustive_omitted_patterns)] match alias_ty.kind {
    ty::Projection { .. } => true,
    _ => false,
}matches!(alias_ty.kind, ty::Projection { .. }) {
1651                self_ty = alias_ty.self_ty();
1652            } else {
1653                return ControlFlow::Continue(());
1654            }
1655
1656            alias_bound_kind = AliasBoundKind::NonSelfBounds;
1657        }
1658    }
1659
1660    /// Equates the trait in `obligation` with trait bound. If the two traits
1661    /// can be equated and the normalized trait bound doesn't contain inference
1662    /// variables or placeholders, the normalized bound is returned.
1663    fn match_normalize_trait_ref(
1664        &mut self,
1665        obligation: &PolyTraitObligation<'tcx>,
1666        placeholder_trait_ref: ty::TraitRef<'tcx>,
1667        trait_bound: ty::PolyTraitRef<'tcx>,
1668    ) -> Result<Option<ty::TraitRef<'tcx>>, ()> {
1669        if true {
    if !!placeholder_trait_ref.has_escaping_bound_vars() {
        ::core::panicking::panic("assertion failed: !placeholder_trait_ref.has_escaping_bound_vars()")
    };
};debug_assert!(!placeholder_trait_ref.has_escaping_bound_vars());
1670        if placeholder_trait_ref.def_id != trait_bound.def_id() {
1671            // Avoid unnecessary normalization
1672            return Err(());
1673        }
1674
1675        let drcx = DeepRejectCtxt::relate_rigid_rigid(self.infcx.tcx);
1676        let obligation_args = obligation.predicate.skip_binder().trait_ref.args;
1677        if !drcx.args_may_unify(obligation_args, trait_bound.skip_binder().args) {
1678            return Err(());
1679        }
1680
1681        let trait_bound = self.infcx.instantiate_binder_with_fresh_vars(
1682            obligation.cause.span,
1683            HigherRankedType,
1684            trait_bound,
1685        );
1686        let Normalized { value: trait_bound, obligations: _ } = normalize_with_depth(
1687            self,
1688            obligation.param_env,
1689            obligation.cause.clone(),
1690            obligation.recursion_depth + 1,
1691            ty::Unnormalized::new_wip(trait_bound),
1692        );
1693        self.infcx
1694            .at(&obligation.cause, obligation.param_env)
1695            .eq(DefineOpaqueTypes::No, placeholder_trait_ref, trait_bound)
1696            .map(|InferOk { obligations: _, value: () }| {
1697                // This method is called within a probe, so we can't have
1698                // inference variables and placeholders escape.
1699                if !trait_bound.has_infer() && !trait_bound.has_placeholders() {
1700                    Some(trait_bound)
1701                } else {
1702                    None
1703                }
1704            })
1705            .map_err(|_| ())
1706    }
1707
1708    fn where_clause_may_apply<'o>(
1709        &mut self,
1710        stack: &TraitObligationStack<'o, 'tcx>,
1711        where_clause_trait_ref: ty::PolyTraitRef<'tcx>,
1712    ) -> Result<EvaluationResult, OverflowError> {
1713        self.evaluation_probe(|this| {
1714            match this.match_where_clause_trait_ref(stack.obligation, where_clause_trait_ref) {
1715                Ok(obligations) => this.evaluate_predicates_recursively(stack.list(), obligations),
1716                Err(()) => Ok(EvaluatedToErr),
1717            }
1718        })
1719    }
1720
1721    /// Return `Yes` if the obligation's predicate type applies to the env_predicate, and
1722    /// `No` if it does not. Return `Ambiguous` in the case that the projection type is a GAT,
1723    /// and applying this env_predicate constrains any of the obligation's GAT parameters.
1724    ///
1725    /// This behavior is a somewhat of a hack to prevent over-constraining inference variables
1726    /// in cases like #91762.
1727    pub(super) fn match_projection_projections(
1728        &mut self,
1729        obligation: &ProjectionTermObligation<'tcx>,
1730        env_predicate: PolyProjectionClause<'tcx>,
1731        potentially_unnormalized_candidates: bool,
1732    ) -> ProjectionMatchesProjection {
1733        let def_id = obligation.predicate.expect_projection_def_id();
1734        if true {
    {
        match (&def_id, &env_predicate.item_def_id()) {
            (left_val, right_val) => {
                if !(*left_val == *right_val) {
                    let kind = ::core::panicking::AssertKind::Eq;
                    ::core::panicking::assert_failed(kind, &*left_val,
                        &*right_val, ::core::option::Option::None);
                }
            }
        }
    };
};debug_assert_eq!(def_id, env_predicate.item_def_id());
1735
1736        let mut nested_obligations = PredicateObligations::new();
1737        let infer_predicate = self.infcx.instantiate_binder_with_fresh_vars(
1738            obligation.cause.span,
1739            BoundRegionConversionTime::HigherRankedType,
1740            env_predicate,
1741        );
1742        let mut infer_projection = infer_predicate.projection_term;
1743        if potentially_unnormalized_candidates {
1744            infer_projection = normalize_with_depth_to(
1745                self,
1746                obligation.param_env,
1747                obligation.cause.clone(),
1748                obligation.recursion_depth + 1,
1749                ty::Unnormalized::new_wip(infer_projection),
1750                &mut nested_obligations,
1751            )
1752        }
1753
1754        let is_match = self
1755            .infcx
1756            .at(&obligation.cause, obligation.param_env)
1757            .eq(DefineOpaqueTypes::No, obligation.predicate, infer_projection)
1758            .is_ok_and(|InferOk { obligations, value: () }| {
1759                self.evaluate_predicates_recursively(
1760                    TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
1761                    nested_obligations.into_iter().chain(obligations),
1762                )
1763                .is_ok_and(|res| res.may_apply())
1764            });
1765
1766        if is_match {
1767            let generics = self.tcx().generics_of(def_id);
1768            // FIXME(generic_associated_types): Addresses aggressive inference in #92917.
1769            // If this type is a GAT, and of the GAT args resolve to something new,
1770            // that means that we must have newly inferred something about the GAT.
1771            // We should give up in that case.
1772            //
1773            // This only detects one layer of inference, which is probably not what we actually
1774            // want, but fixing it causes some ambiguity:
1775            // <https://github.com/rust-lang/rust/issues/125196>.
1776            if !generics.is_own_empty()
1777                && obligation.predicate.args[generics.parent_count..].iter().any(|&p| {
1778                    p.has_non_region_infer()
1779                        && match p.kind() {
1780                            ty::GenericArgKind::Const(ct) => {
1781                                self.infcx.shallow_resolve_const(ct) != ct
1782                            }
1783                            ty::GenericArgKind::Type(ty) => self.infcx.shallow_resolve(ty) != ty,
1784                            ty::GenericArgKind::Lifetime(_) => false,
1785                        }
1786                })
1787            {
1788                ProjectionMatchesProjection::Ambiguous
1789            } else {
1790                ProjectionMatchesProjection::Yes
1791            }
1792        } else {
1793            ProjectionMatchesProjection::No
1794        }
1795    }
1796}
1797
1798/// ## Winnowing
1799///
1800/// Winnowing is the process of attempting to resolve ambiguity by
1801/// probing further. During the winnowing process, we unify all
1802/// type variables and then we also attempt to evaluate recursive
1803/// bounds to see if they are satisfied.
1804impl<'tcx> SelectionContext<'_, 'tcx> {
1805    /// If there are multiple ways to prove a trait goal, we make some
1806    /// *fairly arbitrary* choices about which candidate is actually used.
1807    ///
1808    /// For more details, look at the implementation of this method :)
1809    {}
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("winnow_candidates",
                                "rustc_trait_selection::traits::select",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1809u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("has_non_region_infer")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("has_non_region_infer");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("candidate_preference_mode")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("candidate_preference_mode");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("candidates")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("candidates");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::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(&has_non_region_infer
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate_preference_mode)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidates)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                Option<SelectionCandidate<'tcx>> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if candidates.len() == 1 {
                            return Some(candidates.pop().unwrap().candidate);
                        }
                        let mut sized_candidates =
                            candidates.iter().filter(|c|
                                    #[allow(non_exhaustive_omitted_patterns)] match c.candidate
                                        {
                                        SizedCandidate => true,
                                        _ => false,
                                    });
                        if let Some(sized_candidate) = sized_candidates.next() {
                            if true {
                                {
                                    match (&sized_candidates.next(), &None) {
                                        (left_val, right_val) => {
                                            if !(*left_val == *right_val) {
                                                let kind = ::core::panicking::AssertKind::Eq;
                                                ::core::panicking::assert_failed(kind, &*left_val,
                                                    &*right_val, ::core::option::Option::None);
                                            }
                                        }
                                    }
                                };
                            };
                            if sized_candidate.evaluation.must_apply_modulo_regions() {
                                return Some(sized_candidate.candidate.clone());
                            } else { return None; }
                        }
                        'search_victim: loop {
                            for (i, this) in candidates.iter().enumerate() {
                                let ParamCandidate(this) = this.candidate else { continue };
                                for (j, other) in candidates.iter().enumerate() {
                                    if i == j { continue; }
                                    let ParamCandidate(other) =
                                        other.candidate else { continue };
                                    if this == other {
                                        candidates.remove(j);
                                        continue 'search_victim;
                                    }
                                    if this.skip_binder().trait_ref ==
                                                    other.skip_binder().trait_ref &&
                                                this.skip_binder().polarity == other.skip_binder().polarity
                                            && !this.skip_binder().trait_ref.has_escaping_bound_vars() {
                                        candidates.remove(j);
                                        continue 'search_victim;
                                    }
                                }
                            }
                            break;
                        }
                        let mut alias_bounds =
                            candidates.iter().filter_map(|c|
                                    {
                                        if let ProjectionCandidate { idx, kind } = c.candidate {
                                            Some((idx, kind))
                                        } else { None }
                                    });
                        if #[allow(non_exhaustive_omitted_patterns)] match candidate_preference_mode
                                {
                                CandidatePreferenceMode::Marker => true,
                                _ => false,
                            } {
                            match alias_bounds.clone().filter_map(|(idx, kind)|
                                            (kind ==
                                                        AliasBoundKind::SelfBounds).then_some(idx)).try_reduce(|c1,
                                        c2|
                                        if has_non_region_infer { None } else { Some(c1.min(c2)) })
                                {
                                Some(Some(idx)) => {
                                    return Some(ProjectionCandidate {
                                                idx,
                                                kind: AliasBoundKind::SelfBounds,
                                            });
                                }
                                Some(None) => {}
                                None => return None,
                            }
                        }
                        let is_global =
                            |c: ty::PolyTraitClause<'tcx>|
                                c.is_global() && !c.has_bound_vars();
                        let param_candidates =
                            candidates.iter().filter_map(|c|
                                    if let ParamCandidate(p) = c.candidate {
                                        Some(p)
                                    } else { None });
                        let mut has_global_bounds = false;
                        let mut param_candidate = None;
                        for c in param_candidates {
                            if is_global(c) {
                                has_global_bounds = true;
                            } else if param_candidate.replace(c).is_some() {
                                return None;
                            }
                        }
                        if let Some(predicate) = param_candidate {
                            if has_global_bounds {
                                return None;
                            } else { return Some(ParamCandidate(predicate)); }
                        }
                        match alias_bounds.try_reduce(|(c1, k1), (c2, k2)|
                                    {
                                        if has_non_region_infer {
                                            None
                                        } else if c1 < c2 { Some((c1, k1)) } else { Some((c2, k2)) }
                                    }) {
                            Some(Some((idx, kind))) =>
                                return Some(ProjectionCandidate { idx, kind }),
                            Some(None) => {}
                            None => return None,
                        }
                        let object_bound =
                            candidates.iter().filter_map(|c|
                                        if let ObjectCandidate(i) = c.candidate {
                                            Some(i)
                                        } else {
                                            None
                                        }).try_reduce(|c1, c2|
                                    if has_non_region_infer { None } else { Some(c1.min(c2)) });
                        match object_bound {
                            Some(Some(index)) => {
                                return if has_non_region_infer &&
                                            candidates.iter().any(|c|
                                                    #[allow(non_exhaustive_omitted_patterns)] match c.candidate
                                                        {
                                                        ImplCandidate(_) => true,
                                                        _ => false,
                                                    }) {
                                        None
                                    } else { Some(ObjectCandidate(index)) };
                            }
                            Some(None) => {}
                            None => return None,
                        }
                        let upcast_bound =
                            candidates.iter().filter_map(|c|
                                        {
                                            if let TraitUpcastingUnsizeCandidate(i) = c.candidate {
                                                Some(i)
                                            } else { None }
                                        }).try_reduce(|c1, c2|
                                    if has_non_region_infer { None } else { Some(c1.min(c2)) });
                        match upcast_bound {
                            Some(Some(index)) =>
                                return Some(TraitUpcastingUnsizeCandidate(index)),
                            Some(None) => {}
                            None => return None,
                        }
                        let impls =
                            candidates.iter().filter_map(|c|
                                    {
                                        if let ImplCandidate(def_id) = c.candidate {
                                            Some((def_id, c.evaluation))
                                        } else { None }
                                    });
                        let mut impl_candidate = None;
                        for c in impls {
                            if let Some(prev) = impl_candidate.replace(c) {
                                if self.prefer_lhs_over_victim(has_non_region_infer, c,
                                        prev.0)
                                    {} else if self.prefer_lhs_over_victim(has_non_region_infer,
                                        prev, c.0) {
                                    impl_candidate = Some(prev);
                                } else { return None; }
                            }
                        }
                        if let Some((def_id, _evaluation)) = impl_candidate {
                            if candidates.iter().all(|c|
                                        match c.candidate {
                                            SizedCandidate | BuiltinCandidate | TransmutabilityCandidate
                                                | AutoImplCandidate | ClosureCandidate { .. } |
                                                AsyncClosureCandidate | AsyncFnKindHelperCandidate |
                                                CoroutineCandidate | FutureCandidate | IteratorCandidate |
                                                AsyncIteratorCandidate | FnPointerCandidate |
                                                TraitAliasCandidate | TraitUpcastingUnsizeCandidate(_) |
                                                BuiltinObjectCandidate | BuiltinUnsizeCandidate |
                                                TryAsDynCandidate | BikeshedGuaranteedNoDropCandidate =>
                                                false,
                                            ParamCandidate(_) | ImplCandidate(_) => true,
                                            ProjectionCandidate { .. } | ObjectCandidate(_) =>
                                                ::core::panicking::panic("internal error: entered unreachable code"),
                                        }) {
                                return Some(ImplCandidate(def_id));
                            } else { return None; }
                        }
                        if candidates.len() == 1 {
                            Some(candidates.pop().unwrap().candidate)
                        } else {
                            let mut not_a_global_where_bound =
                                candidates.into_iter().filter(|c|
                                        !#[allow(non_exhaustive_omitted_patterns)] match c.candidate
                                                {
                                                ParamCandidate(p) if is_global(p) => true,
                                                _ => false,
                                            });
                            not_a_global_where_bound.next().map(|c|
                                        c.candidate).filter(|_|
                                    not_a_global_where_bound.next().is_none())
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1809",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1809u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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)]
1810    fn winnow_candidates(
1811        &mut self,
1812        has_non_region_infer: bool,
1813        candidate_preference_mode: CandidatePreferenceMode,
1814        mut candidates: Vec<EvaluatedCandidate<'tcx>>,
1815    ) -> Option<SelectionCandidate<'tcx>> {
1816        if candidates.len() == 1 {
1817            return Some(candidates.pop().unwrap().candidate);
1818        }
1819
1820        // We prefer `Sized` candidates over everything.
1821        let mut sized_candidates =
1822            candidates.iter().filter(|c| matches!(c.candidate, SizedCandidate));
1823        if let Some(sized_candidate) = sized_candidates.next() {
1824            // There should only ever be a single sized candidate
1825            // as they would otherwise overlap.
1826            debug_assert_eq!(sized_candidates.next(), None);
1827            // Only prefer the built-in `Sized` candidate if its nested goals are certain.
1828            // Otherwise, we may encounter failure later on if inference causes this candidate
1829            // to not hold, but a where clause would've applied instead.
1830            if sized_candidate.evaluation.must_apply_modulo_regions() {
1831                return Some(sized_candidate.candidate.clone());
1832            } else {
1833                return None;
1834            }
1835        }
1836
1837        // Before we consider where-bounds, we have to deduplicate them here and also
1838        // drop where-bounds in case the same where-bound exists without bound vars.
1839        // This is necessary as elaborating super-trait bounds may result in duplicates.
1840        'search_victim: loop {
1841            for (i, this) in candidates.iter().enumerate() {
1842                let ParamCandidate(this) = this.candidate else { continue };
1843                for (j, other) in candidates.iter().enumerate() {
1844                    if i == j {
1845                        continue;
1846                    }
1847
1848                    let ParamCandidate(other) = other.candidate else { continue };
1849                    if this == other {
1850                        candidates.remove(j);
1851                        continue 'search_victim;
1852                    }
1853
1854                    if this.skip_binder().trait_ref == other.skip_binder().trait_ref
1855                        && this.skip_binder().polarity == other.skip_binder().polarity
1856                        && !this.skip_binder().trait_ref.has_escaping_bound_vars()
1857                    {
1858                        candidates.remove(j);
1859                        continue 'search_victim;
1860                    }
1861                }
1862            }
1863
1864            break;
1865        }
1866
1867        let mut alias_bounds = candidates.iter().filter_map(|c| {
1868            if let ProjectionCandidate { idx, kind } = c.candidate {
1869                Some((idx, kind))
1870            } else {
1871                None
1872            }
1873        });
1874        // Extract non-nested alias bound candidates, will be preferred over where bounds if
1875        // we're proving an auto-trait, sizedness trait or default trait.
1876        if matches!(candidate_preference_mode, CandidatePreferenceMode::Marker) {
1877            match alias_bounds
1878                .clone()
1879                .filter_map(|(idx, kind)| (kind == AliasBoundKind::SelfBounds).then_some(idx))
1880                .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) })
1881            {
1882                Some(Some(idx)) => {
1883                    return Some(ProjectionCandidate { idx, kind: AliasBoundKind::SelfBounds });
1884                }
1885                Some(None) => {}
1886                None => return None,
1887            }
1888        }
1889
1890        // The next highest priority is for non-global where-bounds. However, while we don't
1891        // prefer global where-clauses here, we do bail with ambiguity when encountering both
1892        // a global and a non-global where-clause.
1893        //
1894        // Our handling of where-bounds is generally fairly messy but necessary for backwards
1895        // compatibility, see #50825 for why we need to handle global where-bounds like this.
1896        let is_global = |c: ty::PolyTraitClause<'tcx>| c.is_global() && !c.has_bound_vars();
1897        let param_candidates = candidates
1898            .iter()
1899            .filter_map(|c| if let ParamCandidate(p) = c.candidate { Some(p) } else { None });
1900        let mut has_global_bounds = false;
1901        let mut param_candidate = None;
1902        for c in param_candidates {
1903            if is_global(c) {
1904                has_global_bounds = true;
1905            } else if param_candidate.replace(c).is_some() {
1906                // Ambiguity, two potentially different where-clauses
1907                return None;
1908            }
1909        }
1910        if let Some(predicate) = param_candidate {
1911            // Ambiguity, a global and a non-global where-bound.
1912            if has_global_bounds {
1913                return None;
1914            } else {
1915                return Some(ParamCandidate(predicate));
1916            }
1917        }
1918
1919        // Prefer alias-bounds over blanket impls for rigid associated types. This is
1920        // fairly arbitrary but once again necessary for backwards compatibility.
1921        // If there are multiple applicable candidates which don't affect type inference,
1922        // choose the one with the lowest index.
1923        match alias_bounds.try_reduce(|(c1, k1), (c2, k2)| {
1924            if has_non_region_infer {
1925                None
1926            } else if c1 < c2 {
1927                Some((c1, k1))
1928            } else {
1929                Some((c2, k2))
1930            }
1931        }) {
1932            Some(Some((idx, kind))) => return Some(ProjectionCandidate { idx, kind }),
1933            Some(None) => {}
1934            None => return None,
1935        }
1936
1937        // Need to prioritize builtin trait object impls as `<dyn Any as Any>::type_id`
1938        // should use the vtable method and not the method provided by the user-defined
1939        // impl `impl<T: ?Sized> Any for T { .. }`. This really shouldn't exist but is
1940        // necessary due to #57893. We again arbitrarily prefer the applicable candidate
1941        // with the lowest index.
1942        //
1943        // We do not want to use these impls to guide inference in case a user-written impl
1944        // may also apply.
1945        let object_bound = candidates
1946            .iter()
1947            .filter_map(|c| if let ObjectCandidate(i) = c.candidate { Some(i) } else { None })
1948            .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) });
1949        match object_bound {
1950            Some(Some(index)) => {
1951                return if has_non_region_infer
1952                    && candidates.iter().any(|c| matches!(c.candidate, ImplCandidate(_)))
1953                {
1954                    None
1955                } else {
1956                    Some(ObjectCandidate(index))
1957                };
1958            }
1959            Some(None) => {}
1960            None => return None,
1961        }
1962        // Same for upcasting.
1963        let upcast_bound = candidates
1964            .iter()
1965            .filter_map(|c| {
1966                if let TraitUpcastingUnsizeCandidate(i) = c.candidate { Some(i) } else { None }
1967            })
1968            .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) });
1969        match upcast_bound {
1970            Some(Some(index)) => return Some(TraitUpcastingUnsizeCandidate(index)),
1971            Some(None) => {}
1972            None => return None,
1973        }
1974
1975        // Finally, handle overlapping user-written impls.
1976        let impls = candidates.iter().filter_map(|c| {
1977            if let ImplCandidate(def_id) = c.candidate {
1978                Some((def_id, c.evaluation))
1979            } else {
1980                None
1981            }
1982        });
1983        let mut impl_candidate = None;
1984        for c in impls {
1985            if let Some(prev) = impl_candidate.replace(c) {
1986                if self.prefer_lhs_over_victim(has_non_region_infer, c, prev.0) {
1987                    // Ok, prefer `c` over the previous entry
1988                } else if self.prefer_lhs_over_victim(has_non_region_infer, prev, c.0) {
1989                    // Ok, keep `prev` instead of the new entry
1990                    impl_candidate = Some(prev);
1991                } else {
1992                    // Ambiguity, two potentially different where-clauses
1993                    return None;
1994                }
1995            }
1996        }
1997        if let Some((def_id, _evaluation)) = impl_candidate {
1998            // Don't use impl candidates which overlap with other candidates.
1999            // This should pretty much only ever happen with malformed impls.
2000            if candidates.iter().all(|c| match c.candidate {
2001                SizedCandidate
2002                | BuiltinCandidate
2003                | TransmutabilityCandidate
2004                | AutoImplCandidate
2005                | ClosureCandidate { .. }
2006                | AsyncClosureCandidate
2007                | AsyncFnKindHelperCandidate
2008                | CoroutineCandidate
2009                | FutureCandidate
2010                | IteratorCandidate
2011                | AsyncIteratorCandidate
2012                | FnPointerCandidate
2013                | TraitAliasCandidate
2014                | TraitUpcastingUnsizeCandidate(_)
2015                | BuiltinObjectCandidate
2016                | BuiltinUnsizeCandidate
2017                | TryAsDynCandidate
2018                | BikeshedGuaranteedNoDropCandidate => false,
2019                // Non-global param candidates have already been handled, global
2020                // where-bounds get ignored.
2021                ParamCandidate(_) | ImplCandidate(_) => true,
2022                ProjectionCandidate { .. } | ObjectCandidate(_) => unreachable!(),
2023            }) {
2024                return Some(ImplCandidate(def_id));
2025            } else {
2026                return None;
2027            }
2028        }
2029
2030        if candidates.len() == 1 {
2031            Some(candidates.pop().unwrap().candidate)
2032        } else {
2033            // Also try ignoring all global where-bounds and check whether we end
2034            // with a unique candidate in this case.
2035            let mut not_a_global_where_bound = candidates
2036                .into_iter()
2037                .filter(|c| !matches!(c.candidate, ParamCandidate(p) if is_global(p)));
2038            not_a_global_where_bound
2039                .next()
2040                .map(|c| c.candidate)
2041                .filter(|_| not_a_global_where_bound.next().is_none())
2042        }
2043    }
2044
2045    fn prefer_lhs_over_victim(
2046        &self,
2047        has_non_region_infer: bool,
2048        (lhs, lhs_evaluation): (DefId, EvaluationResult),
2049        victim: DefId,
2050    ) -> bool {
2051        let tcx = self.tcx();
2052        // See if we can toss out `victim` based on specialization.
2053        //
2054        // While this requires us to know *for sure* that the `lhs` impl applies
2055        // we still use modulo regions here. This is fine as specialization currently
2056        // assumes that specializing impls have to be always applicable, meaning that
2057        // the only allowed region constraints may be constraints also present on the default impl.
2058        if lhs_evaluation.must_apply_modulo_regions() {
2059            if tcx.specializes((lhs, victim)) {
2060                return true;
2061            }
2062        }
2063
2064        match tcx.impls_are_allowed_to_overlap(lhs, victim) {
2065            // For candidates which already reference errors it doesn't really
2066            // matter what we do 🤷
2067            Some(ty::ImplOverlapKind::Permitted { marker: false }) => {
2068                lhs_evaluation.must_apply_considering_regions()
2069            }
2070            Some(ty::ImplOverlapKind::Permitted { marker: true }) => {
2071                // Subtle: If the predicate we are evaluating has inference
2072                // variables, do *not* allow discarding candidates due to
2073                // marker trait impls.
2074                //
2075                // Without this restriction, we could end up accidentally
2076                // constraining inference variables based on an arbitrarily
2077                // chosen trait impl.
2078                //
2079                // Imagine we have the following code:
2080                //
2081                // ```rust
2082                // #[marker] trait MyTrait {}
2083                // impl MyTrait for u8 {}
2084                // impl MyTrait for bool {}
2085                // ```
2086                //
2087                // And we are evaluating the predicate `<_#0t as MyTrait>`.
2088                //
2089                // During selection, we will end up with one candidate for each
2090                // impl of `MyTrait`. If we were to discard one impl in favor
2091                // of the other, we would be left with one candidate, causing
2092                // us to "successfully" select the predicate, unifying
2093                // _#0t with (for example) `u8`.
2094                //
2095                // However, we have no reason to believe that this unification
2096                // is correct - we've essentially just picked an arbitrary
2097                // *possibility* for _#0t, and required that this be the *only*
2098                // possibility.
2099                //
2100                // Eventually, we will either:
2101                // 1) Unify all inference variables in the predicate through
2102                // some other means (e.g. type-checking of a function). We will
2103                // then be in a position to drop marker trait candidates
2104                // without constraining inference variables (since there are
2105                // none left to constrain)
2106                // 2) Be left with some unconstrained inference variables. We
2107                // will then correctly report an inference error, since the
2108                // existence of multiple marker trait impls tells us nothing
2109                // about which one should actually apply.
2110                !has_non_region_infer && lhs_evaluation.must_apply_considering_regions()
2111            }
2112            None => false,
2113        }
2114    }
2115}
2116
2117impl<'tcx> SelectionContext<'_, 'tcx> {
2118    fn sizedness_conditions(
2119        &mut self,
2120        self_ty: Ty<'tcx>,
2121        sizedness: SizedTraitKind,
2122    ) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
2123        match self_ty.kind() {
2124            ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2125            | ty::Uint(_)
2126            | ty::Int(_)
2127            | ty::Bool
2128            | ty::Float(_)
2129            | ty::FnDef(..)
2130            | ty::FnPtr(..)
2131            | ty::RawPtr(..)
2132            | ty::Char
2133            | ty::Ref(..)
2134            | ty::Coroutine(..)
2135            | ty::CoroutineWitness(..)
2136            | ty::Array(..)
2137            | ty::Closure(..)
2138            | ty::CoroutineClosure(..)
2139            | ty::Never
2140            | ty::Error(_) => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2141
2142            ty::Str | ty::Slice(_) | ty::Dynamic(..) => match sizedness {
2143                SizedTraitKind::Sized => {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("tried to assemble `Sized` for unsized type")));
}unreachable!("tried to assemble `Sized` for unsized type"),
2144                SizedTraitKind::MetaSized => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2145            },
2146
2147            ty::Foreign(..) => {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("tried to assemble `Sized` for unsized type")));
}unreachable!("tried to assemble `Sized` for unsized type"),
2148
2149            ty::Tuple(tys) => {
2150                ty::Binder::dummy(tys.last().map_or_else(Vec::new, |&last| ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [last]))vec![last]))
2151            }
2152
2153            ty::Pat(ty, _) => ty::Binder::dummy(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [*ty]))vec![*ty]),
2154
2155            ty::Adt(def, args) => {
2156                if let Some(crit) = def.sizedness_constraint(self.tcx(), sizedness) {
2157                    ty::Binder::dummy(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [crit.instantiate(self.tcx(), args).skip_norm_wip()]))vec![crit.instantiate(self.tcx(), args).skip_norm_wip()])
2158                } else {
2159                    ty::Binder::dummy(::alloc::vec::Vec::new()vec![])
2160                }
2161            }
2162
2163            ty::UnsafeBinder(binder_ty) => binder_ty.map_bound(|ty| ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [ty]))vec![ty]),
2164
2165            ty::Alias(..)
2166            | ty::Param(_)
2167            | ty::Placeholder(..)
2168            | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_))
2169            | ty::Bound(..) => {
2170                ::rustc_middle::util::bug::bug_fmt(format_args!("asked to assemble `Sized` of unexpected type: {0:?}",
        self_ty));bug!("asked to assemble `Sized` of unexpected type: {:?}", self_ty);
2171            }
2172        }
2173    }
2174
2175    fn copy_clone_conditions(&mut self, self_ty: Ty<'tcx>) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
2176        match *self_ty.kind() {
2177            ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2178
2179            ty::Uint(_)
2180            | ty::Int(_)
2181            | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2182            | ty::Bool
2183            | ty::Float(_)
2184            | ty::Char
2185            | ty::RawPtr(..)
2186            | ty::Never
2187            | ty::Ref(_, _, hir::Mutability::Not)
2188            | ty::Array(..) => {
2189                {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("tried to assemble `Sized` for type with libcore-provided impl")));
}unreachable!("tried to assemble `Sized` for type with libcore-provided impl")
2190            }
2191
2192            // FIXME(unsafe_binder): Should we conditionally
2193            // (i.e. universally) implement copy/clone?
2194            ty::UnsafeBinder(_) => {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("tried to assemble `Sized` for unsafe binder")));
}unreachable!("tried to assemble `Sized` for unsafe binder"),
2195
2196            ty::Tuple(tys) => {
2197                // (*) binder moved here
2198                ty::Binder::dummy(tys.iter().collect())
2199            }
2200
2201            ty::Pat(ty, _) => {
2202                // (*) binder moved here
2203                ty::Binder::dummy(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [ty]))vec![ty])
2204            }
2205
2206            ty::Coroutine(def_id, args) => match self.tcx().coroutine_movability(def_id) {
2207                hir::Movability::Static => {
2208                    {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("tried to assemble `Clone` for static coroutine")));
}unreachable!("tried to assemble `Clone` for static coroutine")
2209                }
2210                hir::Movability::Movable => {
2211                    if self.tcx().features().coroutine_clone() {
2212                        ty::Binder::dummy(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [args.as_coroutine().tupled_upvars_ty(),
                Ty::new_coroutine_witness_for_coroutine(self.tcx(), def_id,
                    args)]))vec![
2213                            args.as_coroutine().tupled_upvars_ty(),
2214                            Ty::new_coroutine_witness_for_coroutine(self.tcx(), def_id, args),
2215                        ])
2216                    } else {
2217                        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("tried to assemble `Clone` for coroutine without enabled feature")));
}unreachable!(
2218                            "tried to assemble `Clone` for coroutine without enabled feature"
2219                        )
2220                    }
2221                }
2222            },
2223
2224            ty::CoroutineWitness(def_id, args) => self
2225                .infcx
2226                .tcx
2227                .coroutine_hidden_types(def_id)
2228                .instantiate(self.infcx.tcx, args)
2229                .skip_norm_wip()
2230                .map_bound(|witness| witness.types.to_vec()),
2231
2232            ty::Closure(_, args) => ty::Binder::dummy(args.as_closure().upvar_tys().to_vec()),
2233
2234            ty::CoroutineClosure(_, args) => {
2235                ty::Binder::dummy(args.as_coroutine_closure().upvar_tys().to_vec())
2236            }
2237
2238            ty::Foreign(..)
2239            | ty::Str
2240            | ty::Slice(_)
2241            | ty::Dynamic(..)
2242            | ty::Adt(..)
2243            | ty::Alias(..)
2244            | ty::Param(..)
2245            | ty::Placeholder(..)
2246            | ty::Bound(..)
2247            | ty::Ref(_, _, ty::Mutability::Mut)
2248            | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2249                ::rustc_middle::util::bug::bug_fmt(format_args!("asked to assemble builtin bounds of unexpected type: {0:?}",
        self_ty));bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
2250            }
2251        }
2252    }
2253
2254    fn coroutine_is_gen(&mut self, self_ty: Ty<'tcx>) -> bool {
2255        #[allow(non_exhaustive_omitted_patterns)] match *self_ty.kind() {
    ty::Coroutine(did, ..) if self.tcx().coroutine_is_gen(did) => true,
    _ => false,
}matches!(*self_ty.kind(), ty::Coroutine(did, ..)
2256            if self.tcx().coroutine_is_gen(did))
2257    }
2258
2259    /// For default impls, we need to break apart a type into its
2260    /// "constituent types" -- meaning, the types that it contains.
2261    ///
2262    /// Here are some (simple) examples:
2263    ///
2264    /// ```ignore (illustrative)
2265    /// (i32, u32) -> [i32, u32]
2266    /// Foo where struct Foo { x: i32, y: u32 } -> [i32, u32]
2267    /// Bar<i32> where struct Bar<T> { x: T, y: u32 } -> [i32, u32]
2268    /// Zed<i32> where enum Zed { A(T), B(u32) } -> [i32, u32]
2269    /// ```
2270    {}
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("constituent_types_for_auto_trait",
                                "rustc_trait_selection::traits::select",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(2270u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("t")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("t");
                                                    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(&t)
                                                        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<ty::Binder<'tcx, AutoImplConstituents<'tcx>>,
                                SelectionError<'tcx>> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        Ok(match *t.kind() {
                                ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) |
                                    ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) |
                                    ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) | ty::Never |
                                    ty::Char => {
                                    ty::Binder::dummy(AutoImplConstituents {
                                            types: ::alloc::vec::Vec::new(),
                                            assumptions: ::alloc::vec::Vec::new(),
                                        })
                                }
                                ty::Foreign(..) => {
                                    ty::Binder::dummy(AutoImplConstituents {
                                            types: ::alloc::vec::Vec::new(),
                                            assumptions: ::alloc::vec::Vec::new(),
                                        })
                                }
                                ty::UnsafeBinder(ty) => {
                                    ty.map_bound(|ty|
                                            AutoImplConstituents {
                                                types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                        [ty])),
                                                assumptions: ::alloc::vec::Vec::new(),
                                            })
                                }
                                ty::Str =>
                                    ty::Binder::dummy(AutoImplConstituents {
                                            types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                    [Ty::new_slice(self.tcx(), self.tcx().types.u8)])),
                                            assumptions: ::alloc::vec::Vec::new(),
                                        }),
                                ty::Placeholder(..) | ty::Dynamic(..) | ty::Param(..) |
                                    ty::Alias(_, ty::AliasTy {
                                    kind: ty::Projection { .. } | ty::Inherent { .. } |
                                        ty::Free { .. }, .. }) | ty::Bound(..) |
                                    ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_)
                                    | ty::FreshFloatTy(_)) => {
                                    ::rustc_middle::util::bug::bug_fmt(format_args!("asked to assemble constituent types of unexpected type: {0:?}",
                                            t));
                                }
                                ty::RawPtr(element_ty, _) | ty::Ref(_, element_ty, _) => {
                                    ty::Binder::dummy(AutoImplConstituents {
                                            types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                    [element_ty])),
                                            assumptions: ::alloc::vec::Vec::new(),
                                        })
                                }
                                ty::Pat(ty, _) | ty::Array(ty, _) | ty::Slice(ty) => {
                                    ty::Binder::dummy(AutoImplConstituents {
                                            types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                    [ty])),
                                            assumptions: ::alloc::vec::Vec::new(),
                                        })
                                }
                                ty::Tuple(tys) => {
                                    ty::Binder::dummy(AutoImplConstituents {
                                            types: tys.iter().collect(),
                                            assumptions: ::alloc::vec::Vec::new(),
                                        })
                                }
                                ty::Closure(_, args) => {
                                    let ty =
                                        self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
                                    ty::Binder::dummy(AutoImplConstituents {
                                            types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                    [ty])),
                                            assumptions: ::alloc::vec::Vec::new(),
                                        })
                                }
                                ty::CoroutineClosure(_, args) => {
                                    let ty =
                                        self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
                                    ty::Binder::dummy(AutoImplConstituents {
                                            types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                    [ty])),
                                            assumptions: ::alloc::vec::Vec::new(),
                                        })
                                }
                                ty::Coroutine(def_id, args) => {
                                    let ty =
                                        self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
                                    let tcx = self.tcx();
                                    let witness =
                                        Ty::new_coroutine_witness_for_coroutine(tcx, def_id, args);
                                    ty::Binder::dummy(AutoImplConstituents {
                                            types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                    [ty, witness])),
                                            assumptions: ::alloc::vec::Vec::new(),
                                        })
                                }
                                ty::CoroutineWitness(def_id, args) =>
                                    self.infcx.tcx.coroutine_hidden_types(def_id).instantiate(self.infcx.tcx,
                                                args).skip_norm_wip().map_bound(|witness|
                                            AutoImplConstituents {
                                                types: witness.types.to_vec(),
                                                assumptions: witness.assumptions.to_vec(),
                                            }),
                                ty::Adt(def, args) if def.is_phantom_data() => {
                                    ty::Binder::dummy(AutoImplConstituents {
                                            types: args.types().collect(),
                                            assumptions: ::alloc::vec::Vec::new(),
                                        })
                                }
                                ty::Adt(def, args) =>
                                    ty::Binder::dummy(AutoImplConstituents {
                                            types: def.all_fields().map(|f|
                                                        f.ty(self.tcx(), args).skip_norm_wip()).collect(),
                                            assumptions: ::alloc::vec::Vec::new(),
                                        }),
                                ty::Alias(_, ty::AliasTy {
                                    kind: ty::Opaque { def_id }, args, .. }) => {
                                    if self.infcx.can_define_opaque_ty(def_id) {
                                        ::core::panicking::panic("internal error: entered unreachable code")
                                    } else {
                                        let ty = self.tcx().type_of_opaque(def_id);
                                        ty::Binder::dummy(AutoImplConstituents {
                                                types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                                                        [ty.instantiate(self.tcx(), args).skip_norm_wip()])),
                                                assumptions: ::alloc::vec::Vec::new(),
                                            })
                                    }
                                }
                            })
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2270",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2270u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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)]
2271    fn constituent_types_for_auto_trait(
2272        &self,
2273        t: Ty<'tcx>,
2274    ) -> Result<ty::Binder<'tcx, AutoImplConstituents<'tcx>>, SelectionError<'tcx>> {
2275        Ok(match *t.kind() {
2276            ty::Uint(_)
2277            | ty::Int(_)
2278            | ty::Bool
2279            | ty::Float(_)
2280            | ty::FnDef(..)
2281            | ty::FnPtr(..)
2282            | ty::Error(_)
2283            | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2284            | ty::Never
2285            | ty::Char => {
2286                ty::Binder::dummy(AutoImplConstituents { types: vec![], assumptions: vec![] })
2287            }
2288
2289            // This branch is only for `experimental_default_bounds`.
2290            // Other foreign types were rejected earlier in
2291            // `assemble_candidates_from_auto_impls`.
2292            ty::Foreign(..) => {
2293                ty::Binder::dummy(AutoImplConstituents { types: vec![], assumptions: vec![] })
2294            }
2295
2296            ty::UnsafeBinder(ty) => {
2297                ty.map_bound(|ty| AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2298            }
2299
2300            // Treat this like `struct str([u8]);`
2301            ty::Str => ty::Binder::dummy(AutoImplConstituents {
2302                types: vec![Ty::new_slice(self.tcx(), self.tcx().types.u8)],
2303                assumptions: vec![],
2304            }),
2305
2306            ty::Placeholder(..)
2307            | ty::Dynamic(..)
2308            | ty::Param(..)
2309            | ty::Alias(
2310                _,
2311                ty::AliasTy {
2312                    kind: ty::Projection { .. } | ty::Inherent { .. } | ty::Free { .. },
2313                    ..
2314                },
2315            )
2316            | ty::Bound(..)
2317            | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2318                bug!("asked to assemble constituent types of unexpected type: {:?}", t);
2319            }
2320
2321            ty::RawPtr(element_ty, _) | ty::Ref(_, element_ty, _) => {
2322                ty::Binder::dummy(AutoImplConstituents {
2323                    types: vec![element_ty],
2324                    assumptions: vec![],
2325                })
2326            }
2327
2328            ty::Pat(ty, _) | ty::Array(ty, _) | ty::Slice(ty) => {
2329                ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2330            }
2331
2332            ty::Tuple(tys) => {
2333                // (T1, ..., Tn) -- meets any bound that all of T1...Tn meet
2334                ty::Binder::dummy(AutoImplConstituents {
2335                    types: tys.iter().collect(),
2336                    assumptions: vec![],
2337                })
2338            }
2339
2340            ty::Closure(_, args) => {
2341                let ty = self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
2342                ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2343            }
2344
2345            ty::CoroutineClosure(_, args) => {
2346                let ty = self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
2347                ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2348            }
2349
2350            ty::Coroutine(def_id, args) => {
2351                let ty = self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
2352                let tcx = self.tcx();
2353                let witness = Ty::new_coroutine_witness_for_coroutine(tcx, def_id, args);
2354                ty::Binder::dummy(AutoImplConstituents {
2355                    types: vec![ty, witness],
2356                    assumptions: vec![],
2357                })
2358            }
2359
2360            ty::CoroutineWitness(def_id, args) => self
2361                .infcx
2362                .tcx
2363                .coroutine_hidden_types(def_id)
2364                .instantiate(self.infcx.tcx, args)
2365                .skip_norm_wip()
2366                .map_bound(|witness| AutoImplConstituents {
2367                    types: witness.types.to_vec(),
2368                    assumptions: witness.assumptions.to_vec(),
2369                }),
2370
2371            // For `PhantomData<T>`, we pass `T`.
2372            ty::Adt(def, args) if def.is_phantom_data() => {
2373                ty::Binder::dummy(AutoImplConstituents {
2374                    types: args.types().collect(),
2375                    assumptions: vec![],
2376                })
2377            }
2378
2379            ty::Adt(def, args) => ty::Binder::dummy(AutoImplConstituents {
2380                types: def.all_fields().map(|f| f.ty(self.tcx(), args).skip_norm_wip()).collect(),
2381                assumptions: vec![],
2382            }),
2383
2384            ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) => {
2385                if self.infcx.can_define_opaque_ty(def_id) {
2386                    unreachable!()
2387                } else {
2388                    // We can resolve the opaque type to its hidden type,
2389                    // which enforces a DAG between the functions requiring
2390                    // the auto trait bounds in question.
2391                    let ty = self.tcx().type_of_opaque(def_id);
2392                    ty::Binder::dummy(AutoImplConstituents {
2393                        types: vec![ty.instantiate(self.tcx(), args).skip_norm_wip()],
2394                        assumptions: vec![],
2395                    })
2396                }
2397            }
2398        })
2399    }
2400
2401    fn collect_predicates_for_types(
2402        &mut self,
2403        param_env: ty::ParamEnv<'tcx>,
2404        cause: ObligationCause<'tcx>,
2405        recursion_depth: usize,
2406        trait_def_id: DefId,
2407        types: Vec<Ty<'tcx>>,
2408    ) -> PredicateObligations<'tcx> {
2409        // Because the types were potentially derived from
2410        // higher-ranked obligations they may reference late-bound
2411        // regions. For example, `for<'a> Foo<&'a i32> : Copy` would
2412        // yield a type like `for<'a> &'a i32`. In general, we
2413        // maintain the invariant that we never manipulate bound
2414        // regions, so we have to process these bound regions somehow.
2415        //
2416        // The strategy is to:
2417        //
2418        // 1. Instantiate those regions to placeholder regions (e.g.,
2419        //    `for<'a> &'a i32` becomes `&0 i32`.
2420        // 2. Produce something like `&'0 i32 : Copy`
2421        // 3. Re-bind the regions back to `for<'a> &'a i32 : Copy`
2422
2423        types
2424            .into_iter()
2425            .flat_map(|placeholder_ty| {
2426                let Normalized { value: normalized_ty, mut obligations } = normalize_with_depth(
2427                    self,
2428                    param_env,
2429                    cause.clone(),
2430                    recursion_depth,
2431                    Unnormalized::new_wip(placeholder_ty),
2432                );
2433
2434                let tcx = self.tcx();
2435                let trait_ref = if tcx.generics_of(trait_def_id).own_params.len() == 1 {
2436                    ty::TraitRef::new(tcx, trait_def_id, [normalized_ty])
2437                } else {
2438                    // If this is an ill-formed auto/built-in trait, then synthesize
2439                    // new error args for the missing generics.
2440                    let err_args = ty::GenericArgs::extend_with_error(
2441                        tcx,
2442                        trait_def_id,
2443                        &[normalized_ty.into()],
2444                    );
2445                    ty::TraitRef::new_from_args(tcx, trait_def_id, err_args)
2446                };
2447
2448                let obligation = Obligation::new(self.tcx(), cause.clone(), param_env, trait_ref);
2449                obligations.push(obligation);
2450                obligations
2451            })
2452            .collect()
2453    }
2454
2455    ///////////////////////////////////////////////////////////////////////////
2456    // Matching
2457    //
2458    // Matching is a common path used for both evaluation and
2459    // confirmation. It basically unifies types that appear in impls
2460    // and traits. This does affect the surrounding environment;
2461    // therefore, when used during evaluation, match routines must be
2462    // run inside of a `probe()` so that their side-effects are
2463    // contained.
2464
2465    fn rematch_impl(
2466        &mut self,
2467        impl_def_id: DefId,
2468        obligation: &PolyTraitObligation<'tcx>,
2469    ) -> Normalized<'tcx, GenericArgsRef<'tcx>> {
2470        let impl_trait_header = self.tcx().impl_trait_header(impl_def_id);
2471        match self.match_impl(impl_def_id, impl_trait_header, obligation) {
2472            Ok(args) => args,
2473            Err(()) => {
2474                let predicate = self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
2475                ::rustc_middle::util::bug::bug_fmt(format_args!("impl {0:?} was matchable against {1:?} but now is not",
        impl_def_id, predicate))bug!("impl {impl_def_id:?} was matchable against {predicate:?} but now is not")
2476            }
2477        }
2478    }
2479
2480    {}
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("match_impl",
                                "rustc_trait_selection::traits::select",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(2480u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("impl_def_id")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("impl_def_id");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("impl_trait_header")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("impl_trait_header");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("obligation")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("obligation");
                                                    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(&impl_def_id)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_trait_header)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                        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<Normalized<'tcx, GenericArgsRef<'tcx>>, ()> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let placeholder_obligation =
                            self.infcx.enter_forall_and_leak_universe(obligation.predicate);
                        let placeholder_obligation_trait_ref =
                            placeholder_obligation.trait_ref;
                        let impl_args =
                            self.infcx.fresh_args_for_item(obligation.cause.span,
                                impl_def_id);
                        let trait_ref =
                            impl_trait_header.trait_ref.instantiate(self.tcx(),
                                impl_args);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2494",
                                                "rustc_trait_selection::traits::select",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(2494u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("impl_trait_header")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("impl_trait_header");
                                                                    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(&impl_trait_header)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let mut nested_obligations = PredicateObligations::new();
                        let impl_trait_ref =
                            normalize_with_depth_to(self, obligation.param_env,
                                obligation.cause.clone(), obligation.recursion_depth + 1,
                                trait_ref, &mut nested_obligations);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2506",
                                                "rustc_trait_selection::traits::select",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(2506u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("impl_trait_ref")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("impl_trait_ref");
                                                                    NAME.as_str()
                                                                },
                                                                {
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("placeholder_obligation_trait_ref")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("placeholder_obligation_trait_ref");
                                                                    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(&impl_trait_ref)
                                                                    as &dyn ::tracing::field::Value)),
                                                        (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&placeholder_obligation_trait_ref)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let cause =
                            ObligationCause::new(obligation.cause.span,
                                obligation.cause.body_def_id,
                                ObligationCauseCode::MatchImpl(obligation.cause.clone(),
                                    impl_def_id));
                        let InferOk { obligations, .. } =
                            self.infcx.at(&cause,
                                            obligation.param_env).eq(DefineOpaqueTypes::No,
                                        placeholder_obligation_trait_ref,
                                        impl_trait_ref).map_err(|e|
                                        {
                                            {
                                                use ::tracing::__macro_support::Callsite as _;
                                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                                    {
                                                        static META: ::tracing::Metadata<'static> =
                                                            {
                                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2519",
                                                                    "rustc_trait_selection::traits::select",
                                                                    ::tracing::Level::DEBUG,
                                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                                    ::tracing_core::__macro_support::Option::Some(2519u32),
                                                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                                    ::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!("match_impl: failed eq_trait_refs due to `{0}`",
                                                                                                e.to_string(self.tcx())) as &dyn ::tracing::field::Value))])
                                                        });
                                                } else { ; }
                                            }
                                        })?;
                        nested_obligations.extend(obligations);
                        match self.typing_mode() {
                            TypingMode::Reflection if
                                !self.tcx().impl_is_fully_generic_for_reflection(impl_def_id)
                                => {
                                {
                                    use ::tracing::__macro_support::Callsite as _;
                                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                        {
                                            static META: ::tracing::Metadata<'static> =
                                                {
                                                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2527",
                                                        "rustc_trait_selection::traits::select",
                                                        ::tracing::Level::DEBUG,
                                                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                        ::tracing_core::__macro_support::Option::Some(2527u32),
                                                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                                        ::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!("reflection mode only allows fully generic impls")
                                                                            as &dyn ::tracing::field::Value))])
                                            });
                                    } else { ; }
                                };
                                return Err(());
                            }
                            TypingMode::Coherence | TypingMode::Typeck { .. } |
                                TypingMode::PostTypeckUntilBorrowck { .. } |
                                TypingMode::PostBorrowck { .. } | TypingMode::Codegen |
                                TypingMode::ErasedNotCoherence(_) | TypingMode::Reflection |
                                TypingMode::PostAnalysis => {}
                        }
                        Ok(Normalized {
                                value: impl_args,
                                obligations: nested_obligations,
                            })
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2480",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2480u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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)]
2481    fn match_impl(
2482        &mut self,
2483        impl_def_id: DefId,
2484        impl_trait_header: ty::ImplTraitHeader<'tcx>,
2485        obligation: &PolyTraitObligation<'tcx>,
2486    ) -> Result<Normalized<'tcx, GenericArgsRef<'tcx>>, ()> {
2487        let placeholder_obligation =
2488            self.infcx.enter_forall_and_leak_universe(obligation.predicate);
2489        let placeholder_obligation_trait_ref = placeholder_obligation.trait_ref;
2490
2491        let impl_args = self.infcx.fresh_args_for_item(obligation.cause.span, impl_def_id);
2492
2493        let trait_ref = impl_trait_header.trait_ref.instantiate(self.tcx(), impl_args);
2494        debug!(?impl_trait_header);
2495
2496        let mut nested_obligations = PredicateObligations::new();
2497        let impl_trait_ref = normalize_with_depth_to(
2498            self,
2499            obligation.param_env,
2500            obligation.cause.clone(),
2501            obligation.recursion_depth + 1,
2502            trait_ref,
2503            &mut nested_obligations,
2504        );
2505
2506        debug!(?impl_trait_ref, ?placeholder_obligation_trait_ref);
2507
2508        let cause = ObligationCause::new(
2509            obligation.cause.span,
2510            obligation.cause.body_def_id,
2511            ObligationCauseCode::MatchImpl(obligation.cause.clone(), impl_def_id),
2512        );
2513
2514        let InferOk { obligations, .. } = self
2515            .infcx
2516            .at(&cause, obligation.param_env)
2517            .eq(DefineOpaqueTypes::No, placeholder_obligation_trait_ref, impl_trait_ref)
2518            .map_err(|e| {
2519                debug!("match_impl: failed eq_trait_refs due to `{}`", e.to_string(self.tcx()))
2520            })?;
2521        nested_obligations.extend(obligations);
2522
2523        match self.typing_mode() {
2524            TypingMode::Reflection
2525                if !self.tcx().impl_is_fully_generic_for_reflection(impl_def_id) =>
2526            {
2527                debug!("reflection mode only allows fully generic impls");
2528                return Err(());
2529            }
2530
2531            TypingMode::Coherence
2532            | TypingMode::Typeck { .. }
2533            | TypingMode::PostTypeckUntilBorrowck { .. }
2534            | TypingMode::PostBorrowck { .. }
2535            | TypingMode::Codegen
2536            | TypingMode::ErasedNotCoherence(_)
2537            | TypingMode::Reflection
2538            | TypingMode::PostAnalysis => {}
2539        }
2540
2541        Ok(Normalized { value: impl_args, obligations: nested_obligations })
2542    }
2543
2544    fn match_upcast_principal(
2545        &mut self,
2546        obligation: &PolyTraitObligation<'tcx>,
2547        unnormalized_upcast_principal: ty::Unnormalized<'tcx, ty::PolyTraitRef<'tcx>>,
2548        a_data: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
2549        b_data: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
2550        a_region: ty::Region<'tcx>,
2551        b_region: ty::Region<'tcx>,
2552    ) -> SelectionResult<'tcx, PredicateObligations<'tcx>> {
2553        let tcx = self.tcx();
2554        let mut nested = PredicateObligations::new();
2555
2556        // We may upcast to auto traits that are either explicitly listed in
2557        // the object type's bounds, or implied by the principal trait ref's
2558        // supertraits.
2559        let a_auto_traits: FxIndexSet<DefId> = a_data
2560            .auto_traits()
2561            .chain(
2562                a_data
2563                    .principal_def_id()
2564                    .map(|principal_def_id| {
2565                        elaborate::supertrait_def_ids(tcx, principal_def_id)
2566                            .filter(|def_id| tcx.trait_is_auto(*def_id))
2567                    })
2568                    .into_flat_iter(),
2569            )
2570            .collect();
2571
2572        let upcast_principal = normalize_with_depth_to(
2573            self,
2574            obligation.param_env,
2575            obligation.cause.clone(),
2576            obligation.recursion_depth + 1,
2577            unnormalized_upcast_principal,
2578            &mut nested,
2579        );
2580
2581        for bound in b_data {
2582            match bound.skip_binder() {
2583                // Check that a_ty's supertrait (upcast_principal) is compatible
2584                // with the target (b_ty).
2585                ty::ExistentialPredicate::Trait(target_principal) => {
2586                    let hr_source_principal = upcast_principal.map_bound(|trait_ref| {
2587                        ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
2588                    });
2589                    let hr_target_principal = bound.rebind(target_principal);
2590
2591                    nested.extend(
2592                        self.infcx
2593                            .enter_forall(hr_target_principal, |target_principal| {
2594                                let source_principal =
2595                                    self.infcx.instantiate_binder_with_fresh_vars(
2596                                        obligation.cause.span,
2597                                        HigherRankedType,
2598                                        hr_source_principal,
2599                                    );
2600                                self.infcx.at(&obligation.cause, obligation.param_env).eq_trace(
2601                                    DefineOpaqueTypes::Yes,
2602                                    ToTrace::to_trace(
2603                                        &obligation.cause,
2604                                        hr_target_principal,
2605                                        hr_source_principal,
2606                                    ),
2607                                    target_principal,
2608                                    source_principal,
2609                                )
2610                            })
2611                            .map_err(|_| SelectionError::Unimplemented)?
2612                            .into_obligations(),
2613                    );
2614                }
2615                // Check that b_ty's projection is satisfied by exactly one of
2616                // a_ty's projections. First, we look through the list to see if
2617                // any match. If not, error. Then, if *more* than one matches, we
2618                // return ambiguity. Otherwise, if exactly one matches, equate
2619                // it with b_ty's projection.
2620                ty::ExistentialPredicate::Projection(target_projection) => {
2621                    let hr_target_projection = bound.rebind(target_projection);
2622
2623                    let mut matching_projections =
2624                        a_data.projection_bounds().filter(|&hr_source_projection| {
2625                            // Eager normalization means that we can just use can_eq
2626                            // here instead of equating and processing obligations.
2627                            hr_source_projection.item_def_id() == hr_target_projection.item_def_id()
2628                                && self.infcx.probe(|_| {
2629                                    self.infcx
2630                                        .enter_forall(hr_target_projection, |target_projection| {
2631                                            let source_projection =
2632                                                self.infcx.instantiate_binder_with_fresh_vars(
2633                                                    obligation.cause.span,
2634                                                    HigherRankedType,
2635                                                    hr_source_projection,
2636                                                );
2637                                            self.infcx
2638                                                .at(&obligation.cause, obligation.param_env)
2639                                                .eq_trace(
2640                                                    DefineOpaqueTypes::Yes,
2641                                                    ToTrace::to_trace(
2642                                                        &obligation.cause,
2643                                                        hr_target_projection,
2644                                                        hr_source_projection,
2645                                                    ),
2646                                                    target_projection,
2647                                                    source_projection,
2648                                                )
2649                                        })
2650                                        .is_ok()
2651                                })
2652                        });
2653
2654                    let Some(hr_source_projection) = matching_projections.next() else {
2655                        return Err(SelectionError::Unimplemented);
2656                    };
2657                    if matching_projections.next().is_some() {
2658                        return Ok(None);
2659                    }
2660                    nested.extend(
2661                        self.infcx
2662                            .enter_forall(hr_target_projection, |target_projection| {
2663                                let source_projection =
2664                                    self.infcx.instantiate_binder_with_fresh_vars(
2665                                        obligation.cause.span,
2666                                        HigherRankedType,
2667                                        hr_source_projection,
2668                                    );
2669                                self.infcx.at(&obligation.cause, obligation.param_env).eq_trace(
2670                                    DefineOpaqueTypes::Yes,
2671                                    ToTrace::to_trace(
2672                                        &obligation.cause,
2673                                        hr_target_projection,
2674                                        hr_source_projection,
2675                                    ),
2676                                    target_projection,
2677                                    source_projection,
2678                                )
2679                            })
2680                            .map_err(|_| SelectionError::Unimplemented)?
2681                            .into_obligations(),
2682                    );
2683                }
2684                // Check that b_ty's auto traits are present in a_ty's bounds.
2685                ty::ExistentialPredicate::AutoTrait(def_id) => {
2686                    if !a_auto_traits.contains(&def_id) {
2687                        return Err(SelectionError::Unimplemented);
2688                    }
2689                }
2690            }
2691        }
2692
2693        nested.push(Obligation::with_depth(
2694            tcx,
2695            obligation.cause.clone(),
2696            obligation.recursion_depth + 1,
2697            obligation.param_env,
2698            ty::Binder::dummy(ty::OutlivesClause(a_region, b_region)),
2699        ));
2700
2701        Ok(Some(nested))
2702    }
2703
2704    /// Normalize `where_clause_trait_ref` and try to match it against
2705    /// `obligation`. If successful, return any predicates that
2706    /// result from the normalization.
2707    fn match_where_clause_trait_ref(
2708        &mut self,
2709        obligation: &PolyTraitObligation<'tcx>,
2710        where_clause_trait_ref: ty::PolyTraitRef<'tcx>,
2711    ) -> Result<PredicateObligations<'tcx>, ()> {
2712        self.match_poly_trait_ref(obligation, where_clause_trait_ref)
2713    }
2714
2715    /// Returns `Ok` if `poly_trait_ref` being true implies that the
2716    /// obligation is satisfied.
2717    {}
#[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("match_poly_trait_ref",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2717u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("obligation");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("poly_trait_ref")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("poly_trait_ref");
                                                        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(&obligation)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&poly_trait_ref)
                                                            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<PredicateObligations<'tcx>, ()> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let predicate =
                self.infcx.enter_forall_and_leak_universe(obligation.predicate);
            let trait_ref =
                self.infcx.instantiate_binder_with_fresh_vars(obligation.cause.span,
                    HigherRankedType, poly_trait_ref);
            self.infcx.at(&obligation.cause,
                            obligation.param_env).eq(DefineOpaqueTypes::No,
                        predicate.trait_ref,
                        trait_ref).map(|InferOk { obligations, .. }|
                        obligations).map_err(|_| ())
        }
    }
}#[instrument(skip(self), level = "debug")]
2718    fn match_poly_trait_ref(
2719        &mut self,
2720        obligation: &PolyTraitObligation<'tcx>,
2721        poly_trait_ref: ty::PolyTraitRef<'tcx>,
2722    ) -> Result<PredicateObligations<'tcx>, ()> {
2723        let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
2724        let trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
2725            obligation.cause.span,
2726            HigherRankedType,
2727            poly_trait_ref,
2728        );
2729        self.infcx
2730            .at(&obligation.cause, obligation.param_env)
2731            .eq(DefineOpaqueTypes::No, predicate.trait_ref, trait_ref)
2732            .map(|InferOk { obligations, .. }| obligations)
2733            .map_err(|_| ())
2734    }
2735
2736    ///////////////////////////////////////////////////////////////////////////
2737    // Miscellany
2738
2739    fn match_fresh_trait_preds(
2740        &self,
2741        previous: ty::PolyTraitClause<'tcx>,
2742        current: ty::PolyTraitClause<'tcx>,
2743    ) -> bool {
2744        let mut matcher = _match::MatchAgainstFreshVars::new(self.tcx());
2745        matcher.relate(previous, current).is_ok()
2746    }
2747
2748    fn push_stack<'o>(
2749        &mut self,
2750        previous_stack: TraitObligationStackList<'o, 'tcx>,
2751        obligation: &'o PolyTraitObligation<'tcx>,
2752    ) -> TraitObligationStack<'o, 'tcx> {
2753        let fresh_trait_pred = obligation.predicate.fold_with(&mut self.freshener);
2754
2755        let dfn = previous_stack.cache.next_dfn();
2756        let depth = previous_stack.depth() + 1;
2757        TraitObligationStack {
2758            obligation,
2759            fresh_trait_pred,
2760            reached_depth: Cell::new(depth),
2761            previous: previous_stack,
2762            dfn,
2763            depth,
2764        }
2765    }
2766
2767    {}
#[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("closure_trait_ref_unnormalized",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2767u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("self_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("self_ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("fn_trait_def_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("fn_trait_def_id");
                                                        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(&self_ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_trait_def_id)
                                                            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: ty::PolyTraitRef<'tcx> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let ty::Closure(_, args) =
                *self_ty.kind() else {
                    ::rustc_middle::util::bug::bug_fmt(format_args!("expected closure, found {0}",
                            self_ty));
                };
            let closure_sig = args.as_closure().sig();
            closure_trait_ref_and_return_type(self.tcx(), fn_trait_def_id,
                    self_ty, closure_sig,
                    util::TupleArgumentsFlag::No).map_bound(|(trait_ref, _)|
                    trait_ref)
        }
    }
}#[instrument(skip(self), level = "debug")]
2768    fn closure_trait_ref_unnormalized(
2769        &mut self,
2770        self_ty: Ty<'tcx>,
2771        fn_trait_def_id: DefId,
2772    ) -> ty::PolyTraitRef<'tcx> {
2773        let ty::Closure(_, args) = *self_ty.kind() else {
2774            bug!("expected closure, found {self_ty}");
2775        };
2776        let closure_sig = args.as_closure().sig();
2777
2778        closure_trait_ref_and_return_type(
2779            self.tcx(),
2780            fn_trait_def_id,
2781            self_ty,
2782            closure_sig,
2783            util::TupleArgumentsFlag::No,
2784        )
2785        .map_bound(|(trait_ref, _)| trait_ref)
2786    }
2787
2788    /// Returns the obligations that are implied by instantiating an
2789    /// impl or trait. The obligations are instantiated and fully
2790    /// normalized. This is used when confirming an impl or default
2791    /// impl.
2792    {}
#[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("impl_or_trait_obligations",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2792u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("recursion_depth")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("recursion_depth");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("def_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("def_id");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("args")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("args");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("parent_trait_pred")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("parent_trait_pred");
                                                        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(&recursion_depth
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&def_id)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&parent_trait_pred)
                                                            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: PredicateObligations<'tcx> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.tcx();
            let clauses = tcx.clauses_of(def_id);
            {
                match (&clauses.parent, &None) {
                    (left_val, right_val) => {
                        if !(*left_val == *right_val) {
                            let kind = ::core::panicking::AssertKind::Eq;
                            ::core::panicking::assert_failed(kind, &*left_val,
                                &*right_val, ::core::option::Option::None);
                        }
                    }
                }
            };
            let clauses = clauses.instantiate_own(tcx, args);
            let mut obligations =
                PredicateObligations::with_capacity(clauses.len());
            for (index, (clause, span)) in clauses.into_iter().enumerate() {
                let cause =
                    if tcx.is_lang_item(parent_trait_pred.def_id(),
                            LangItem::CoerceUnsized) {
                        cause.clone()
                    } else {
                        cause.clone().derived_cause(parent_trait_pred,
                            |derived|
                                {
                                    ObligationCauseCode::ImplDerived(Box::new(ImplDerivedCause {
                                                derived,
                                                impl_or_alias_def_id: def_id,
                                                impl_def_clause_index: Some(index),
                                                span,
                                            }))
                                })
                    };
                let clause =
                    normalize_with_depth_to(self, param_env, cause.clone(),
                        recursion_depth, clause, &mut obligations);
                obligations.push(Obligation {
                        cause,
                        recursion_depth,
                        param_env,
                        predicate: clause.as_predicate(),
                    });
            }
            if tcx.def_kind(def_id) == (DefKind::Impl { of_trait: true }) {
                for clause in
                    tcx.impl_super_outlives(def_id).iter_instantiated(tcx, args)
                    {
                    let clause =
                        normalize_with_depth_to(self, param_env, cause.clone(),
                            recursion_depth, clause, &mut obligations);
                    obligations.push(Obligation {
                            cause: cause.clone(),
                            recursion_depth,
                            param_env,
                            predicate: clause.as_predicate(),
                        });
                }
            }
            obligations
        }
    }
}#[instrument(level = "debug", skip(self, cause, param_env))]
2793    fn impl_or_trait_obligations(
2794        &mut self,
2795        cause: &ObligationCause<'tcx>,
2796        recursion_depth: usize,
2797        param_env: ty::ParamEnv<'tcx>,
2798        def_id: DefId,              // of impl or trait
2799        args: GenericArgsRef<'tcx>, // for impl or trait
2800        parent_trait_pred: ty::Binder<'tcx, ty::TraitClause<'tcx>>,
2801    ) -> PredicateObligations<'tcx> {
2802        let tcx = self.tcx();
2803
2804        // To allow for one-pass evaluation of the nested obligation,
2805        // each predicate must be preceded by the obligations required
2806        // to normalize it.
2807        // for example, if we have:
2808        //    impl<U: Iterator<Item: Copy>, V: Iterator<Item = U>> Foo for V
2809        // the impl will have the following predicates:
2810        //    <V as Iterator>::Item = U,
2811        //    U: Iterator, U: Sized,
2812        //    V: Iterator, V: Sized,
2813        //    <U as Iterator>::Item: Copy
2814        // When we instantiate, say, `V => IntoIter<u32>, U => $0`, the last
2815        // obligation will normalize to `<$0 as Iterator>::Item = $1` and
2816        // `$1: Copy`, so we must ensure the obligations are emitted in
2817        // that order.
2818        let clauses = tcx.clauses_of(def_id);
2819        assert_eq!(clauses.parent, None);
2820        let clauses = clauses.instantiate_own(tcx, args);
2821        let mut obligations = PredicateObligations::with_capacity(clauses.len());
2822        for (index, (clause, span)) in clauses.into_iter().enumerate() {
2823            let cause = if tcx.is_lang_item(parent_trait_pred.def_id(), LangItem::CoerceUnsized) {
2824                cause.clone()
2825            } else {
2826                cause.clone().derived_cause(parent_trait_pred, |derived| {
2827                    ObligationCauseCode::ImplDerived(Box::new(ImplDerivedCause {
2828                        derived,
2829                        impl_or_alias_def_id: def_id,
2830                        impl_def_clause_index: Some(index),
2831                        span,
2832                    }))
2833                })
2834            };
2835            let clause = normalize_with_depth_to(
2836                self,
2837                param_env,
2838                cause.clone(),
2839                recursion_depth,
2840                clause,
2841                &mut obligations,
2842            );
2843            obligations.push(Obligation {
2844                cause,
2845                recursion_depth,
2846                param_env,
2847                predicate: clause.as_predicate(),
2848            });
2849        }
2850
2851        // Register any outlives obligations from the trait here, cc #124336.
2852        if tcx.def_kind(def_id) == (DefKind::Impl { of_trait: true }) {
2853            for clause in tcx.impl_super_outlives(def_id).iter_instantiated(tcx, args) {
2854                let clause = normalize_with_depth_to(
2855                    self,
2856                    param_env,
2857                    cause.clone(),
2858                    recursion_depth,
2859                    clause,
2860                    &mut obligations,
2861                );
2862                obligations.push(Obligation {
2863                    cause: cause.clone(),
2864                    recursion_depth,
2865                    param_env,
2866                    predicate: clause.as_predicate(),
2867                });
2868            }
2869        }
2870
2871        obligations
2872    }
2873
2874    pub(super) fn should_stall_coroutine(&self, def_id: DefId) -> bool {
2875        match self.typing_mode() {
2876            TypingMode::Typeck { defining_opaque_types_and_generators: stalled_generators } => {
2877                def_id.as_local().is_some_and(|def_id| stalled_generators.contains(&def_id))
2878            }
2879            TypingMode::Coherence
2880            | TypingMode::PostAnalysis
2881            | TypingMode::Reflection
2882            | TypingMode::Codegen
2883            | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types: _ }
2884            | TypingMode::PostBorrowck { defined_opaque_types: _ } => false,
2885        }
2886    }
2887}
2888
2889impl<'o, 'tcx> TraitObligationStack<'o, 'tcx> {
2890    fn list(&'o self) -> TraitObligationStackList<'o, 'tcx> {
2891        TraitObligationStackList::with(self)
2892    }
2893
2894    fn cache(&self) -> &'o ProvisionalEvaluationCache<'tcx> {
2895        self.previous.cache
2896    }
2897
2898    fn iter(&'o self) -> TraitObligationStackList<'o, 'tcx> {
2899        self.list()
2900    }
2901
2902    /// Indicates that attempting to evaluate this stack entry
2903    /// required accessing something from the stack at depth `reached_depth`.
2904    fn update_reached_depth(&self, reached_depth: usize) {
2905        if !(self.depth >= reached_depth) {
    {
        ::core::panicking::panic_fmt(format_args!("invoked `update_reached_depth` with something under this stack: self.depth={0} reached_depth={1}",
                self.depth, reached_depth));
    }
};assert!(
2906            self.depth >= reached_depth,
2907            "invoked `update_reached_depth` with something under this stack: \
2908             self.depth={} reached_depth={}",
2909            self.depth,
2910            reached_depth,
2911        );
2912        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2912",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2912u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("reached_depth")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("reached_depth");
                                            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!("update_reached_depth")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&reached_depth as
                                            &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(reached_depth, "update_reached_depth");
2913        let mut p = self;
2914        while reached_depth < p.depth {
2915            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2915",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2915u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("p.fresh_trait_pred")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("p.fresh_trait_pred");
                                            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!("update_reached_depth: marking as cycle participant")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&p.fresh_trait_pred)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?p.fresh_trait_pred, "update_reached_depth: marking as cycle participant");
2916            p.reached_depth.set(p.reached_depth.get().min(reached_depth));
2917            p = p.previous.head.unwrap();
2918        }
2919    }
2920}
2921
2922/// The "provisional evaluation cache" is used to store intermediate cache results
2923/// when solving auto traits. Auto traits are unusual in that they can support
2924/// cycles. So, for example, a "proof tree" like this would be ok:
2925///
2926/// - `Foo<T>: Send` :-
2927///   - `Bar<T>: Send` :-
2928///     - `Foo<T>: Send` -- cycle, but ok
2929///   - `Baz<T>: Send`
2930///
2931/// Here, to prove `Foo<T>: Send`, we have to prove `Bar<T>: Send` and
2932/// `Baz<T>: Send`. Proving `Bar<T>: Send` in turn required `Foo<T>: Send`.
2933/// For non-auto traits, this cycle would be an error, but for auto traits (because
2934/// they are coinductive) it is considered ok.
2935///
2936/// However, there is a complication: at the point where we have
2937/// "proven" `Bar<T>: Send`, we have in fact only proven it
2938/// *provisionally*. In particular, we proved that `Bar<T>: Send`
2939/// *under the assumption* that `Foo<T>: Send`. But what if we later
2940/// find out this assumption is wrong?  Specifically, we could
2941/// encounter some kind of error proving `Baz<T>: Send`. In that case,
2942/// `Bar<T>: Send` didn't turn out to be true.
2943///
2944/// In Issue #60010, we found a bug in rustc where it would cache
2945/// these intermediate results. This was fixed in #60444 by disabling
2946/// *all* caching for things involved in a cycle -- in our example,
2947/// that would mean we don't cache that `Bar<T>: Send`. But this led
2948/// to large slowdowns.
2949///
2950/// Specifically, imagine this scenario, where proving `Baz<T>: Send`
2951/// first requires proving `Bar<T>: Send` (which is true:
2952///
2953/// - `Foo<T>: Send` :-
2954///   - `Bar<T>: Send` :-
2955///     - `Foo<T>: Send` -- cycle, but ok
2956///   - `Baz<T>: Send`
2957///     - `Bar<T>: Send` -- would be nice for this to be a cache hit!
2958///     - `*const T: Send` -- but what if we later encounter an error?
2959///
2960/// The *provisional evaluation cache* resolves this issue. It stores
2961/// cache results that we've proven but which were involved in a cycle
2962/// in some way. We track the minimal stack depth (i.e., the
2963/// farthest from the top of the stack) that we are dependent on.
2964/// The idea is that the cache results within are all valid -- so long as
2965/// none of the nodes in between the current node and the node at that minimum
2966/// depth result in an error (in which case the cached results are just thrown away).
2967///
2968/// During evaluation, we consult this provisional cache and rely on
2969/// it. Accessing a cached value is considered equivalent to accessing
2970/// a result at `reached_depth`, so it marks the *current* solution as
2971/// provisional as well. If an error is encountered, we toss out any
2972/// provisional results added from the subtree that encountered the
2973/// error. When we pop the node at `reached_depth` from the stack, we
2974/// can commit all the things that remain in the provisional cache.
2975struct ProvisionalEvaluationCache<'tcx> {
2976    /// next "depth first number" to issue -- just a counter
2977    dfn: Cell<usize>,
2978
2979    /// Map from cache key to the provisionally evaluated thing.
2980    /// The cache entries contain the result but also the DFN in which they
2981    /// were added. The DFN is used to clear out values on failure.
2982    ///
2983    /// Imagine we have a stack like:
2984    ///
2985    /// - `A B C` and we add a cache for the result of C (DFN 2)
2986    /// - Then we have a stack `A B D` where `D` has DFN 3
2987    /// - We try to solve D by evaluating E: `A B D E` (DFN 4)
2988    /// - `E` generates various cache entries which have cyclic dependencies on `B`
2989    ///   - `A B D E F` and so forth
2990    ///   - the DFN of `F` for example would be 5
2991    /// - then we determine that `E` is in error -- we will then clear
2992    ///   all cache values whose DFN is >= 4 -- in this case, that
2993    ///   means the cached value for `F`.
2994    map: RefCell<FxIndexMap<ty::PolyTraitClause<'tcx>, ProvisionalEvaluation>>,
2995
2996    /// The stack of terms that we assume to be well-formed because a `WF(term)` predicate
2997    /// is on the stack above (and because of wellformedness is coinductive).
2998    /// In an "ideal" world, this would share a stack with trait predicates in
2999    /// `TraitObligationStack`. However, trait predicates are *much* hotter than
3000    /// `WellFormed` predicates, and it's very likely that the additional matches
3001    /// will have a perf effect. The value here is the well-formed `GenericArg`
3002    /// and the depth of the trait predicate *above* that well-formed predicate.
3003    wf_args: RefCell<Vec<(ty::Term<'tcx>, usize)>>,
3004}
3005
3006/// A cache value for the provisional cache: contains the depth-first
3007/// number (DFN) and result.
3008#[derive(#[automatically_derived]
impl ::core::marker::Copy for ProvisionalEvaluation { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ProvisionalEvaluation { }
#[automatically_derived]
impl ::core::clone::Clone for ProvisionalEvaluation {
    #[inline]
    fn clone(&self) -> ProvisionalEvaluation {
        let _: ::core::clone::AssertParamIsClone<usize>;
        let _: ::core::clone::AssertParamIsClone<EvaluationResult>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ProvisionalEvaluation {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "ProvisionalEvaluation", "from_dfn", &self.from_dfn,
            "reached_depth", &self.reached_depth, "result", &&self.result)
    }
}Debug)]
3009struct ProvisionalEvaluation {
3010    from_dfn: usize,
3011    reached_depth: usize,
3012    result: EvaluationResult,
3013}
3014
3015impl<'tcx> Default for ProvisionalEvaluationCache<'tcx> {
3016    fn default() -> Self {
3017        Self { dfn: Cell::new(0), map: Default::default(), wf_args: Default::default() }
3018    }
3019}
3020
3021impl<'tcx> ProvisionalEvaluationCache<'tcx> {
3022    /// Get the next DFN in sequence (basically a counter).
3023    fn next_dfn(&self) -> usize {
3024        let result = self.dfn.get();
3025        self.dfn.set(result + 1);
3026        result
3027    }
3028
3029    /// Check the provisional cache for any result for
3030    /// `fresh_trait_pred`. If there is a hit, then you must consider
3031    /// it an access to the stack slots at depth
3032    /// `reached_depth` (from the returned value).
3033    fn get_provisional(
3034        &self,
3035        fresh_trait_pred: ty::PolyTraitClause<'tcx>,
3036    ) -> Option<ProvisionalEvaluation> {
3037        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3037",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3037u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("fresh_trait_pred")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("fresh_trait_pred");
                                            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!("get_provisional = {0:#?}",
                                                    self.map.borrow().get(&fresh_trait_pred)) as
                                            &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fresh_trait_pred)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(
3038            ?fresh_trait_pred,
3039            "get_provisional = {:#?}",
3040            self.map.borrow().get(&fresh_trait_pred),
3041        );
3042        Some(*self.map.borrow().get(&fresh_trait_pred)?)
3043    }
3044
3045    /// Insert a provisional result into the cache. The result came
3046    /// from the node with the given DFN. It accessed a minimum depth
3047    /// of `reached_depth` to compute. It evaluated `fresh_trait_pred`
3048    /// and resulted in `result`.
3049    fn insert_provisional(
3050        &self,
3051        from_dfn: usize,
3052        reached_depth: usize,
3053        fresh_trait_pred: ty::PolyTraitClause<'tcx>,
3054        result: EvaluationResult,
3055    ) {
3056        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3056",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3056u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("from_dfn")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("from_dfn");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("fresh_trait_pred")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("fresh_trait_pred");
                                            NAME.as_str()
                                        },
                                        {
                                            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(&format_args!("insert_provisional")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&from_dfn)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fresh_trait_pred)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&result)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?from_dfn, ?fresh_trait_pred, ?result, "insert_provisional");
3057
3058        let mut map = self.map.borrow_mut();
3059
3060        // Subtle: when we complete working on the DFN `from_dfn`, anything
3061        // that remains in the provisional cache must be dependent on some older
3062        // stack entry than `from_dfn`. We have to update their depth with our transitive
3063        // depth in that case or else it would be referring to some popped note.
3064        //
3065        // Example:
3066        // A (reached depth 0)
3067        //   ...
3068        //      B // depth 1 -- reached depth = 0
3069        //          C // depth 2 -- reached depth = 1 (should be 0)
3070        //              B
3071        //          A // depth 0
3072        //   D (reached depth 1)
3073        //      C (cache -- reached depth = 2)
3074        for (_k, v) in &mut *map {
3075            if v.from_dfn >= from_dfn {
3076                v.reached_depth = reached_depth.min(v.reached_depth);
3077            }
3078        }
3079
3080        map.insert(fresh_trait_pred, ProvisionalEvaluation { from_dfn, reached_depth, result });
3081    }
3082
3083    /// Invoked when the node with dfn `dfn` does not get a successful
3084    /// result. This will clear out any provisional cache entries
3085    /// that were added since `dfn` was created. This is because the
3086    /// provisional entries are things which must assume that the
3087    /// things on the stack at the time of their creation succeeded --
3088    /// since the failing node is presently at the top of the stack,
3089    /// these provisional entries must either depend on it or some
3090    /// ancestor of it.
3091    fn on_failure(&self, dfn: usize) {
3092        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3092",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3092u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("dfn")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("dfn");
                                            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!("on_failure")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dfn)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?dfn, "on_failure");
3093        self.map.borrow_mut().retain(|key, eval| {
3094            if !eval.from_dfn >= dfn {
3095                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3095",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3095u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::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!("on_failure: removing {0:?}",
                                                    key) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("on_failure: removing {:?}", key);
3096                false
3097            } else {
3098                true
3099            }
3100        });
3101    }
3102
3103    /// Invoked when the node at depth `depth` completed without
3104    /// depending on anything higher in the stack (if that completion
3105    /// was a failure, then `on_failure` should have been invoked
3106    /// already).
3107    ///
3108    /// Note that we may still have provisional cache items remaining
3109    /// in the cache when this is done. For example, if there is a
3110    /// cycle:
3111    ///
3112    /// * A depends on...
3113    ///     * B depends on A
3114    ///     * C depends on...
3115    ///         * D depends on C
3116    ///     * ...
3117    ///
3118    /// Then as we complete the C node we will have a provisional cache
3119    /// with results for A, B, C, and D. This method would clear out
3120    /// the C and D results, but leave A and B provisional.
3121    ///
3122    /// This is determined based on the DFN: we remove any provisional
3123    /// results created since `dfn` started (e.g., in our example, dfn
3124    /// would be 2, representing the C node, and hence we would
3125    /// remove the result for D, which has DFN 3, but not the results for
3126    /// A and B, which have DFNs 0 and 1 respectively).
3127    ///
3128    /// Note that we *do not* attempt to cache these cycle participants
3129    /// in the evaluation cache. Doing so would require carefully computing
3130    /// the correct `DepNode` to store in the cache entry:
3131    /// cycle participants may implicitly depend on query results
3132    /// related to other participants in the cycle, due to our logic
3133    /// which examines the evaluation stack.
3134    ///
3135    /// We used to try to perform this caching,
3136    /// but it lead to multiple incremental compilation ICEs
3137    /// (see #92987 and #96319), and was very hard to understand.
3138    /// Fortunately, removing the caching didn't seem to
3139    /// have a performance impact in practice.
3140    fn on_completion(&self, dfn: usize) {
3141        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3141",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3141u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("dfn")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("dfn");
                                            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!("on_completion")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dfn)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?dfn, "on_completion");
3142        self.map.borrow_mut().retain(|fresh_trait_pred, eval| {
3143            if eval.from_dfn >= dfn {
3144                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3144",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3144u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("fresh_trait_pred")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("fresh_trait_pred");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("eval")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("eval");
                                            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!("on_completion")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fresh_trait_pred)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&eval)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?fresh_trait_pred, ?eval, "on_completion");
3145                return false;
3146            }
3147            true
3148        });
3149    }
3150}
3151
3152#[derive(#[automatically_derived]
impl<'o, 'tcx> ::core::marker::Copy for TraitObligationStackList<'o, 'tcx> { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl<'o, 'tcx> ::core::clone::TrivialClone for
    TraitObligationStackList<'o, 'tcx> {
}
#[automatically_derived]
impl<'o, 'tcx> ::core::clone::Clone for TraitObligationStackList<'o, 'tcx> {
    #[inline]
    fn clone(&self) -> TraitObligationStackList<'o, 'tcx> {
        let _:
                ::core::clone::AssertParamIsClone<&'o ProvisionalEvaluationCache<'tcx>>;
        let _:
                ::core::clone::AssertParamIsClone<Option<&'o TraitObligationStack<'o,
                'tcx>>>;
        *self
    }
}Clone)]
3153struct TraitObligationStackList<'o, 'tcx> {
3154    cache: &'o ProvisionalEvaluationCache<'tcx>,
3155    head: Option<&'o TraitObligationStack<'o, 'tcx>>,
3156}
3157
3158impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> {
3159    fn empty(cache: &'o ProvisionalEvaluationCache<'tcx>) -> TraitObligationStackList<'o, 'tcx> {
3160        TraitObligationStackList { cache, head: None }
3161    }
3162
3163    fn with(r: &'o TraitObligationStack<'o, 'tcx>) -> TraitObligationStackList<'o, 'tcx> {
3164        TraitObligationStackList { cache: r.cache(), head: Some(r) }
3165    }
3166
3167    fn head(&self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
3168        self.head
3169    }
3170
3171    fn depth(&self) -> usize {
3172        if let Some(head) = self.head { head.depth } else { 0 }
3173    }
3174}
3175
3176impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> {
3177    type Item = &'o TraitObligationStack<'o, 'tcx>;
3178
3179    fn next(&mut self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
3180        let o = self.head?;
3181        *self = o.previous;
3182        Some(o)
3183    }
3184}
3185
3186impl<'o, 'tcx> fmt::Debug for TraitObligationStack<'o, 'tcx> {
3187    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3188        f.write_fmt(format_args!("TraitObligationStack({0:?})", self.obligation))write!(f, "TraitObligationStack({:?})", self.obligation)
3189    }
3190}
3191
3192pub(crate) enum ProjectionMatchesProjection {
3193    Yes,
3194    Ambiguous,
3195    No,
3196}
3197
3198#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for AutoImplConstituents<'tcx> {
    #[inline]
    fn clone(&self) -> AutoImplConstituents<'tcx> {
        AutoImplConstituents {
            types: ::core::clone::Clone::clone(&self.types),
            assumptions: ::core::clone::Clone::clone(&self.assumptions),
        }
    }
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for AutoImplConstituents<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "AutoImplConstituents", "types", &self.types, "assumptions",
            &&self.assumptions)
    }
}Debug, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            for AutoImplConstituents<'tcx> {
            fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        AutoImplConstituents {
                            types: __binding_0, assumptions: __binding_1 } => {
                            AutoImplConstituents {
                                types: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                assumptions: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    AutoImplConstituents {
                        types: __binding_0, assumptions: __binding_1 } => {
                        AutoImplConstituents {
                            types: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            assumptions: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            for AutoImplConstituents<'tcx> {
            fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    AutoImplConstituents {
                        types: ref __binding_0, assumptions: ref __binding_1 } => {
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_middle::ty::VisitorResult>::output()
            }
        }
    };TypeVisitable)]
3199pub(crate) struct AutoImplConstituents<'tcx> {
3200    pub types: Vec<Ty<'tcx>>,
3201    pub assumptions: Vec<ty::ArgOutlivesClause<'tcx>>,
3202}