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_attr_ir::lang_items::LangItem;
12use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
13use rustc_errors::Diag;
14use rustc_hir as hir;
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::dep_graph::{DepKind, DepNodeIndex};
23pub use rustc_middle::traits::select::*;
24use rustc_middle::ty::abstract_const::NotConstEvaluatable;
25use rustc_middle::ty::error::TypeErrorToStringExt;
26use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths};
27use rustc_middle::ty::{
28    self, CallerBoundsIterator, CandidatePreferenceMode, CantBeErased, DeepRejectCtxt, GenericArgs,
29    PolyProjectionClause, SizedTraitKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, TypingMode,
30    Unnormalized, Upcast, elaborate, may_use_unstable_feature,
31};
32use rustc_next_trait_solver::solve::AliasBoundKind;
33use rustc_span::bug;
34use tracing::{debug, instrument, trace};
35
36use self::EvaluationResult::*;
37use self::SelectionCandidate::*;
38use super::project::ProjectionTermObligation;
39use super::util::closure_trait_ref_and_return_type;
40use super::{
41    ImplDerivedCause, Normalized, Obligation, ObligationCause, ObligationCauseCode,
42    PolyTraitObligation, PredicateObligation, Selection, SelectionError, SelectionResult,
43    TraitQueryMode, const_evaluatable, project, util, wf,
44};
45use crate::error_reporting::InferCtxtErrorExt;
46use crate::infer::{InferCtxt, InferOk, TypeFreshener};
47use crate::solve::InferCtxtSelectExt as _;
48use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to};
49use crate::traits::project::{ProjectAndUnifyResult, ProjectionCacheKeyExt};
50use crate::traits::{EvaluateConstErr, ProjectionCacheKey, effects, implicit_fast_path};
51
52mod _match;
53mod candidate_assembly;
54mod confirmation;
55
56#[derive(#[automatically_derived]impl<'tcx> ::core::clone::Clone for
    IntercrateAmbiguityCause<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        match self {
            Self::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),
                },
            Self::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]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::DownstreamCrate { trait_ref: __self_0, self_ty: __self_1 }
                =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "DownstreamCrate trait_ref self_ty", __self_0, &__self_1),
            Self::UpstreamCrateUpdate { trait_ref: __self_0, self_ty: __self_1
                } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "UpstreamCrateUpdate trait_ref self_ty", __self_0,
                    &__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: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::DownstreamCrate {
                    trait_ref: __self_0, self_ty: __self_1 },
                    Self::DownstreamCrate {
                    trait_ref: __arg1_0, self_ty: __arg1_1 }) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (Self::UpstreamCrateUpdate {
                    trait_ref: __self_0, self_ty: __self_1 },
                    Self::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) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::DownstreamCrate { trait_ref: __self_0, self_ty: __self_1 }
                => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
            Self::UpstreamCrateUpdate { trait_ref: __self_0, self_ty: __self_1
                } => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
        }
    }
}Hash)]
57pub enum IntercrateAmbiguityCause<'tcx> {
58    DownstreamCrate { trait_ref: ty::TraitRef<'tcx>, self_ty: Option<Ty<'tcx>> },
59    UpstreamCrateUpdate { trait_ref: ty::TraitRef<'tcx>, self_ty: Option<Ty<'tcx>> },
60}
61
62impl<'tcx> IntercrateAmbiguityCause<'tcx> {
63    /// Emits notes when the overlap is caused by complex intercrate ambiguities.
64    /// See #23980 for details.
65    pub fn add_intercrate_ambiguity_hint(&self, err: &mut Diag<'_>) {
66        err.note(self.intercrate_ambiguity_hint());
67    }
68
69    pub fn intercrate_ambiguity_hint(&self) -> String {
70        {
    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 {
71            IntercrateAmbiguityCause::DownstreamCrate { trait_ref, self_ty } => {
72                format!(
73                    "downstream crates may implement trait `{trait_desc}`{self_desc}",
74                    trait_desc = trait_ref.print_trait_sugared(),
75                    self_desc = if let Some(self_ty) = self_ty {
76                        format!(" for type `{self_ty}`")
77                    } else {
78                        String::new()
79                    }
80                )
81            }
82            IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_ref, self_ty } => {
83                format!(
84                    "upstream crates may add a new impl of trait `{trait_desc}`{self_desc} \
85                in future versions",
86                    trait_desc = trait_ref.print_trait_sugared(),
87                    self_desc = if let Some(self_ty) = self_ty {
88                        format!(" for type `{self_ty}`")
89                    } else {
90                        String::new()
91                    }
92                )
93            }
94        })
95    }
96}
97
98pub struct SelectionContext<'cx, 'tcx> {
99    pub infcx: &'cx InferCtxt<'tcx>,
100
101    /// Freshener used specifically for entries on the obligation
102    /// stack. This ensures that all entries on the stack at one time
103    /// will have the same set of placeholder entries, which is
104    /// important for checking for trait bounds that recursively
105    /// require themselves.
106    freshener: TypeFreshener<'cx, 'tcx>,
107
108    /// The mode that trait queries run in, which informs our error handling
109    /// policy. In essence, canonicalized queries need their errors propagated
110    /// rather than immediately reported because we do not have accurate spans.
111    query_mode: TraitQueryMode,
112}
113
114// A stack that walks back up the stack frame.
115struct TraitObligationStack<'prev, 'tcx> {
116    obligation: &'prev PolyTraitObligation<'tcx>,
117
118    /// The trait predicate from `obligation` but "freshened" with the
119    /// selection-context's freshener. Used to check for recursion.
120    fresh_trait_pred: ty::PolyTraitClause<'tcx>,
121
122    /// Starts out equal to `depth` -- if, during evaluation, we
123    /// encounter a cycle, then we will set this flag to the minimum
124    /// depth of that cycle for all participants in the cycle. These
125    /// participants will then forego caching their results. This is
126    /// not the most efficient solution, but it addresses #60010. The
127    /// problem we are trying to prevent:
128    ///
129    /// - If you have `A: AutoTrait` requires `B: AutoTrait` and `C: NonAutoTrait`
130    /// - `B: AutoTrait` requires `A: AutoTrait` (coinductive cycle, ok)
131    /// - `C: NonAutoTrait` requires `A: AutoTrait` (non-coinductive cycle, not ok)
132    ///
133    /// you don't want to cache that `B: AutoTrait` or `A: AutoTrait`
134    /// is `EvaluatedToOk`; this is because they were only considered
135    /// ok on the premise that if `A: AutoTrait` held, but we indeed
136    /// encountered a problem (later on) with `A: AutoTrait`. So we
137    /// currently set a flag on the stack node for `B: AutoTrait` (as
138    /// well as the second instance of `A: AutoTrait`) to suppress
139    /// caching.
140    ///
141    /// This is a simple, targeted fix. A more-performant fix requires
142    /// deeper changes, but would permit more caching: we could
143    /// basically defer caching until we have fully evaluated the
144    /// tree, and then cache the entire tree at once. In any case, the
145    /// performance impact here shouldn't be so horrible: every time
146    /// this is hit, we do cache at least one trait, so we only
147    /// evaluate each member of a cycle up to N times, where N is the
148    /// length of the cycle. This means the performance impact is
149    /// bounded and we shouldn't have any terrible worst-cases.
150    reached_depth: Cell<usize>,
151
152    previous: TraitObligationStackList<'prev, 'tcx>,
153
154    /// The number of parent frames plus one (thus, the topmost frame has depth 1).
155    depth: usize,
156
157    /// The depth-first number of this node in the search graph -- a
158    /// pre-order index. Basically, a freshly incremented counter.
159    dfn: usize,
160}
161
162struct SelectionCandidateSet<'tcx> {
163    /// A list of candidates that definitely apply to the current
164    /// obligation (meaning: types unify).
165    vec: Vec<SelectionCandidate<'tcx>>,
166
167    /// If `true`, then there were candidates that might or might
168    /// not have applied, but we couldn't tell. This occurs when some
169    /// of the input types are type variables, in which case there are
170    /// various "builtin" rules that might or might not trigger.
171    ambiguous: bool,
172}
173
174#[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: &Self) -> 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]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "EvaluatedCandidate candidate evaluation", &self.candidate,
            &&self.evaluation)
    }
}Debug, #[automatically_derived]impl<'tcx> ::core::clone::Clone for
    EvaluatedCandidate<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        EvaluatedCandidate {
            candidate: ::core::clone::Clone::clone(&self.candidate),
            evaluation: ::core::clone::Clone::clone(&self.evaluation),
        }
    }
}Clone)]
175struct EvaluatedCandidate<'tcx> {
176    candidate: SelectionCandidate<'tcx>,
177    evaluation: EvaluationResult,
178}
179
180impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
181    pub fn new(infcx: &'cx InferCtxt<'tcx>) -> SelectionContext<'cx, 'tcx> {
182        SelectionContext {
183            infcx,
184            freshener: TypeFreshener::new(infcx),
185            query_mode: TraitQueryMode::Standard,
186        }
187    }
188
189    pub fn typing_mode(&self) -> TypingMode<'tcx, CantBeErased> {
190        self.infcx.typing_mode_raw().assert_not_erased()
191    }
192
193    pub fn with_query_mode(
194        infcx: &'cx InferCtxt<'tcx>,
195        query_mode: TraitQueryMode,
196    ) -> SelectionContext<'cx, 'tcx> {
197        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:197",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(197u32),
                        ::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");
198        SelectionContext { query_mode, ..SelectionContext::new(infcx) }
199    }
200
201    pub fn tcx(&self) -> TyCtxt<'tcx> {
202        self.infcx.tcx
203    }
204
205    ///////////////////////////////////////////////////////////////////////////
206    // Selection
207    //
208    // The selection phase tries to identify *how* an obligation will
209    // be resolved. For example, it will identify which impl or
210    // parameter bound is to be used. The process can be inconclusive
211    // if the self type in the obligation is not fully inferred. Selection
212    // can result in an error in one of two ways:
213    //
214    // 1. If no applicable impl or parameter bound can be found.
215    // 2. If the output type parameters in the obligation do not match
216    //    those specified by the impl/bound. For example, if the obligation
217    //    is `Vec<Foo>: Iterable<Bar>`, but the impl specifies
218    //    `impl<T> Iterable<T> for Vec<T>`, than an error would result.
219
220    /// Attempts to satisfy the obligation. If successful, this will affect the surrounding
221    /// type environment by performing unification.
222    {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(222u32),
                                ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:222",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(222u32),
                        ::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)]
223    pub fn poly_select(
224        &mut self,
225        obligation: &PolyTraitObligation<'tcx>,
226    ) -> SelectionResult<'tcx, Selection<'tcx>> {
227        if self.infcx.next_trait_solver() {
228            return self.infcx.select_in_new_trait_solver(obligation);
229        }
230
231        let candidate = match self.select_from_obligation(obligation) {
232            Err(SelectionError::Overflow(OverflowError::Canonical)) => {
233                // In standard mode, overflow must have been caught and reported
234                // earlier.
235                assert!(self.query_mode == TraitQueryMode::Canonical);
236                return Err(SelectionError::Overflow(OverflowError::Canonical));
237            }
238            Err(e) => {
239                return Err(e);
240            }
241            Ok(None) => {
242                return Ok(None);
243            }
244            Ok(Some(candidate)) => candidate,
245        };
246
247        match self.confirm_candidate(obligation, candidate) {
248            Err(SelectionError::Overflow(OverflowError::Canonical)) => {
249                assert!(self.query_mode == TraitQueryMode::Canonical);
250                Err(SelectionError::Overflow(OverflowError::Canonical))
251            }
252            Err(e) => Err(e),
253            Ok(ImplSource::Builtin(..)) if self.typing_mode().is_reflection() => {
254                // Builtin impls regularly don't satisfy the try_as_dyn requirements, so
255                // we just reject all of them.
256                Err(SelectionError::Unimplemented)
257            }
258            Ok(candidate) => Ok(Some(candidate)),
259        }
260    }
261
262    pub fn select(
263        &mut self,
264        obligation: &TraitObligation<'tcx>,
265    ) -> SelectionResult<'tcx, Selection<'tcx>> {
266        self.poly_select(&Obligation {
267            cause: obligation.cause.clone(),
268            param_env: obligation.param_env,
269            predicate: ty::Binder::dummy(obligation.predicate),
270            recursion_depth: obligation.recursion_depth,
271        })
272    }
273
274    fn select_from_obligation(
275        &mut self,
276        obligation: &PolyTraitObligation<'tcx>,
277    ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
278        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());
279
280        let pec = &ProvisionalEvaluationCache::default();
281        let stack = self.push_stack(TraitObligationStackList::empty(pec), obligation);
282
283        self.candidate_from_obligation(&stack)
284    }
285
286    {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(286u32),
                                ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:302",
                                                "rustc_trait_selection::traits::select",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(302u32),
                                                ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:308",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(308u32),
                                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:321",
                                                "rustc_trait_selection::traits::select",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(321u32),
                                                ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:286",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(286u32),
                        ::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)]
287    fn candidate_from_obligation<'o>(
288        &mut self,
289        stack: &TraitObligationStack<'o, 'tcx>,
290    ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
291        debug_assert!(!self.infcx.next_trait_solver());
292        // Watch out for overflow. This intentionally bypasses (and does
293        // not update) the cache.
294        self.check_recursion_limit(stack.obligation, stack.obligation)?;
295
296        // Check the cache. Note that we freshen the trait-ref
297        // separately rather than using `stack.fresh_trait_pred` --
298        // this is because we want the unbound variables to be
299        // replaced with fresh types starting from index 0.
300        let cache_fresh_trait_pred =
301            stack.obligation.predicate.fold_with(&mut TypeFreshener::new(self.infcx));
302        debug!(?cache_fresh_trait_pred);
303        debug_assert!(!stack.obligation.predicate.has_escaping_bound_vars());
304
305        if let Some(c) =
306            self.check_candidate_cache(stack.obligation.param_env, cache_fresh_trait_pred)
307        {
308            debug!("CACHE HIT");
309            return c;
310        }
311
312        // If no match, compute result and insert into cache.
313        //
314        // FIXME(nikomatsakis) -- this cache is not taking into
315        // account cycles that may have occurred in forming the
316        // candidate. I don't know of any specific problems that
317        // result but it seems awfully suspicious.
318        let (candidate, dep_node) =
319            self.in_task(|this| this.candidate_from_obligation_no_cache(stack));
320
321        debug!("CACHE MISS");
322        self.insert_candidate_cache(
323            stack.obligation.param_env,
324            cache_fresh_trait_pred,
325            dep_node,
326            candidate.clone(),
327        );
328        candidate
329    }
330
331    fn candidate_from_obligation_no_cache<'o>(
332        &mut self,
333        stack: &TraitObligationStack<'o, 'tcx>,
334    ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
335        let candidate_set = self.assemble_candidates(stack)?;
336
337        if candidate_set.ambiguous {
338            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:338",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(338u32),
                        ::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");
339            return Ok(None);
340        }
341
342        let candidates = candidate_set.vec;
343
344        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:344",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(344u32),
                        ::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());
345
346        // At this point, we know that each of the entries in the
347        // candidate set is *individually* applicable. Now we have to
348        // figure out if they contain mutual incompatibilities. This
349        // frequently arises if we have an unconstrained input type --
350        // for example, we are looking for `$0: Eq` where `$0` is some
351        // unconstrained type variable. In that case, we'll get a
352        // candidate which assumes $0 == int, one that assumes `$0 ==
353        // usize`, etc. This spells an ambiguity.
354
355        let mut candidates = self.filter_impls(candidates, stack.obligation);
356
357        // If there is more than one candidate, first winnow them down
358        // by considering extra conditions (nested obligations and so
359        // forth). We don't winnow if there is exactly one
360        // candidate. This is a relatively minor distinction but it
361        // can lead to better inference and error-reporting. An
362        // example would be if there was an impl:
363        //
364        //     impl<T:Clone> Vec<T> { fn push_clone(...) { ... } }
365        //
366        // and we were to see some code `foo.push_clone()` where `boo`
367        // is a `Vec<Bar>` and `Bar` does not implement `Clone`. If
368        // we were to winnow, we'd wind up with zero candidates.
369        // Instead, we select the right impl now but report "`Bar` does
370        // not implement `Clone`".
371        if candidates.len() == 1 {
372            return Ok(candidates.pop());
373        }
374
375        // Winnow, but record the exact outcome of evaluation, which
376        // is needed for specialization. Propagate overflow if it occurs.
377        let candidates = candidates
378            .into_iter()
379            .map(|c| match self.evaluate_candidate(stack, &c) {
380                Ok(eval) if eval.may_apply() => {
381                    Ok(Some(EvaluatedCandidate { candidate: c, evaluation: eval }))
382                }
383                Ok(_) => Ok(None),
384                Err(OverflowError::Canonical) => {
385                    Err(SelectionError::Overflow(OverflowError::Canonical))
386                }
387                Err(OverflowError::Error(e)) => {
388                    Err(SelectionError::Overflow(OverflowError::Error(e)))
389                }
390            })
391            .flat_map(Result::transpose)
392            .collect::<Result<Vec<_>, _>>()?;
393
394        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:394",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(394u32),
                        ::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());
395        // If there are *NO* candidates, then there are no impls --
396        // that we know of, anyway. Note that in the case where there
397        // are unbound type variables within the obligation, it might
398        // be the case that you could still satisfy the obligation
399        // from another crate by instantiating the type variables with
400        // a type from another crate that does have an impl. This case
401        // is checked for in `evaluate_stack` (and hence users
402        // who might care about this case, like coherence, should use
403        // that function).
404        if candidates.is_empty() {
405            // If there's an error type, 'downgrade' our result from
406            // `Err(Unimplemented)` to `Ok(None)`. This helps us avoid
407            // emitting additional spurious errors, since we're guaranteed
408            // to have emitted at least one.
409            if stack.obligation.predicate.references_error() {
410                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:410",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(410u32),
                        ::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");
411                Ok(None)
412            } else {
413                Err(SelectionError::Unimplemented)
414            }
415        } else {
416            let has_non_region_infer = stack.obligation.predicate.has_non_region_infer();
417            let candidate_preference_mode =
418                CandidatePreferenceMode::compute(self.tcx(), stack.obligation.predicate.def_id());
419            Ok(self.winnow_candidates(has_non_region_infer, candidate_preference_mode, candidates))
420        }
421    }
422
423    ///////////////////////////////////////////////////////////////////////////
424    // EVALUATION
425    //
426    // Tests whether an obligation can be selected or whether an impl
427    // can be applied to particular types. It skips the "confirmation"
428    // step and hence completely ignores output type parameters.
429    //
430    // The result is "true" if the obligation *may* hold and "false" if
431    // we can be sure it does not.
432
433    /// Evaluates whether the obligation `obligation` can be satisfied
434    /// and returns an `EvaluationResult`. This is meant for the
435    /// *initial* call.
436    ///
437    /// Do not use this directly, use `infcx.evaluate_obligation` instead.
438    pub fn evaluate_root_obligation(
439        &mut self,
440        obligation: &PredicateObligation<'tcx>,
441    ) -> Result<EvaluationResult, OverflowError> {
442        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());
443        self.evaluation_probe(|this| {
444            let goal = this
445                .infcx
446                .deeply_resolve_ignoring_regions((obligation.predicate, obligation.param_env));
447            let mut result = this.evaluate_predicate_recursively(
448                TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
449                obligation.clone(),
450            )?;
451            // If the predicate has done any inference, then downgrade the
452            // result to ambiguous.
453            if this.infcx.deeply_resolve_ignoring_regions(goal) != goal {
454                result = result.max(EvaluatedToAmbig);
455            }
456            Ok(result)
457        })
458    }
459
460    /// Computes the evaluation result of `op`, discarding any constraints.
461    ///
462    /// This also runs for leak check to allow higher ranked region errors to impact
463    /// selection. By default it checks for leaks from all universes created inside of
464    /// `op`, but this can be overwritten if necessary.
465    fn evaluation_probe(
466        &mut self,
467        op: impl FnOnce(&mut Self) -> Result<EvaluationResult, OverflowError>,
468    ) -> Result<EvaluationResult, OverflowError> {
469        self.infcx.probe(|snapshot| -> Result<EvaluationResult, OverflowError> {
470            let outer_universe = self.infcx.universe();
471            let result = op(self)?;
472
473            match self.infcx.leak_check(outer_universe, Some(snapshot)) {
474                Ok(()) => {}
475                Err(_) => return Ok(EvaluatedToErr),
476            }
477
478            if self.infcx.opaque_types_added_in_snapshot(snapshot) {
479                return Ok(result.max(EvaluatedToOkModuloOpaqueTypes));
480            }
481
482            if self.infcx.region_constraints_added_in_snapshot(snapshot) {
483                Ok(result.max(EvaluatedToOkModuloRegions))
484            } else {
485                Ok(result)
486            }
487        })
488    }
489
490    /// Evaluates the predicates in `predicates` recursively. This may
491    /// guide inference. If this is not desired, run it inside of a
492    /// is run within an inference probe.
493    /// `probe`.
494    {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(494u32),
                                    ::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)?;
                if let EvaluatedToErr = eval {
                    return Ok(EvaluatedToErr);
                } else { result = cmp::max(result, eval); }
            }
            Ok(result)
        }
    }
}#[instrument(skip(self, stack), level = "debug")]
495    fn evaluate_predicates_recursively<'o, I>(
496        &mut self,
497        stack: TraitObligationStackList<'o, 'tcx>,
498        predicates: I,
499    ) -> Result<EvaluationResult, OverflowError>
500    where
501        I: IntoIterator<Item = PredicateObligation<'tcx>> + std::fmt::Debug,
502    {
503        let mut result = EvaluatedToOk;
504        for mut obligation in predicates {
505            obligation.set_depth_from_parent(stack.depth());
506            let eval = self.evaluate_predicate_recursively(stack, obligation)?;
507            if let EvaluatedToErr = eval {
508                // fast-path - EvaluatedToErr is the top of the lattice,
509                // so we don't need to look on the other predicates.
510                return Ok(EvaluatedToErr);
511            } else {
512                result = cmp::max(result, eval);
513            }
514        }
515        Ok(result)
516    }
517
518    {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(518u32),
                                ::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() &&
                                implicit_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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:623",
                                                            "rustc_trait_selection::traits::select",
                                                            ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(623u32),
                                                            ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:800",
                                                            "rustc_trait_selection::traits::select",
                                                            ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(800u32),
                                                            ::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_span::macros::bug_impl(None,
                                    format_args!("NormalizesTo is only used by the new solver"),
                                    Location::caller())
                            }
                            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_span::macros::bug_impl(None,
                                                format_args!("placeholder const {0:?} in old solver", ct),
                                                Location::caller())
                                        }
                                        ty::ConstKind::Bound(_, _) =>
                                            ::rustc_span::macros::bug_impl(None,
                                                format_args!("escaping bound vars in {0:?}", ct),
                                                Location::caller()),
                                        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),
                                }
                            }
                            ty::PredicateKind::Clause(ty::ClauseKind::CompressedTrait(_))
                                => ::core::panicking::unreachable_default_msg(),
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:518",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(518u32),
                        ::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(
519        level = "debug",
520        skip(self, previous_stack),
521        fields(previous_stack = ?previous_stack.head())
522        ret,
523    )]
524    fn evaluate_predicate_recursively<'o>(
525        &mut self,
526        previous_stack: TraitObligationStackList<'o, 'tcx>,
527        obligation: PredicateObligation<'tcx>,
528    ) -> Result<EvaluationResult, OverflowError> {
529        debug_assert!(!self.infcx.next_trait_solver());
530        // `previous_stack` stores a `PolyTraitObligation`, while `obligation` is
531        // a `PredicateObligation`. These are distinct types, so we can't
532        // use any `Option` combinator method that would force them to be
533        // the same.
534        match previous_stack.head() {
535            Some(h) => self.check_recursion_limit(&obligation, h.obligation)?,
536            None => self.check_recursion_limit(&obligation, &obligation)?,
537        }
538
539        if !self.infcx.disable_trait_solver_fast_paths()
540            && implicit_fast_path(self.tcx(), obligation.predicate, obligation.param_env)
541        {
542            return Ok(EvaluatedToOk);
543        }
544
545        let bound_predicate = obligation.predicate.kind();
546        match bound_predicate.skip_binder() {
547            ty::PredicateKind::Clause(ty::ClauseKind::Trait(t)) => {
548                let t = bound_predicate.rebind(t);
549                debug_assert!(!t.has_escaping_bound_vars());
550                let obligation = obligation.with(self.tcx(), t);
551                self.evaluate_trait_predicate_recursively(previous_stack, obligation)
552            }
553
554            ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(data)) => {
555                self.infcx.enter_forall(bound_predicate.rebind(data), |data| {
556                    match effects::evaluate_host_effect_obligation(
557                        self,
558                        &obligation.with(self.tcx(), data),
559                    ) {
560                        Ok(nested) => self.evaluate_predicates_recursively(previous_stack, nested),
561                        Err(effects::EvaluationFailure::Ambiguous) => Ok(EvaluatedToAmbig),
562                        Err(effects::EvaluationFailure::NoSolution) => Ok(EvaluatedToErr),
563                    }
564                })
565            }
566
567            ty::PredicateKind::Subtype(p) => {
568                let p = bound_predicate.rebind(p);
569                // Does this code ever run?
570                match self.infcx.subtype_predicate(&obligation.cause, obligation.param_env, p) {
571                    Ok(Ok(InferOk { obligations, .. })) => {
572                        self.evaluate_predicates_recursively(previous_stack, obligations)
573                    }
574                    Ok(Err(_)) => Ok(EvaluatedToErr),
575                    Err(..) => Ok(EvaluatedToAmbig),
576                }
577            }
578
579            ty::PredicateKind::Coerce(p) => {
580                let p = bound_predicate.rebind(p);
581                // Does this code ever run?
582                match self.infcx.coerce_predicate(&obligation.cause, obligation.param_env, p) {
583                    Ok(Ok(InferOk { obligations, .. })) => {
584                        self.evaluate_predicates_recursively(previous_stack, obligations)
585                    }
586                    Ok(Err(_)) => Ok(EvaluatedToErr),
587                    Err(..) => Ok(EvaluatedToAmbig),
588                }
589            }
590
591            ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
592                if term.is_trivially_wf(self.tcx()) {
593                    return Ok(EvaluatedToOk);
594                }
595
596                // So, there is a bit going on here. First, `WellFormed` predicates
597                // are coinductive, like trait predicates with auto traits.
598                // This means that we need to detect if we have recursively
599                // evaluated `WellFormed(X)`. Otherwise, we would run into
600                // a "natural" overflow error.
601                //
602                // Now, the next question is whether we need to do anything
603                // special with caching. Considering the following tree:
604                // - `WF(Foo<T>)`
605                //   - `Bar<T>: Send`
606                //     - `WF(Foo<T>)`
607                //   - `Foo<T>: Trait`
608                // In this case, the innermost `WF(Foo<T>)` should return
609                // `EvaluatedToOk`, since it's coinductive. Then if
610                // `Bar<T>: Send` is resolved to `EvaluatedToOk`, it can be
611                // inserted into a cache (because without thinking about `WF`
612                // goals, it isn't in a cycle). If `Foo<T>: Trait` later doesn't
613                // hold, then `Bar<T>: Send` shouldn't hold. Therefore, we
614                // *do* need to keep track of coinductive cycles.
615
616                let cache = previous_stack.cache;
617                let dfn = cache.next_dfn();
618
619                for stack_term in previous_stack.cache.wf_args.borrow().iter().rev() {
620                    if stack_term.0 != term {
621                        continue;
622                    }
623                    debug!("WellFormed({:?}) on stack", term);
624                    if let Some(stack) = previous_stack.head {
625                        // Okay, let's imagine we have two different stacks:
626                        //   `T: NonAutoTrait -> WF(T) -> T: NonAutoTrait`
627                        //   `WF(T) -> T: NonAutoTrait -> WF(T)`
628                        // Because of this, we need to check that all
629                        // predicates between the WF goals are coinductive.
630                        // Otherwise, we can say that `T: NonAutoTrait` is
631                        // true.
632                        // Let's imagine we have a predicate stack like
633                        //         `Foo: Bar -> WF(T) -> T: NonAutoTrait -> T: Auto`
634                        // depth   ^1                    ^2                 ^3
635                        // and the current predicate is `WF(T)`. `wf_args`
636                        // would contain `(T, 1)`. We want to check all
637                        // trait predicates greater than `1`. The previous
638                        // stack would be `T: Auto`.
639                        let cycle = stack.iter().take_while(|s| s.depth > stack_term.1);
640                        let tcx = self.tcx();
641                        let cycle = cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
642                        if self.coinductive_match(cycle) {
643                            stack.update_reached_depth(stack_term.1);
644                            return Ok(EvaluatedToOk);
645                        } else {
646                            return Ok(EvaluatedToAmbigStackDependent);
647                        }
648                    }
649                    return Ok(EvaluatedToOk);
650                }
651
652                match wf::obligations(
653                    self.infcx,
654                    obligation.param_env,
655                    obligation.cause.body_def_id,
656                    obligation.recursion_depth + 1,
657                    term,
658                    obligation.cause.span,
659                ) {
660                    Some(obligations) => {
661                        cache.wf_args.borrow_mut().push((term, previous_stack.depth()));
662                        let result =
663                            self.evaluate_predicates_recursively(previous_stack, obligations);
664                        cache.wf_args.borrow_mut().pop();
665
666                        let result = result?;
667
668                        if !result.must_apply_modulo_regions() {
669                            cache.on_failure(dfn);
670                        }
671
672                        cache.on_completion(dfn);
673
674                        Ok(result)
675                    }
676                    None => Ok(EvaluatedToAmbig),
677                }
678            }
679
680            ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(pred)) => {
681                // A global type with no free lifetimes or generic parameters
682                // outlives anything.
683                if pred.0.has_free_regions()
684                    || pred.0.has_bound_regions()
685                    || pred.0.has_non_region_infer()
686                    || pred.0.has_non_region_param()
687                {
688                    Ok(EvaluatedToOkModuloRegions)
689                } else {
690                    Ok(EvaluatedToOk)
691                }
692            }
693
694            ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..)) => {
695                // We do not consider region relationships when evaluating trait matches.
696                Ok(EvaluatedToOkModuloRegions)
697            }
698
699            ty::PredicateKind::DynCompatible(trait_def_id) => {
700                // `DynCompatible` obligations are only emitted as
701                // nested obligations of `WellFormed` goals. It is quite
702                // rare, but possible, that we encounter them during
703                // evaluation. See #158665 for more details here.
704                if self.tcx().is_dyn_compatible(trait_def_id) {
705                    Ok(EvaluatedToOk)
706                } else {
707                    Ok(EvaluatedToErr)
708                }
709            }
710
711            ty::PredicateKind::Clause(ty::ClauseKind::Projection(data)) => {
712                let data = bound_predicate.rebind(data);
713                let project_obligation = obligation.with(self.tcx(), data);
714                match project::poly_project_and_unify_term(self, &project_obligation) {
715                    ProjectAndUnifyResult::Holds(mut subobligations) => {
716                        'compute_res: {
717                            // If we've previously marked this projection as 'complete', then
718                            // use the final cached result (either `EvaluatedToOk` or
719                            // `EvaluatedToOkModuloRegions`), and skip re-evaluating the
720                            // sub-obligations.
721                            if let Some(key) = ProjectionCacheKey::from_poly_projection_obligation(
722                                self,
723                                &project_obligation,
724                            ) && let Some(cached_res) =
725                                self.infcx.inner.borrow_mut().projection_cache().is_complete(key)
726                            {
727                                break 'compute_res Ok(cached_res);
728                            }
729
730                            // Need to explicitly set the depth of nested goals here as
731                            // projection obligations can cycle by themselves and in
732                            // `evaluate_predicates_recursively` we only add the depth
733                            // for parent trait goals because only these get added to the
734                            // `TraitObligationStackList`.
735                            for subobligation in subobligations.iter_mut() {
736                                subobligation.set_depth_from_parent(obligation.recursion_depth);
737                            }
738                            let res = self
739                                .evaluate_predicates_recursively(previous_stack, subobligations);
740                            if let Ok(eval_rslt) = res
741                                && (eval_rslt == EvaluatedToOk
742                                    || eval_rslt == EvaluatedToOkModuloRegions)
743                                && let Some(key) =
744                                    ProjectionCacheKey::from_poly_projection_obligation(
745                                        self,
746                                        &project_obligation,
747                                    )
748                            {
749                                // If the result is something that we can cache, then mark this
750                                // entry as 'complete'. This will allow us to skip evaluating the
751                                // subobligations at all the next time we evaluate the projection
752                                // predicate.
753                                self.infcx
754                                    .inner
755                                    .borrow_mut()
756                                    .projection_cache()
757                                    .complete(key, eval_rslt);
758                            }
759                            res
760                        }
761                    }
762                    ProjectAndUnifyResult::FailedNormalization => Ok(EvaluatedToAmbig),
763                    ProjectAndUnifyResult::Recursive => Ok(EvaluatedToAmbigStackDependent),
764                    ProjectAndUnifyResult::MismatchedProjectionTypes(_) => Ok(EvaluatedToErr),
765                }
766            }
767
768            ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
769                if may_use_unstable_feature(self.infcx, obligation.param_env, symbol) {
770                    Ok(EvaluatedToOk)
771                } else {
772                    Ok(EvaluatedToAmbig)
773                }
774            }
775
776            ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(alias_const)) => {
777                match const_evaluatable::is_const_evaluatable(
778                    self.infcx,
779                    alias_const,
780                    obligation.param_env,
781                    obligation.cause.span,
782                ) {
783                    Ok(()) => Ok(EvaluatedToOk),
784                    Err(NotConstEvaluatable::MentionsInfer) => Ok(EvaluatedToAmbig),
785                    Err(NotConstEvaluatable::MentionsParam) => Ok(EvaluatedToErr),
786                    Err(_) => Ok(EvaluatedToErr),
787                }
788            }
789
790            ty::PredicateKind::ConstEquate(c1, c2) => {
791                let tcx = self.tcx();
792                assert!(
793                    tcx.features().generic_const_exprs(),
794                    "`ConstEquate` without a feature gate: {c1:?} {c2:?}",
795                );
796
797                {
798                    let c1 = tcx.expand_abstract_consts(c1);
799                    let c2 = tcx.expand_abstract_consts(c2);
800                    debug!(
801                        "evaluate_predicate_recursively: equating consts:\nc1= {:?}\nc2= {:?}",
802                        c1, c2
803                    );
804
805                    match (c1.kind(), c2.kind()) {
806                        (ty::ConstKind::Alias(_, a), ty::ConstKind::Alias(_, b))
807                            if a.kind == b.kind
808                                && matches!(
809                                    a.kind,
810                                    ty::AliasConstKind::Projection { .. }
811                                        | ty::AliasConstKind::InherentSelf { .. }
812                                        | ty::AliasConstKind::InherentImpl { .. }
813                                ) =>
814                        {
815                            if let Ok(InferOk { obligations, value: () }) = self
816                                .infcx
817                                .at(&obligation.cause, obligation.param_env)
818                                // Can define opaque types as this is only reachable with
819                                // `generic_const_exprs`
820                                .eq(
821                                    DefineOpaqueTypes::Yes,
822                                    ty::AliasTerm::from(a),
823                                    ty::AliasTerm::from(b),
824                                )
825                            {
826                                return self
827                                    .evaluate_predicates_recursively(previous_stack, obligations);
828                            }
829                        }
830                        (_, ty::ConstKind::Alias(_, _)) | (ty::ConstKind::Alias(_, _), _) => (),
831                        (_, _) => {
832                            if let Ok(InferOk { obligations, value: () }) = self
833                                .infcx
834                                .at(&obligation.cause, obligation.param_env)
835                                // Can define opaque types as this is only reachable with
836                                // `generic_const_exprs`
837                                .eq(DefineOpaqueTypes::Yes, c1, c2)
838                            {
839                                return self
840                                    .evaluate_predicates_recursively(previous_stack, obligations);
841                            }
842                        }
843                    }
844                }
845
846                let evaluate = |c: ty::Const<'tcx>| {
847                    if let ty::ConstKind::Alias(_, _) = c.kind() {
848                        crate::traits::try_evaluate_const(
849                            self.infcx,
850                            c,
851                            obligation.param_env,
852                            |v| Ok::<_, !>(v.skip_norm_wip()),
853                        )
854                    } else {
855                        Ok(c)
856                    }
857                };
858
859                match (evaluate(c1), evaluate(c2)) {
860                    (Ok(c1), Ok(c2)) => {
861                        match self.infcx.at(&obligation.cause, obligation.param_env).eq(
862                            // Can define opaque types as this is only reachable with
863                            // `generic_const_exprs`
864                            DefineOpaqueTypes::Yes,
865                            c1,
866                            c2,
867                        ) {
868                            Ok(inf_ok) => self.evaluate_predicates_recursively(
869                                previous_stack,
870                                inf_ok.into_obligations(),
871                            ),
872                            Err(_) => Ok(EvaluatedToErr),
873                        }
874                    }
875                    (Err(EvaluateConstErr::InvalidConstParamTy(..)), _)
876                    | (_, Err(EvaluateConstErr::InvalidConstParamTy(..))) => Ok(EvaluatedToErr),
877                    (Err(EvaluateConstErr::EvaluationFailure(..)), _)
878                    | (_, Err(EvaluateConstErr::EvaluationFailure(..))) => Ok(EvaluatedToErr),
879                    (Err(EvaluateConstErr::HasGenericsOrInfers), _)
880                    | (_, Err(EvaluateConstErr::HasGenericsOrInfers)) => {
881                        if c1.has_non_region_infer() || c2.has_non_region_infer() {
882                            Ok(EvaluatedToAmbig)
883                        } else {
884                            // Two different constants using generic parameters ~> error.
885                            Ok(EvaluatedToErr)
886                        }
887                    }
888                }
889            }
890            ty::PredicateKind::NormalizesTo(..) => {
891                bug!("NormalizesTo is only used by the new solver")
892            }
893            ty::PredicateKind::Ambiguous => Ok(EvaluatedToAmbig),
894            ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
895                let ct = self.infcx.shallow_resolve_const(ct);
896                let ct_ty = match ct.kind() {
897                    ty::ConstKind::Infer(_) => {
898                        return Ok(EvaluatedToAmbig);
899                    }
900                    ty::ConstKind::Error(_) => return Ok(EvaluatedToOk),
901                    ty::ConstKind::Value(cv) => cv.ty,
902                    ty::ConstKind::Alias(_, alias_const) => {
903                        alias_const.type_of(self.tcx()).skip_norm_wip()
904                    }
905                    // FIXME(generic_const_exprs): See comment in `fulfill.rs`
906                    ty::ConstKind::Expr(_) => return Ok(EvaluatedToOk),
907                    ty::ConstKind::Placeholder(_) => {
908                        bug!("placeholder const {:?} in old solver", ct)
909                    }
910                    ty::ConstKind::Bound(_, _) => bug!("escaping bound vars in {:?}", ct),
911                    ty::ConstKind::Param(param_ct) => {
912                        param_ct.find_const_ty_from_env(obligation.param_env)
913                    }
914                };
915
916                match self.infcx.at(&obligation.cause, obligation.param_env).eq(
917                    // Only really exercised by generic_const_exprs
918                    DefineOpaqueTypes::Yes,
919                    ct_ty,
920                    ty,
921                ) {
922                    Ok(inf_ok) => self
923                        .evaluate_predicates_recursively(previous_stack, inf_ok.into_obligations()),
924                    Err(_) => Ok(EvaluatedToErr),
925                }
926            }
927            ty::PredicateKind::Clause(ty::ClauseKind::CompressedTrait(_)) => unreachable!(),
928        }
929    }
930
931    {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(931u32),
                                ::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 true {
                            if !!self.typing_mode().is_coherence() {
                                {
                                    ::core::panicking::panic_fmt(format_args!("old solver coherence"));
                                }
                            };
                        };
                        if obligation.is_global() &&
                                obligation.param_env.caller_bounds().all_clauses(self.tcx()).iter().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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:949",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(949u32),
                                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:957",
                                                "rustc_trait_selection::traits::select",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(957u32),
                                                ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:962",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(962u32),
                                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:967",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(967u32),
                                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1034",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(1034u32),
                                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1042",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(1042u32),
                                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1046",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(1046u32),
                                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1047",
                                                    "rustc_trait_selection::traits::select",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(1047u32),
                                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:931",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(931u32),
                        ::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)]
932    fn evaluate_trait_predicate_recursively<'o>(
933        &mut self,
934        previous_stack: TraitObligationStackList<'o, 'tcx>,
935        mut obligation: PolyTraitObligation<'tcx>,
936    ) -> Result<EvaluationResult, OverflowError> {
937        debug_assert!(!self.typing_mode().is_coherence(), "old solver coherence");
938        if obligation.is_global()
939            && obligation
940                .param_env
941                .caller_bounds()
942                .all_clauses(self.tcx())
943                .iter()
944                .all(|bound| bound.has_param())
945        {
946            // If a param env has no global bounds, global obligations do not
947            // depend on its particular value in order to work, so we can clear
948            // out the param env and get better caching.
949            debug!("in global");
950            obligation.param_env = ty::ParamEnv::empty();
951        }
952
953        let stack = self.push_stack(previous_stack, &obligation);
954        let fresh_trait_pred = stack.fresh_trait_pred;
955        let param_env = obligation.param_env;
956
957        debug!(?fresh_trait_pred);
958
959        // If a trait predicate is in the (local or global) evaluation cache,
960        // then we know it holds without cycles.
961        if let Some(result) = self.check_evaluation_cache(param_env, fresh_trait_pred) {
962            debug!("CACHE HIT");
963            return Ok(result);
964        }
965
966        if let Some(result) = stack.cache().get_provisional(fresh_trait_pred) {
967            debug!("PROVISIONAL CACHE HIT");
968            stack.update_reached_depth(result.reached_depth);
969            return Ok(result.result);
970        }
971
972        // Check if this is a match for something already on the
973        // stack. If so, we don't want to insert the result into the
974        // main cache (it is cycle dependent) nor the provisional
975        // cache (which is meant for things that have completed but
976        // for a "backedge" -- this result *is* the backedge).
977        if let Some(cycle_result) = self.check_evaluation_cycle(&stack) {
978            return Ok(cycle_result);
979        }
980
981        let (result, dep_node) = self.in_task(|this| {
982            let mut result = this.evaluate_stack(&stack)?;
983
984            // fix issue #103563, we don't normalize
985            // nested obligations which produced by `TraitDef` candidate
986            // (i.e. using bounds on assoc items as assumptions).
987            // because we don't have enough information to
988            // normalize these obligations before evaluating.
989            // so we will try to normalize the obligation and evaluate again.
990            // we will replace it with new solver in the future.
991            if EvaluationResult::EvaluatedToErr == result
992                && fresh_trait_pred.has_aliases()
993                && fresh_trait_pred.is_global()
994            {
995                let mut nested_obligations = PredicateObligations::new();
996                let predicate = normalize_with_depth_to(
997                    this,
998                    param_env,
999                    obligation.cause.clone(),
1000                    obligation.recursion_depth + 1,
1001                    Unnormalized::new_wip(obligation.predicate),
1002                    &mut nested_obligations,
1003                );
1004                if predicate != obligation.predicate {
1005                    let mut nested_result = EvaluationResult::EvaluatedToOk;
1006                    for obligation in nested_obligations {
1007                        nested_result = cmp::max(
1008                            this.evaluate_predicate_recursively(previous_stack, obligation)?,
1009                            nested_result,
1010                        );
1011                    }
1012
1013                    if nested_result.must_apply_modulo_regions() {
1014                        let obligation = obligation.with(this.tcx(), predicate);
1015                        result = cmp::max(
1016                            nested_result,
1017                            this.evaluate_trait_predicate_recursively(previous_stack, obligation)?,
1018                        );
1019                    }
1020                }
1021            }
1022
1023            Ok::<_, OverflowError>(result)
1024        });
1025
1026        let result = result?;
1027
1028        if !result.must_apply_modulo_regions() {
1029            stack.cache().on_failure(stack.dfn);
1030        }
1031
1032        let reached_depth = stack.reached_depth.get();
1033        if reached_depth >= stack.depth {
1034            debug!("CACHE MISS");
1035            self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
1036            stack.cache().on_completion(stack.dfn);
1037        } else if let Some(_guar) = self.infcx.tainted_by_errors() {
1038            // When an error has occurred, we allow global caching of results even if they
1039            // appear stack-dependent. This prevents exponential re-evaluation of cycles
1040            // in the presence of errors, avoiding compiler hangs like #150907.
1041            // This is safe because compilation will fail anyway.
1042            debug!("CACHE MISS (tainted by errors)");
1043            self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
1044            stack.cache().on_completion(stack.dfn);
1045        } else {
1046            debug!("PROVISIONAL");
1047            debug!(
1048                "caching provisionally because {:?} \
1049                 is a cycle participant (at depth {}, reached depth {})",
1050                fresh_trait_pred, stack.depth, reached_depth,
1051            );
1052
1053            stack.cache().insert_provisional(stack.dfn, reached_depth, fresh_trait_pred, result);
1054        }
1055
1056        Ok(result)
1057    }
1058
1059    /// If there is any previous entry on the stack that precisely
1060    /// matches this obligation, then we can assume that the
1061    /// obligation is satisfied for now (still all other conditions
1062    /// must be met of course). One obvious case this comes up is
1063    /// marker traits like `Send`. Think of a linked list:
1064    ///
1065    ///     struct List<T> { data: T, next: Option<Box<List<T>>> }
1066    ///
1067    /// `Box<List<T>>` will be `Send` if `T` is `Send` and
1068    /// `Option<Box<List<T>>>` is `Send`, and in turn
1069    /// `Option<Box<List<T>>>` is `Send` if `Box<List<T>>` is
1070    /// `Send`.
1071    ///
1072    /// Note that we do this comparison using the `fresh_trait_pred`
1073    /// fields. Because these have all been freshened using
1074    /// `self.freshener`, we can be sure that (a) this will not
1075    /// affect the inferencer state and (b) that if we see two
1076    /// fresh regions with the same index, they refer to the same
1077    /// unbound type variable.
1078    fn check_evaluation_cycle(
1079        &mut self,
1080        stack: &TraitObligationStack<'_, 'tcx>,
1081    ) -> Option<EvaluationResult> {
1082        if let Some(cycle_depth) = stack
1083            .iter()
1084            .skip(1) // Skip top-most frame.
1085            .find(|prev| {
1086                stack.obligation.param_env == prev.obligation.param_env
1087                    && stack.fresh_trait_pred == prev.fresh_trait_pred
1088            })
1089            .map(|stack| stack.depth)
1090        {
1091            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1091",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1091u32),
                        ::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);
1092
1093            // If we have a stack like `A B C D E A`, where the top of
1094            // the stack is the final `A`, then this will iterate over
1095            // `A, E, D, C, B` -- i.e., all the participants apart
1096            // from the cycle head. We mark them as participating in a
1097            // cycle. This suppresses caching for those nodes. See
1098            // `in_cycle` field for more details.
1099            stack.update_reached_depth(cycle_depth);
1100
1101            // Subtle: when checking for a coinductive cycle, we do
1102            // not compare using the "freshened trait refs" (which
1103            // have erased regions) but rather the fully explicit
1104            // trait refs. This is important because it's only a cycle
1105            // if the regions match exactly.
1106            let cycle = stack.iter().skip(1).take_while(|s| s.depth >= cycle_depth);
1107            let tcx = self.tcx();
1108            let cycle = cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
1109            if self.coinductive_match(cycle) {
1110                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1110",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1110u32),
                        ::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");
1111                Some(EvaluatedToOk)
1112            } else {
1113                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1113",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1113u32),
                        ::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");
1114                Some(EvaluatedToAmbigStackDependent)
1115            }
1116        } else {
1117            None
1118        }
1119    }
1120
1121    fn evaluate_stack<'o>(
1122        &mut self,
1123        stack: &TraitObligationStack<'o, 'tcx>,
1124    ) -> Result<EvaluationResult, OverflowError> {
1125        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());
1126        // In intercrate mode, whenever any of the generics are unbound,
1127        // there can always be an impl. Even if there are no impls in
1128        // this crate, perhaps the type would be unified with
1129        // something from another crate that does provide an impl.
1130        //
1131        // In intra mode, we must still be conservative. The reason is
1132        // that we want to avoid cycles. Imagine an impl like:
1133        //
1134        //     impl<T:Eq> Eq for Vec<T>
1135        //
1136        // and a trait reference like `$0 : Eq` where `$0` is an
1137        // unbound variable. When we evaluate this trait-reference, we
1138        // will unify `$0` with `Vec<$1>` (for some fresh variable
1139        // `$1`), on the condition that `$1 : Eq`. We will then wind
1140        // up with many candidates (since that are other `Eq` impls
1141        // that apply) and try to winnow things down. This results in
1142        // a recursive evaluation that `$1 : Eq` -- as you can
1143        // imagine, this is just where we started. To avoid that, we
1144        // check for unbound variables and return an ambiguous (hence possible)
1145        // match if we've seen this trait before.
1146        //
1147        // This suffices to allow chains like `FnMut` implemented in
1148        // terms of `Fn` etc, but we could probably make this more
1149        // precise still.
1150        //
1151        // FIXME(gca_min_const_items): Consider consts as well?
1152        let unbound_input_types =
1153            stack.fresh_trait_pred.skip_binder().trait_ref.args.types().any(|ty| ty.is_fresh());
1154
1155        if unbound_input_types
1156            && stack.iter().skip(1).any(|prev| {
1157                stack.obligation.param_env == prev.obligation.param_env
1158                    && self.match_fresh_trait_preds(stack.fresh_trait_pred, prev.fresh_trait_pred)
1159            })
1160        {
1161            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1161",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1161u32),
                        ::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");
1162            return Ok(EvaluatedToAmbigStackDependent);
1163        }
1164
1165        match self.candidate_from_obligation(stack) {
1166            Ok(Some(c)) => self.evaluate_candidate(stack, &c),
1167            Ok(None) => Ok(EvaluatedToAmbig),
1168            Err(SelectionError::Overflow(OverflowError::Canonical)) => {
1169                Err(OverflowError::Canonical)
1170            }
1171            Err(..) => Ok(EvaluatedToErr),
1172        }
1173    }
1174
1175    /// For defaulted traits, we use a co-inductive strategy to solve, so
1176    /// that recursion is ok. This routine returns `true` if the top of the
1177    /// stack (`cycle[0]`):
1178    ///
1179    /// - is a coinductive trait: an auto-trait or `Sized`,
1180    /// - it also appears in the backtrace at some position `X`,
1181    /// - all the predicates at positions `X..` between `X` and the top are
1182    ///   also coinductive traits.
1183    pub(crate) fn coinductive_match<I>(&mut self, mut cycle: I) -> bool
1184    where
1185        I: Iterator<Item = ty::Predicate<'tcx>>,
1186    {
1187        cycle.all(|p| match p.kind().skip_binder() {
1188            ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
1189                self.infcx.tcx.trait_is_coinductive(data.def_id())
1190            }
1191            ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => {
1192                // FIXME(generic_const_exprs): GCE needs well-formedness predicates to be
1193                // coinductive, but GCE is on the way out anyways, so this should eventually
1194                // be replaced with `false`.
1195                self.infcx.tcx.features().generic_const_exprs()
1196            }
1197            _ => false,
1198        })
1199    }
1200
1201    /// Further evaluates `candidate` to decide whether all type parameters match and whether nested
1202    /// obligations are met. Returns whether `candidate` remains viable after this further
1203    /// scrutiny.
1204    {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1204u32),
                                ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1218",
                                                                            "rustc_trait_selection::traits::select",
                                                                            ::tracing::Level::DEBUG,
                                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                                            ::tracing_core::__macro_support::Option::Some(1218u32),
                                                                            ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1204",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1204u32),
                        ::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(
1205        level = "debug",
1206        skip(self, stack),
1207        fields(depth = stack.obligation.recursion_depth),
1208        ret
1209    )]
1210    fn evaluate_candidate<'o>(
1211        &mut self,
1212        stack: &TraitObligationStack<'o, 'tcx>,
1213        candidate: &SelectionCandidate<'tcx>,
1214    ) -> Result<EvaluationResult, OverflowError> {
1215        let mut result = self.evaluation_probe(|this| {
1216            match this.confirm_candidate(stack.obligation, candidate.clone()) {
1217                Ok(selection) => {
1218                    debug!(?selection);
1219                    if let ImplSource::Builtin(..) = selection
1220                        && this.typing_mode().is_reflection()
1221                    {
1222                        return Ok(EvaluatedToErr);
1223                    }
1224                    this.evaluate_predicates_recursively(
1225                        stack.list(),
1226                        selection.nested_obligations().into_iter(),
1227                    )
1228                }
1229                Err(..) => Ok(EvaluatedToErr),
1230            }
1231        })?;
1232
1233        // If we erased any lifetimes, then we want to use
1234        // `EvaluatedToOkModuloRegions` instead of `EvaluatedToOk`
1235        // as your final result. The result will be cached using
1236        // the freshened trait predicate as a key, so we need
1237        // our result to be correct by *any* choice of original lifetimes,
1238        // not just the lifetime choice for this particular (non-erased)
1239        // predicate.
1240        // See issue #80691
1241        if stack.fresh_trait_pred.has_erased_regions() {
1242            result = result.max(EvaluatedToOkModuloRegions);
1243        }
1244
1245        Ok(result)
1246    }
1247
1248    fn check_evaluation_cache(
1249        &self,
1250        param_env: ty::ParamEnv<'tcx>,
1251        trait_pred: ty::PolyTraitClause<'tcx>,
1252    ) -> Option<EvaluationResult> {
1253        let infcx = self.infcx;
1254        let tcx = infcx.tcx;
1255        if self.can_use_global_caches(param_env, trait_pred) {
1256            let key = (infcx.typing_env(param_env), trait_pred);
1257            if let Some(res) = tcx.caches.evaluation_cache.get(&key, tcx) {
1258                Some(res)
1259            } else {
1260                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);
1261                None
1262            }
1263        } else {
1264            self.infcx.evaluation_cache.get(&(param_env, trait_pred), tcx)
1265        }
1266    }
1267
1268    fn insert_evaluation_cache(
1269        &mut self,
1270        param_env: ty::ParamEnv<'tcx>,
1271        trait_pred: ty::PolyTraitClause<'tcx>,
1272        dep_node: DepNodeIndex,
1273        result: EvaluationResult,
1274    ) {
1275        // Avoid caching results that depend on more than just the trait-ref
1276        // - the stack can create recursion.
1277        if result.is_stack_dependent() {
1278            return;
1279        }
1280
1281        let infcx = self.infcx;
1282        let tcx = infcx.tcx;
1283        if self.can_use_global_caches(param_env, trait_pred) {
1284            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1284",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1284u32),
                        ::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");
1285            // This may overwrite the cache with the same value
1286            tcx.caches.evaluation_cache.insert(
1287                (infcx.typing_env(param_env), trait_pred),
1288                dep_node,
1289                result,
1290            );
1291            return;
1292        } else {
1293            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1293",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1293u32),
                        ::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");
1294            self.infcx.evaluation_cache.insert((param_env, trait_pred), dep_node, result);
1295        }
1296    }
1297
1298    fn check_recursion_depth<T>(
1299        &self,
1300        depth: usize,
1301        error_obligation: &Obligation<'tcx, T>,
1302    ) -> Result<(), OverflowError>
1303    where
1304        T: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + Clone,
1305    {
1306        if !self.infcx.tcx.recursion_limit().value_within_limit(depth) {
1307            match self.query_mode {
1308                TraitQueryMode::Standard => {
1309                    if let Some(e) = self.infcx.tainted_by_errors() {
1310                        return Err(OverflowError::Error(e));
1311                    }
1312                    self.infcx.err_ctxt().report_overflow_obligation(error_obligation, true);
1313                }
1314                TraitQueryMode::Canonical => {
1315                    return Err(OverflowError::Canonical);
1316                }
1317            }
1318        }
1319        Ok(())
1320    }
1321
1322    /// Checks that the recursion limit has not been exceeded.
1323    ///
1324    /// The weird return type of this function allows it to be used with the `try` (`?`)
1325    /// operator within certain functions.
1326    #[inline(always)]
1327    fn check_recursion_limit<T: Display + TypeFoldable<TyCtxt<'tcx>>, V>(
1328        &self,
1329        obligation: &Obligation<'tcx, T>,
1330        error_obligation: &Obligation<'tcx, V>,
1331    ) -> Result<(), OverflowError>
1332    where
1333        V: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + Clone,
1334    {
1335        self.check_recursion_depth(obligation.recursion_depth, error_obligation)
1336    }
1337
1338    fn in_task<OP, R>(&mut self, op: OP) -> (R, DepNodeIndex)
1339    where
1340        OP: FnOnce(&mut Self) -> R,
1341    {
1342        self.tcx().dep_graph.with_anon_task(self.tcx(), DepKind::TraitSelect, || op(self))
1343    }
1344
1345    /// filter_impls filters candidates that have a positive impl for a negative
1346    /// goal and a negative impl for a positive goal
1347    {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1347u32),
                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1353",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1353u32),
                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1370",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1370u32),
                                    ::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))]
1348    fn filter_impls(
1349        &mut self,
1350        mut candidates: Vec<SelectionCandidate<'tcx>>,
1351        obligation: &PolyTraitObligation<'tcx>,
1352    ) -> Vec<SelectionCandidate<'tcx>> {
1353        trace!("{candidates:#?}");
1354        let tcx = self.tcx();
1355
1356        candidates.retain(|candidate| {
1357            if let &ImplCandidate(def_id) = candidate {
1358                match (tcx.impl_polarity(def_id), obligation.polarity()) {
1359                    (ty::ImplPolarity::Positive, ty::ClausePolarity::Positive)
1360                    | (ty::ImplPolarity::Negative, ty::ClausePolarity::Negative) => true,
1361
1362                    // remove impl candidates with mismatched polarity to the obligation
1363                    _ => false,
1364                }
1365            } else {
1366                true
1367            }
1368        });
1369
1370        trace!("{candidates:#?}");
1371        candidates
1372    }
1373
1374    /// Returns `true` if the global caches can be used.
1375    fn can_use_global_caches(
1376        &self,
1377        param_env: ty::ParamEnv<'tcx>,
1378        pred: ty::PolyTraitClause<'tcx>,
1379    ) -> bool {
1380        // If there are any inference variables in the `ParamEnv`, then we
1381        // always use a cache local to this particular scope. Otherwise, we
1382        // switch to a global cache.
1383        if param_env.has_infer() || pred.has_infer() {
1384            return false;
1385        }
1386
1387        match self.typing_mode() {
1388            // Avoid using the global cache when we're defining opaque types
1389            // as their hidden type may impact the result of candidate selection.
1390            //
1391            // HACK: This is still theoretically unsound. Goals can indirectly rely
1392            // on opaques in the defining scope, and it's easier to do so with TAIT.
1393            // However, if we disqualify *all* goals from being cached, perf suffers.
1394            // This is likely fixed by better caching in general in the new solver.
1395            // See: <https://github.com/rust-lang/rust/issues/132064>.
1396            TypingMode::Typeck { defining_opaque_types_and_generators: defining_opaque_types }
1397            | TypingMode::PostTypeckThroughBorrowck { defining_opaque_types } => {
1398                defining_opaque_types.is_empty()
1399                    || (!pred.has_opaque_types() && !pred.has_coroutines())
1400            }
1401            // Impls that are not fully generic are completely ignored as "nonexistent"
1402            // in this mode, so the results wildly differ from normal trait solving.
1403            TypingMode::Reflection => false,
1404            // The hidden types of `defined_opaque_types` is not local to the current
1405            // inference context, so we can freely move this to the global cache.
1406            TypingMode::PostBorrowck { .. } => true,
1407            // The global cache is only used if there are no opaque types in
1408            // the defining scope or we're outside of analysis.
1409            //
1410            // FIXME(#132279): This is still incorrect as we treat opaque types
1411            // and default associated items differently between these two modes.
1412            TypingMode::PostAnalysis | TypingMode::Codegen => true,
1413            TypingMode::Coherence => {
1414                {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("old solver coherence")));
}unreachable!("old solver coherence")
1415            }
1416        }
1417    }
1418
1419    fn check_candidate_cache(
1420        &mut self,
1421        param_env: ty::ParamEnv<'tcx>,
1422        cache_fresh_trait_pred: ty::PolyTraitClause<'tcx>,
1423    ) -> Option<SelectionResult<'tcx, SelectionCandidate<'tcx>>> {
1424        let infcx = self.infcx;
1425        let tcx = infcx.tcx;
1426        let pred = cache_fresh_trait_pred.skip_binder();
1427
1428        if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
1429            if let Some(res) =
1430                tcx.caches.selection_cache.get(&(infcx.typing_env(param_env), pred), tcx)
1431            {
1432                return Some(res);
1433            } else if truecfg!(debug_assertions) {
1434                match infcx.selection_cache.get(&(param_env, pred), tcx) {
1435                    None | Some(Err(SelectionError::Overflow(OverflowError::Canonical))) => {}
1436                    res => ::rustc_span::macros::bug_impl(None,
    format_args!("unexpected local cache result: {0:?}", res),
    Location::caller())bug!("unexpected local cache result: {res:?}"),
1437                }
1438            }
1439        }
1440
1441        // Subtle: we need to check the local cache even if we're able to use the
1442        // global cache as we don't cache overflow in the global cache but need to
1443        // cache it as otherwise rustdoc hangs when compiling diesel.
1444        infcx.selection_cache.get(&(param_env, pred), tcx)
1445    }
1446
1447    /// Determines whether can we safely cache the result
1448    /// of selecting an obligation. This is almost always `true`,
1449    /// except when dealing with certain `ParamCandidate`s.
1450    ///
1451    /// Ordinarily, a `ParamCandidate` will contain no inference variables,
1452    /// since it was usually produced directly from a `DefId`. However,
1453    /// certain cases (currently only librustdoc's blanket impl finder),
1454    /// a `ParamEnv` may be explicitly constructed with inference types.
1455    /// When this is the case, we do *not* want to cache the resulting selection
1456    /// candidate. This is due to the fact that it might not always be possible
1457    /// to equate the obligation's trait ref and the candidate's trait ref,
1458    /// if more constraints end up getting added to an inference variable.
1459    ///
1460    /// Because of this, we always want to re-run the full selection
1461    /// process for our obligation the next time we see it, since
1462    /// we might end up picking a different `SelectionCandidate` (or none at all).
1463    fn can_cache_candidate(
1464        &self,
1465        result: &SelectionResult<'tcx, SelectionCandidate<'tcx>>,
1466    ) -> bool {
1467        match result {
1468            Ok(Some(SelectionCandidate::ParamCandidate(trait_ref))) => !trait_ref.has_infer(),
1469            _ => true,
1470        }
1471    }
1472
1473    {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1473u32),
                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1486",
                                        "rustc_trait_selection::traits::select",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                        ::tracing_core::__macro_support::Option::Some(1486u32),
                                        ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1494",
                                            "rustc_trait_selection::traits::select",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                            ::tracing_core::__macro_support::Option::Some(1494u32),
                                            ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1507",
                                    "rustc_trait_selection::traits::select",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1507u32),
                                    ::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")]
1474    fn insert_candidate_cache(
1475        &mut self,
1476        param_env: ty::ParamEnv<'tcx>,
1477        cache_fresh_trait_pred: ty::PolyTraitClause<'tcx>,
1478        dep_node: DepNodeIndex,
1479        candidate: SelectionResult<'tcx, SelectionCandidate<'tcx>>,
1480    ) {
1481        let infcx = self.infcx;
1482        let tcx = infcx.tcx;
1483        let pred = cache_fresh_trait_pred.skip_binder();
1484
1485        if !self.can_cache_candidate(&candidate) {
1486            debug!(?pred, ?candidate, "insert_candidate_cache - candidate is not cacheable");
1487            return;
1488        }
1489
1490        if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
1491            if let Err(SelectionError::Overflow(OverflowError::Canonical)) = candidate {
1492                // Don't cache overflow globally; we only produce this in certain modes.
1493            } else {
1494                debug!(?pred, ?candidate, "insert_candidate_cache global");
1495                debug_assert!(!candidate.has_infer());
1496
1497                // This may overwrite the cache with the same value.
1498                tcx.caches.selection_cache.insert(
1499                    (infcx.typing_env(param_env), pred),
1500                    dep_node,
1501                    candidate,
1502                );
1503                return;
1504            }
1505        }
1506
1507        debug!(?pred, ?candidate, "insert_candidate_cache local");
1508        self.infcx.selection_cache.insert((param_env, pred), dep_node, candidate);
1509    }
1510
1511    /// Looks at the item bounds of the projection or opaque type.
1512    /// If this is a nested rigid projection, such as
1513    /// `<<T as Tr1>::Assoc as Tr2>::Assoc`, consider the item bounds
1514    /// on both `Tr1::Assoc` and `Tr2::Assoc`, since we may encounter
1515    /// relative bounds on both via the `associated_type_bounds` feature.
1516    pub(super) fn for_each_item_bound<T>(
1517        &mut self,
1518        mut self_ty: Ty<'tcx>,
1519        mut for_each: impl FnMut(
1520            &mut Self,
1521            ty::Clause<'tcx>,
1522            usize,
1523            AliasBoundKind,
1524        ) -> ControlFlow<T, ()>,
1525        on_ambiguity: impl FnOnce(),
1526    ) -> ControlFlow<T, ()> {
1527        let mut idx = 0;
1528        let mut alias_bound_kind = AliasBoundKind::SelfBounds;
1529
1530        loop {
1531            let (alias_ty, def_id) = match *self_ty.kind() {
1532                ty::Alias(
1533                    _,
1534                    alias_ty @ ty::AliasTy {
1535                        kind: ty::Projection { def_id } | ty::Opaque { def_id },
1536                        ..
1537                    },
1538                ) => (alias_ty, def_id),
1539                ty::Infer(ty::TyVar(_)) => {
1540                    on_ambiguity();
1541                    return ControlFlow::Continue(());
1542                }
1543                _ => return ControlFlow::Continue(()),
1544            };
1545
1546            // HACK: On subsequent recursions, we only care about bounds that don't
1547            // share the same type as `self_ty`. This is because for truly rigid
1548            // projections, we will never be able to equate, e.g. `<T as Tr>::A`
1549            // with `<<T as Tr>::A as Tr>::A`.
1550            let relevant_bounds = if alias_bound_kind == AliasBoundKind::NonSelfBounds {
1551                self.tcx().item_non_self_bounds(def_id)
1552            } else {
1553                self.tcx().item_self_bounds(def_id)
1554            };
1555
1556            for bound in relevant_bounds.instantiate(self.tcx(), alias_ty.args).skip_norm_wip() {
1557                for_each(self, bound, idx, alias_bound_kind)?;
1558                idx += 1;
1559            }
1560
1561            if #[allow(non_exhaustive_omitted_patterns)] match alias_ty.kind {
    ty::Projection { .. } => true,
    _ => false,
}matches!(alias_ty.kind, ty::Projection { .. }) {
1562                self_ty = alias_ty.self_ty();
1563            } else {
1564                return ControlFlow::Continue(());
1565            }
1566
1567            alias_bound_kind = AliasBoundKind::NonSelfBounds;
1568        }
1569    }
1570
1571    /// Equates the trait in `obligation` with trait bound. If the two traits
1572    /// can be equated and the normalized trait bound doesn't contain inference
1573    /// variables or placeholders, the normalized bound is returned.
1574    fn match_normalize_trait_ref(
1575        &mut self,
1576        obligation: &PolyTraitObligation<'tcx>,
1577        placeholder_trait_ref: ty::TraitRef<'tcx>,
1578        trait_bound: ty::PolyTraitRef<'tcx>,
1579    ) -> Result<Option<ty::TraitRef<'tcx>>, ()> {
1580        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());
1581        if placeholder_trait_ref.def_id != trait_bound.def_id() {
1582            // Avoid unnecessary normalization
1583            return Err(());
1584        }
1585
1586        let drcx = DeepRejectCtxt::relate_rigid_rigid(self.infcx.tcx);
1587        let obligation_args = obligation.predicate.skip_binder().trait_ref.args;
1588        if !drcx.args_may_unify(obligation_args, trait_bound.skip_binder().args) {
1589            return Err(());
1590        }
1591
1592        let trait_bound = self.infcx.instantiate_binder_with_fresh_vars(
1593            obligation.cause.span,
1594            HigherRankedType,
1595            trait_bound,
1596        );
1597        let Normalized { value: trait_bound, obligations: _ } = normalize_with_depth(
1598            self,
1599            obligation.param_env,
1600            obligation.cause.clone(),
1601            obligation.recursion_depth + 1,
1602            ty::Unnormalized::new_wip(trait_bound),
1603        );
1604        self.infcx
1605            .at(&obligation.cause, obligation.param_env)
1606            .eq(DefineOpaqueTypes::No, placeholder_trait_ref, trait_bound)
1607            .map(|InferOk { obligations: _, value: () }| {
1608                // This method is called within a probe, so we can't have
1609                // inference variables and placeholders escape.
1610                if !trait_bound.has_infer() && !trait_bound.has_placeholders() {
1611                    Some(trait_bound)
1612                } else {
1613                    None
1614                }
1615            })
1616            .map_err(|_| ())
1617    }
1618
1619    fn where_clause_may_apply<'o>(
1620        &mut self,
1621        stack: &TraitObligationStack<'o, 'tcx>,
1622        where_clause_trait_ref: ty::PolyTraitRef<'tcx>,
1623    ) -> Result<EvaluationResult, OverflowError> {
1624        self.evaluation_probe(|this| {
1625            match this.match_where_clause_trait_ref(stack.obligation, where_clause_trait_ref) {
1626                Ok(obligations) => this.evaluate_predicates_recursively(stack.list(), obligations),
1627                Err(()) => Ok(EvaluatedToErr),
1628            }
1629        })
1630    }
1631
1632    /// Return `Yes` if the obligation's predicate type applies to the env_predicate, and
1633    /// `No` if it does not. Return `Ambiguous` in the case that the projection type is a GAT,
1634    /// and applying this env_predicate constrains any of the obligation's GAT parameters.
1635    ///
1636    /// This behavior is a somewhat of a hack to prevent over-constraining inference variables
1637    /// in cases like #91762.
1638    pub(super) fn match_projection_projections(
1639        &mut self,
1640        obligation: &ProjectionTermObligation<'tcx>,
1641        env_predicate: PolyProjectionClause<'tcx>,
1642        potentially_unnormalized_candidates: bool,
1643    ) -> ProjectionMatchesProjection {
1644        let def_id = obligation.predicate.expect_projection_def_id();
1645        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());
1646
1647        let mut nested_obligations = PredicateObligations::new();
1648        let infer_predicate = self.infcx.instantiate_binder_with_fresh_vars(
1649            obligation.cause.span,
1650            BoundRegionConversionTime::HigherRankedType,
1651            env_predicate,
1652        );
1653        let mut infer_projection = infer_predicate.projection_term;
1654        if potentially_unnormalized_candidates {
1655            infer_projection = normalize_with_depth_to(
1656                self,
1657                obligation.param_env,
1658                obligation.cause.clone(),
1659                obligation.recursion_depth + 1,
1660                ty::Unnormalized::new_wip(infer_projection),
1661                &mut nested_obligations,
1662            )
1663        }
1664
1665        let is_match = self
1666            .infcx
1667            .at(&obligation.cause, obligation.param_env)
1668            .eq(DefineOpaqueTypes::No, obligation.predicate, infer_projection)
1669            .is_ok_and(|InferOk { obligations, value: () }| {
1670                self.evaluate_predicates_recursively(
1671                    TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
1672                    nested_obligations.into_iter().chain(obligations),
1673                )
1674                .is_ok_and(|res| res.may_apply())
1675            });
1676
1677        if is_match {
1678            let generics = self.tcx().generics_of(def_id);
1679            // FIXME(generic_associated_types): Addresses aggressive inference in #92917.
1680            // If this type is a GAT, and of the GAT args resolve to something new,
1681            // that means that we must have newly inferred something about the GAT.
1682            // We should give up in that case.
1683            //
1684            // This only detects one layer of inference, which is probably not what we actually
1685            // want, but fixing it causes some ambiguity:
1686            // <https://github.com/rust-lang/rust/issues/125196>.
1687            if !generics.is_own_empty()
1688                && obligation.predicate.args.as_slice()[generics.parent_count..].iter().any(|&p| {
1689                    p.has_non_region_infer()
1690                        && match p.kind() {
1691                            ty::GenericArgKind::Const(ct) => {
1692                                self.infcx.shallow_resolve_const(ct) != ct
1693                            }
1694                            ty::GenericArgKind::Type(ty) => self.infcx.shallow_resolve(ty) != ty,
1695                            ty::GenericArgKind::Lifetime(_) => false,
1696                        }
1697                })
1698            {
1699                ProjectionMatchesProjection::Ambiguous
1700            } else {
1701                ProjectionMatchesProjection::Yes
1702            }
1703        } else {
1704            ProjectionMatchesProjection::No
1705        }
1706    }
1707}
1708
1709/// ## Winnowing
1710///
1711/// Winnowing is the process of attempting to resolve ambiguity by
1712/// probing further. During the winnowing process, we unify all
1713/// type variables and then we also attempt to evaluate recursive
1714/// bounds to see if they are satisfied.
1715impl<'tcx> SelectionContext<'_, 'tcx> {
1716    /// If there are multiple ways to prove a trait goal, we make some
1717    /// *fairly arbitrary* choices about which candidate is actually used.
1718    ///
1719    /// For more details, look at the implementation of this method :)
1720    {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1720u32),
                                ::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::unreachable_default_msg(),
                                        }) {
                                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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1720",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1720u32),
                        ::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)]
1721    fn winnow_candidates(
1722        &mut self,
1723        has_non_region_infer: bool,
1724        candidate_preference_mode: CandidatePreferenceMode,
1725        mut candidates: Vec<EvaluatedCandidate<'tcx>>,
1726    ) -> Option<SelectionCandidate<'tcx>> {
1727        if candidates.len() == 1 {
1728            return Some(candidates.pop().unwrap().candidate);
1729        }
1730
1731        // We prefer `Sized` candidates over everything.
1732        let mut sized_candidates =
1733            candidates.iter().filter(|c| matches!(c.candidate, SizedCandidate));
1734        if let Some(sized_candidate) = sized_candidates.next() {
1735            // There should only ever be a single sized candidate
1736            // as they would otherwise overlap.
1737            debug_assert_eq!(sized_candidates.next(), None);
1738            // Only prefer the built-in `Sized` candidate if its nested goals are certain.
1739            // Otherwise, we may encounter failure later on if inference causes this candidate
1740            // to not hold, but a where clause would've applied instead.
1741            if sized_candidate.evaluation.must_apply_modulo_regions() {
1742                return Some(sized_candidate.candidate.clone());
1743            } else {
1744                return None;
1745            }
1746        }
1747
1748        // Before we consider where-bounds, we have to deduplicate them here and also
1749        // drop where-bounds in case the same where-bound exists without bound vars.
1750        // This is necessary as elaborating super-trait bounds may result in duplicates.
1751        'search_victim: loop {
1752            for (i, this) in candidates.iter().enumerate() {
1753                let ParamCandidate(this) = this.candidate else { continue };
1754                for (j, other) in candidates.iter().enumerate() {
1755                    if i == j {
1756                        continue;
1757                    }
1758
1759                    let ParamCandidate(other) = other.candidate else { continue };
1760                    if this == other {
1761                        candidates.remove(j);
1762                        continue 'search_victim;
1763                    }
1764
1765                    if this.skip_binder().trait_ref == other.skip_binder().trait_ref
1766                        && this.skip_binder().polarity == other.skip_binder().polarity
1767                        && !this.skip_binder().trait_ref.has_escaping_bound_vars()
1768                    {
1769                        candidates.remove(j);
1770                        continue 'search_victim;
1771                    }
1772                }
1773            }
1774
1775            break;
1776        }
1777
1778        let mut alias_bounds = candidates.iter().filter_map(|c| {
1779            if let ProjectionCandidate { idx, kind } = c.candidate {
1780                Some((idx, kind))
1781            } else {
1782                None
1783            }
1784        });
1785        // Extract non-nested alias bound candidates, will be preferred over where bounds if
1786        // we're proving an auto-trait, sizedness trait or default trait.
1787        if matches!(candidate_preference_mode, CandidatePreferenceMode::Marker) {
1788            match alias_bounds
1789                .clone()
1790                .filter_map(|(idx, kind)| (kind == AliasBoundKind::SelfBounds).then_some(idx))
1791                .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) })
1792            {
1793                Some(Some(idx)) => {
1794                    return Some(ProjectionCandidate { idx, kind: AliasBoundKind::SelfBounds });
1795                }
1796                Some(None) => {}
1797                None => return None,
1798            }
1799        }
1800
1801        // The next highest priority is for non-global where-bounds. However, while we don't
1802        // prefer global where-clauses here, we do bail with ambiguity when encountering both
1803        // a global and a non-global where-clause.
1804        //
1805        // Our handling of where-bounds is generally fairly messy but necessary for backwards
1806        // compatibility, see #50825 for why we need to handle global where-bounds like this.
1807        let is_global = |c: ty::PolyTraitClause<'tcx>| c.is_global() && !c.has_bound_vars();
1808        let param_candidates = candidates
1809            .iter()
1810            .filter_map(|c| if let ParamCandidate(p) = c.candidate { Some(p) } else { None });
1811        let mut has_global_bounds = false;
1812        let mut param_candidate = None;
1813        for c in param_candidates {
1814            if is_global(c) {
1815                has_global_bounds = true;
1816            } else if param_candidate.replace(c).is_some() {
1817                // Ambiguity, two potentially different where-clauses
1818                return None;
1819            }
1820        }
1821        if let Some(predicate) = param_candidate {
1822            // Ambiguity, a global and a non-global where-bound.
1823            if has_global_bounds {
1824                return None;
1825            } else {
1826                return Some(ParamCandidate(predicate));
1827            }
1828        }
1829
1830        // Prefer alias-bounds over blanket impls for rigid associated types. This is
1831        // fairly arbitrary but once again necessary for backwards compatibility.
1832        // If there are multiple applicable candidates which don't affect type inference,
1833        // choose the one with the lowest index.
1834        match alias_bounds.try_reduce(|(c1, k1), (c2, k2)| {
1835            if has_non_region_infer {
1836                None
1837            } else if c1 < c2 {
1838                Some((c1, k1))
1839            } else {
1840                Some((c2, k2))
1841            }
1842        }) {
1843            Some(Some((idx, kind))) => return Some(ProjectionCandidate { idx, kind }),
1844            Some(None) => {}
1845            None => return None,
1846        }
1847
1848        // Need to prioritize builtin trait object impls as `<dyn Any as Any>::type_id`
1849        // should use the vtable method and not the method provided by the user-defined
1850        // impl `impl<T: ?Sized> Any for T { .. }`. This really shouldn't exist but is
1851        // necessary due to #57893. We again arbitrarily prefer the applicable candidate
1852        // with the lowest index.
1853        //
1854        // We do not want to use these impls to guide inference in case a user-written impl
1855        // may also apply.
1856        let object_bound = candidates
1857            .iter()
1858            .filter_map(|c| if let ObjectCandidate(i) = c.candidate { Some(i) } else { None })
1859            .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) });
1860        match object_bound {
1861            Some(Some(index)) => {
1862                return if has_non_region_infer
1863                    && candidates.iter().any(|c| matches!(c.candidate, ImplCandidate(_)))
1864                {
1865                    None
1866                } else {
1867                    Some(ObjectCandidate(index))
1868                };
1869            }
1870            Some(None) => {}
1871            None => return None,
1872        }
1873        // Same for upcasting.
1874        let upcast_bound = candidates
1875            .iter()
1876            .filter_map(|c| {
1877                if let TraitUpcastingUnsizeCandidate(i) = c.candidate { Some(i) } else { None }
1878            })
1879            .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) });
1880        match upcast_bound {
1881            Some(Some(index)) => return Some(TraitUpcastingUnsizeCandidate(index)),
1882            Some(None) => {}
1883            None => return None,
1884        }
1885
1886        // Finally, handle overlapping user-written impls.
1887        let impls = candidates.iter().filter_map(|c| {
1888            if let ImplCandidate(def_id) = c.candidate {
1889                Some((def_id, c.evaluation))
1890            } else {
1891                None
1892            }
1893        });
1894        let mut impl_candidate = None;
1895        for c in impls {
1896            if let Some(prev) = impl_candidate.replace(c) {
1897                if self.prefer_lhs_over_victim(has_non_region_infer, c, prev.0) {
1898                    // Ok, prefer `c` over the previous entry
1899                } else if self.prefer_lhs_over_victim(has_non_region_infer, prev, c.0) {
1900                    // Ok, keep `prev` instead of the new entry
1901                    impl_candidate = Some(prev);
1902                } else {
1903                    // Ambiguity, two potentially different where-clauses
1904                    return None;
1905                }
1906            }
1907        }
1908        if let Some((def_id, _evaluation)) = impl_candidate {
1909            // Don't use impl candidates which overlap with other candidates.
1910            // This should pretty much only ever happen with malformed impls.
1911            if candidates.iter().all(|c| match c.candidate {
1912                SizedCandidate
1913                | BuiltinCandidate
1914                | TransmutabilityCandidate
1915                | AutoImplCandidate
1916                | ClosureCandidate { .. }
1917                | AsyncClosureCandidate
1918                | AsyncFnKindHelperCandidate
1919                | CoroutineCandidate
1920                | FutureCandidate
1921                | IteratorCandidate
1922                | AsyncIteratorCandidate
1923                | FnPointerCandidate
1924                | TraitAliasCandidate
1925                | TraitUpcastingUnsizeCandidate(_)
1926                | BuiltinObjectCandidate
1927                | BuiltinUnsizeCandidate
1928                | TryAsDynCandidate
1929                | BikeshedGuaranteedNoDropCandidate => false,
1930                // Non-global param candidates have already been handled, global
1931                // where-bounds get ignored.
1932                ParamCandidate(_) | ImplCandidate(_) => true,
1933                ProjectionCandidate { .. } | ObjectCandidate(_) => unreachable!(),
1934            }) {
1935                return Some(ImplCandidate(def_id));
1936            } else {
1937                return None;
1938            }
1939        }
1940
1941        if candidates.len() == 1 {
1942            Some(candidates.pop().unwrap().candidate)
1943        } else {
1944            // Also try ignoring all global where-bounds and check whether we end
1945            // with a unique candidate in this case.
1946            let mut not_a_global_where_bound = candidates
1947                .into_iter()
1948                .filter(|c| !matches!(c.candidate, ParamCandidate(p) if is_global(p)));
1949            not_a_global_where_bound
1950                .next()
1951                .map(|c| c.candidate)
1952                .filter(|_| not_a_global_where_bound.next().is_none())
1953        }
1954    }
1955
1956    fn prefer_lhs_over_victim(
1957        &self,
1958        has_non_region_infer: bool,
1959        (lhs, lhs_evaluation): (DefId, EvaluationResult),
1960        victim: DefId,
1961    ) -> bool {
1962        let tcx = self.tcx();
1963        // See if we can toss out `victim` based on specialization.
1964        //
1965        // While this requires us to know *for sure* that the `lhs` impl applies
1966        // we still use modulo regions here. This is fine as specialization currently
1967        // assumes that specializing impls have to be always applicable, meaning that
1968        // the only allowed region constraints may be constraints also present on the default impl.
1969        if lhs_evaluation.must_apply_modulo_regions() {
1970            if tcx.specializes((lhs, victim)) {
1971                return true;
1972            }
1973        }
1974
1975        match tcx.impls_are_allowed_to_overlap(lhs, victim) {
1976            // For candidates which already reference errors it doesn't really
1977            // matter what we do 🤷
1978            Some(ty::ImplOverlapKind::Permitted { marker: false }) => {
1979                lhs_evaluation.must_apply_considering_regions()
1980            }
1981            Some(ty::ImplOverlapKind::Permitted { marker: true }) => {
1982                // Subtle: If the predicate we are evaluating has inference
1983                // variables, do *not* allow discarding candidates due to
1984                // marker trait impls.
1985                //
1986                // Without this restriction, we could end up accidentally
1987                // constraining inference variables based on an arbitrarily
1988                // chosen trait impl.
1989                //
1990                // Imagine we have the following code:
1991                //
1992                // ```rust
1993                // #[marker] trait MyTrait {}
1994                // impl MyTrait for u8 {}
1995                // impl MyTrait for bool {}
1996                // ```
1997                //
1998                // And we are evaluating the predicate `<_#0t as MyTrait>`.
1999                //
2000                // During selection, we will end up with one candidate for each
2001                // impl of `MyTrait`. If we were to discard one impl in favor
2002                // of the other, we would be left with one candidate, causing
2003                // us to "successfully" select the predicate, unifying
2004                // _#0t with (for example) `u8`.
2005                //
2006                // However, we have no reason to believe that this unification
2007                // is correct - we've essentially just picked an arbitrary
2008                // *possibility* for _#0t, and required that this be the *only*
2009                // possibility.
2010                //
2011                // Eventually, we will either:
2012                // 1) Unify all inference variables in the predicate through
2013                // some other means (e.g. type-checking of a function). We will
2014                // then be in a position to drop marker trait candidates
2015                // without constraining inference variables (since there are
2016                // none left to constrain)
2017                // 2) Be left with some unconstrained inference variables. We
2018                // will then correctly report an inference error, since the
2019                // existence of multiple marker trait impls tells us nothing
2020                // about which one should actually apply.
2021                !has_non_region_infer && lhs_evaluation.must_apply_considering_regions()
2022            }
2023            None => false,
2024        }
2025    }
2026}
2027
2028impl<'tcx> SelectionContext<'_, 'tcx> {
2029    fn sizedness_conditions(
2030        &mut self,
2031        self_ty: Ty<'tcx>,
2032        sizedness: SizedTraitKind,
2033    ) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
2034        match self_ty.kind() {
2035            ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2036            | ty::Uint(_)
2037            | ty::Int(_)
2038            | ty::Bool
2039            | ty::Float(_)
2040            | ty::FnDef(..)
2041            | ty::FnPtr(..)
2042            | ty::RawPtr(..)
2043            | ty::Char
2044            | ty::Ref(..)
2045            | ty::Coroutine(..)
2046            | ty::CoroutineWitness(..)
2047            | ty::Array(..)
2048            | ty::Closure(..)
2049            | ty::CoroutineClosure(..)
2050            | ty::Never
2051            | ty::Error(_) => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2052
2053            ty::Str | ty::Slice(_) | ty::Dynamic(..) => match sizedness {
2054                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"),
2055                SizedTraitKind::MetaSized => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2056            },
2057
2058            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"),
2059
2060            ty::Tuple(tys) => {
2061                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]))
2062            }
2063
2064            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]),
2065
2066            ty::Adt(def, args) => {
2067                if let Some(crit) = def.sizedness_constraint(self.tcx(), sizedness) {
2068                    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()])
2069                } else {
2070                    ty::Binder::dummy(::alloc::vec::Vec::new()vec![])
2071                }
2072            }
2073
2074            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]),
2075
2076            ty::Alias(..)
2077            | ty::Param(_)
2078            | ty::Placeholder(..)
2079            | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_))
2080            | ty::Bound(..) => {
2081                ::rustc_span::macros::bug_impl(None,
    format_args!("asked to assemble `Sized` of unexpected type: {0:?}",
        self_ty), Location::caller());bug!("asked to assemble `Sized` of unexpected type: {:?}", self_ty);
2082            }
2083
2084            // FIXME(scrabsha)
2085            ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
2086        }
2087    }
2088
2089    fn copy_clone_conditions(&mut self, self_ty: Ty<'tcx>) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
2090        match *self_ty.kind() {
2091            ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2092
2093            ty::Uint(_)
2094            | ty::Int(_)
2095            | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2096            | ty::Bool
2097            | ty::Float(_)
2098            | ty::Char
2099            | ty::RawPtr(..)
2100            | ty::Never
2101            | ty::Ref(_, _, hir::Mutability::Not)
2102            | ty::Array(..) => {
2103                {
    ::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")
2104            }
2105
2106            // FIXME(unsafe_binder): Should we conditionally
2107            // (i.e. universally) implement copy/clone?
2108            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"),
2109
2110            ty::Tuple(tys) => {
2111                // (*) binder moved here
2112                ty::Binder::dummy(tys.iter().collect())
2113            }
2114
2115            ty::Pat(ty, _) => {
2116                // (*) binder moved here
2117                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])
2118            }
2119
2120            ty::Coroutine(def_id, args) => match self.tcx().coroutine_movability(def_id) {
2121                hir::Movability::Static => {
2122                    {
    ::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")
2123                }
2124                hir::Movability::Movable => {
2125                    if self.tcx().features().coroutine_clone() {
2126                        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![
2127                            args.as_coroutine().tupled_upvars_ty(),
2128                            Ty::new_coroutine_witness_for_coroutine(self.tcx(), def_id, args),
2129                        ])
2130                    } else {
2131                        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("tried to assemble `Clone` for coroutine without enabled feature")));
}unreachable!(
2132                            "tried to assemble `Clone` for coroutine without enabled feature"
2133                        )
2134                    }
2135                }
2136            },
2137
2138            ty::CoroutineWitness(def_id, args) => self
2139                .infcx
2140                .tcx
2141                .coroutine_hidden_types(def_id)
2142                .instantiate(self.infcx.tcx, args)
2143                .skip_norm_wip()
2144                .map_bound(|witness| witness.types.to_vec()),
2145
2146            ty::Closure(_, args) => ty::Binder::dummy(args.as_closure().upvar_tys().to_vec()),
2147
2148            ty::CoroutineClosure(_, args) => {
2149                ty::Binder::dummy(args.as_coroutine_closure().upvar_tys().to_vec())
2150            }
2151
2152            ty::Foreign(..)
2153            | ty::Str
2154            | ty::Slice(_)
2155            | ty::Dynamic(..)
2156            | ty::Adt(..)
2157            | ty::Alias(..)
2158            | ty::Param(..)
2159            | ty::Placeholder(..)
2160            | ty::Bound(..)
2161            | ty::Ref(_, _, ty::Mutability::Mut)
2162            | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2163                ::rustc_span::macros::bug_impl(None,
    format_args!("asked to assemble builtin bounds of unexpected type: {0:?}",
        self_ty), Location::caller());bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
2164            }
2165
2166            // FIXME(scrabsha)
2167            ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
2168        }
2169    }
2170
2171    fn coroutine_is_gen(&mut self, self_ty: Ty<'tcx>) -> bool {
2172        #[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, ..)
2173            if self.tcx().coroutine_is_gen(did))
2174    }
2175
2176    /// For default impls, we need to break apart a type into its
2177    /// "constituent types" -- meaning, the types that it contains.
2178    ///
2179    /// Here are some (simple) examples:
2180    ///
2181    /// ```ignore (illustrative)
2182    /// (i32, u32) -> [i32, u32]
2183    /// Foo where struct Foo { x: i32, y: u32 } -> [i32, u32]
2184    /// Bar<i32> where struct Bar<T> { x: T, y: u32 } -> [i32, u32]
2185    /// Zed<i32> where enum Zed { A(T), B(u32) } -> [i32, u32]
2186    /// ```
2187    {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(2187u32),
                                ::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_span::macros::bug_impl(None,
                                        format_args!("asked to assemble constituent types of unexpected type: {0:?}",
                                            t), Location::caller());
                                }
                                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::unreachable_default_msg()
                                    } 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(),
                                            })
                                    }
                                }
                                ty::View(..) =>
                                    ::core::panicking::unimplemented_default_msg(),
                            })
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2187",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2187u32),
                        ::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)]
2188    fn constituent_types_for_auto_trait(
2189        &self,
2190        t: Ty<'tcx>,
2191    ) -> Result<ty::Binder<'tcx, AutoImplConstituents<'tcx>>, SelectionError<'tcx>> {
2192        Ok(match *t.kind() {
2193            ty::Uint(_)
2194            | ty::Int(_)
2195            | ty::Bool
2196            | ty::Float(_)
2197            | ty::FnDef(..)
2198            | ty::FnPtr(..)
2199            | ty::Error(_)
2200            | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2201            | ty::Never
2202            | ty::Char => {
2203                ty::Binder::dummy(AutoImplConstituents { types: vec![], assumptions: vec![] })
2204            }
2205
2206            // This branch is only for `experimental_default_bounds`.
2207            // Other foreign types were rejected earlier in
2208            // `assemble_candidates_from_auto_impls`.
2209            ty::Foreign(..) => {
2210                ty::Binder::dummy(AutoImplConstituents { types: vec![], assumptions: vec![] })
2211            }
2212
2213            ty::UnsafeBinder(ty) => {
2214                ty.map_bound(|ty| AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2215            }
2216
2217            // Treat this like `struct str([u8]);`
2218            ty::Str => ty::Binder::dummy(AutoImplConstituents {
2219                types: vec![Ty::new_slice(self.tcx(), self.tcx().types.u8)],
2220                assumptions: vec![],
2221            }),
2222
2223            ty::Placeholder(..)
2224            | ty::Dynamic(..)
2225            | ty::Param(..)
2226            | ty::Alias(
2227                _,
2228                ty::AliasTy {
2229                    kind: ty::Projection { .. } | ty::Inherent { .. } | ty::Free { .. },
2230                    ..
2231                },
2232            )
2233            | ty::Bound(..)
2234            | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2235                bug!("asked to assemble constituent types of unexpected type: {:?}", t);
2236            }
2237
2238            ty::RawPtr(element_ty, _) | ty::Ref(_, element_ty, _) => {
2239                ty::Binder::dummy(AutoImplConstituents {
2240                    types: vec![element_ty],
2241                    assumptions: vec![],
2242                })
2243            }
2244
2245            ty::Pat(ty, _) | ty::Array(ty, _) | ty::Slice(ty) => {
2246                ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2247            }
2248
2249            ty::Tuple(tys) => {
2250                // (T1, ..., Tn) -- meets any bound that all of T1...Tn meet
2251                ty::Binder::dummy(AutoImplConstituents {
2252                    types: tys.iter().collect(),
2253                    assumptions: vec![],
2254                })
2255            }
2256
2257            ty::Closure(_, args) => {
2258                let ty = self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
2259                ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2260            }
2261
2262            ty::CoroutineClosure(_, args) => {
2263                let ty = self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
2264                ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2265            }
2266
2267            ty::Coroutine(def_id, args) => {
2268                let ty = self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
2269                let tcx = self.tcx();
2270                let witness = Ty::new_coroutine_witness_for_coroutine(tcx, def_id, args);
2271                ty::Binder::dummy(AutoImplConstituents {
2272                    types: vec![ty, witness],
2273                    assumptions: vec![],
2274                })
2275            }
2276
2277            ty::CoroutineWitness(def_id, args) => self
2278                .infcx
2279                .tcx
2280                .coroutine_hidden_types(def_id)
2281                .instantiate(self.infcx.tcx, args)
2282                .skip_norm_wip()
2283                .map_bound(|witness| AutoImplConstituents {
2284                    types: witness.types.to_vec(),
2285                    assumptions: witness.assumptions.to_vec(),
2286                }),
2287
2288            // For `PhantomData<T>`, we pass `T`.
2289            ty::Adt(def, args) if def.is_phantom_data() => {
2290                ty::Binder::dummy(AutoImplConstituents {
2291                    types: args.types().collect(),
2292                    assumptions: vec![],
2293                })
2294            }
2295
2296            ty::Adt(def, args) => ty::Binder::dummy(AutoImplConstituents {
2297                types: def.all_fields().map(|f| f.ty(self.tcx(), args).skip_norm_wip()).collect(),
2298                assumptions: vec![],
2299            }),
2300
2301            ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) => {
2302                if self.infcx.can_define_opaque_ty(def_id) {
2303                    unreachable!()
2304                } else {
2305                    // We can resolve the opaque type to its hidden type,
2306                    // which enforces a DAG between the functions requiring
2307                    // the auto trait bounds in question.
2308                    let ty = self.tcx().type_of_opaque(def_id);
2309                    ty::Binder::dummy(AutoImplConstituents {
2310                        types: vec![ty.instantiate(self.tcx(), args).skip_norm_wip()],
2311                        assumptions: vec![],
2312                    })
2313                }
2314            }
2315
2316            // FIXME(scrabsha)
2317            ty::View(..) => unimplemented!(),
2318        })
2319    }
2320
2321    fn collect_predicates_for_types(
2322        &mut self,
2323        param_env: ty::ParamEnv<'tcx>,
2324        cause: ObligationCause<'tcx>,
2325        recursion_depth: usize,
2326        trait_def_id: DefId,
2327        types: Vec<Ty<'tcx>>,
2328    ) -> PredicateObligations<'tcx> {
2329        // Because the types were potentially derived from
2330        // higher-ranked obligations they may reference late-bound
2331        // regions. For example, `for<'a> Foo<&'a i32> : Copy` would
2332        // yield a type like `for<'a> &'a i32`. In general, we
2333        // maintain the invariant that we never manipulate bound
2334        // regions, so we have to process these bound regions somehow.
2335        //
2336        // The strategy is to:
2337        //
2338        // 1. Instantiate those regions to placeholder regions (e.g.,
2339        //    `for<'a> &'a i32` becomes `&0 i32`.
2340        // 2. Produce something like `&'0 i32 : Copy`
2341        // 3. Re-bind the regions back to `for<'a> &'a i32 : Copy`
2342
2343        types
2344            .into_iter()
2345            .flat_map(|placeholder_ty| {
2346                let Normalized { value: normalized_ty, mut obligations } = normalize_with_depth(
2347                    self,
2348                    param_env,
2349                    cause.clone(),
2350                    recursion_depth,
2351                    Unnormalized::new_wip(placeholder_ty),
2352                );
2353
2354                let tcx = self.tcx();
2355                let trait_ref = if tcx.generics_of(trait_def_id).own_params.len() == 1 {
2356                    ty::TraitRef::new(tcx, trait_def_id, [normalized_ty])
2357                } else {
2358                    // If this is an ill-formed auto/built-in trait, then synthesize
2359                    // new error args for the missing generics.
2360                    let err_args = ty::GenericArgs::extend_with_error(
2361                        tcx,
2362                        trait_def_id,
2363                        &[normalized_ty.into()],
2364                    );
2365                    ty::TraitRef::new_from_args(tcx, trait_def_id, err_args)
2366                };
2367
2368                let obligation = Obligation::new(self.tcx(), cause.clone(), param_env, trait_ref);
2369                obligations.push(obligation);
2370                obligations
2371            })
2372            .collect()
2373    }
2374
2375    ///////////////////////////////////////////////////////////////////////////
2376    // Matching
2377    //
2378    // Matching is a common path used for both evaluation and
2379    // confirmation. It basically unifies types that appear in impls
2380    // and traits. This does affect the surrounding environment;
2381    // therefore, when used during evaluation, match routines must be
2382    // run inside of a `probe()` so that their side-effects are
2383    // contained.
2384
2385    fn rematch_impl(
2386        &mut self,
2387        impl_def_id: DefId,
2388        obligation: &PolyTraitObligation<'tcx>,
2389    ) -> Normalized<'tcx, GenericArgs<'tcx>> {
2390        let impl_trait_header = self.tcx().impl_trait_header(impl_def_id);
2391        match self.match_impl(impl_def_id, impl_trait_header, obligation) {
2392            Ok(args) => args,
2393            Err(()) => {
2394                let predicate = self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
2395                ::rustc_span::macros::bug_impl(None,
    format_args!("impl {0:?} was matchable against {1:?} but now is not",
        impl_def_id, predicate), Location::caller())bug!("impl {impl_def_id:?} was matchable against {predicate:?} but now is not")
2396            }
2397        }
2398    }
2399
2400    {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(2400u32),
                                ::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, GenericArgs<'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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2414",
                                                "rustc_trait_selection::traits::select",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(2414u32),
                                                ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2426",
                                                "rustc_trait_selection::traits::select",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(2426u32),
                                                ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2439",
                                                                    "rustc_trait_selection::traits::select",
                                                                    ::tracing::Level::DEBUG,
                                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                                    ::tracing_core::__macro_support::Option::Some(2439u32),
                                                                    ::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2447",
                                                        "rustc_trait_selection::traits::select",
                                                        ::tracing::Level::DEBUG,
                                                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                                        ::tracing_core::__macro_support::Option::Some(2447u32),
                                                        ::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::Typeck { .. } |
                                TypingMode::PostTypeckThroughBorrowck { .. } |
                                TypingMode::PostBorrowck { .. } | TypingMode::Codegen |
                                TypingMode::ErasedNotCoherence(_) | TypingMode::Reflection |
                                TypingMode::PostAnalysis => {}
                            TypingMode::Coherence => {
                                {
                                    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
                                            format_args!("old solver coherence")));
                                }
                            }
                        }
                        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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2400",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2400u32),
                        ::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)]
2401    fn match_impl(
2402        &mut self,
2403        impl_def_id: DefId,
2404        impl_trait_header: ty::ImplTraitHeader<'tcx>,
2405        obligation: &PolyTraitObligation<'tcx>,
2406    ) -> Result<Normalized<'tcx, GenericArgs<'tcx>>, ()> {
2407        let placeholder_obligation =
2408            self.infcx.enter_forall_and_leak_universe(obligation.predicate);
2409        let placeholder_obligation_trait_ref = placeholder_obligation.trait_ref;
2410
2411        let impl_args = self.infcx.fresh_args_for_item(obligation.cause.span, impl_def_id);
2412
2413        let trait_ref = impl_trait_header.trait_ref.instantiate(self.tcx(), impl_args);
2414        debug!(?impl_trait_header);
2415
2416        let mut nested_obligations = PredicateObligations::new();
2417        let impl_trait_ref = normalize_with_depth_to(
2418            self,
2419            obligation.param_env,
2420            obligation.cause.clone(),
2421            obligation.recursion_depth + 1,
2422            trait_ref,
2423            &mut nested_obligations,
2424        );
2425
2426        debug!(?impl_trait_ref, ?placeholder_obligation_trait_ref);
2427
2428        let cause = ObligationCause::new(
2429            obligation.cause.span,
2430            obligation.cause.body_def_id,
2431            ObligationCauseCode::MatchImpl(obligation.cause.clone(), impl_def_id),
2432        );
2433
2434        let InferOk { obligations, .. } = self
2435            .infcx
2436            .at(&cause, obligation.param_env)
2437            .eq(DefineOpaqueTypes::No, placeholder_obligation_trait_ref, impl_trait_ref)
2438            .map_err(|e| {
2439                debug!("match_impl: failed eq_trait_refs due to `{}`", e.to_string(self.tcx()))
2440            })?;
2441        nested_obligations.extend(obligations);
2442
2443        match self.typing_mode() {
2444            TypingMode::Reflection
2445                if !self.tcx().impl_is_fully_generic_for_reflection(impl_def_id) =>
2446            {
2447                debug!("reflection mode only allows fully generic impls");
2448                return Err(());
2449            }
2450
2451            TypingMode::Typeck { .. }
2452            | TypingMode::PostTypeckThroughBorrowck { .. }
2453            | TypingMode::PostBorrowck { .. }
2454            | TypingMode::Codegen
2455            | TypingMode::ErasedNotCoherence(_)
2456            | TypingMode::Reflection
2457            | TypingMode::PostAnalysis => {}
2458            TypingMode::Coherence => {
2459                unreachable!("old solver coherence")
2460            }
2461        }
2462
2463        Ok(Normalized { value: impl_args, obligations: nested_obligations })
2464    }
2465
2466    fn match_upcast_principal(
2467        &mut self,
2468        obligation: &PolyTraitObligation<'tcx>,
2469        unnormalized_upcast_principal: ty::Unnormalized<'tcx, ty::PolyTraitRef<'tcx>>,
2470        a_data: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
2471        b_data: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
2472        a_region: ty::Region<'tcx>,
2473        b_region: ty::Region<'tcx>,
2474    ) -> SelectionResult<'tcx, PredicateObligations<'tcx>> {
2475        let tcx = self.tcx();
2476        let mut nested = PredicateObligations::new();
2477
2478        // We may upcast to auto traits that are either explicitly listed in
2479        // the object type's bounds, or implied by the principal trait ref's
2480        // supertraits.
2481        let a_auto_traits: FxIndexSet<DefId> = a_data
2482            .auto_traits()
2483            .chain(
2484                a_data
2485                    .principal_def_id()
2486                    .map(|principal_def_id| {
2487                        elaborate::supertrait_def_ids(tcx, principal_def_id)
2488                            .filter(|def_id| tcx.trait_is_auto(*def_id))
2489                    })
2490                    .into_flat_iter(),
2491            )
2492            .collect();
2493
2494        let upcast_principal = normalize_with_depth_to(
2495            self,
2496            obligation.param_env,
2497            obligation.cause.clone(),
2498            obligation.recursion_depth + 1,
2499            unnormalized_upcast_principal,
2500            &mut nested,
2501        );
2502
2503        for bound in b_data {
2504            match bound.skip_binder() {
2505                // Check that a_ty's supertrait (upcast_principal) is compatible
2506                // with the target (b_ty).
2507                ty::ExistentialPredicate::Trait(target_principal) => {
2508                    let hr_source_principal = upcast_principal.map_bound(|trait_ref| {
2509                        ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
2510                    });
2511                    let hr_target_principal = bound.rebind(target_principal);
2512
2513                    nested.extend(
2514                        self.infcx
2515                            .enter_forall(hr_target_principal, |target_principal| {
2516                                let source_principal =
2517                                    self.infcx.instantiate_binder_with_fresh_vars(
2518                                        obligation.cause.span,
2519                                        HigherRankedType,
2520                                        hr_source_principal,
2521                                    );
2522                                self.infcx.at(&obligation.cause, obligation.param_env).eq_trace(
2523                                    DefineOpaqueTypes::Yes,
2524                                    ToTrace::to_trace(
2525                                        &obligation.cause,
2526                                        hr_target_principal,
2527                                        hr_source_principal,
2528                                    ),
2529                                    target_principal,
2530                                    source_principal,
2531                                )
2532                            })
2533                            .map_err(|_| SelectionError::Unimplemented)?
2534                            .into_obligations(),
2535                    );
2536                }
2537                // Check that b_ty's projection is satisfied by exactly one of
2538                // a_ty's projections. First, we look through the list to see if
2539                // any match. If not, error. Then, if *more* than one matches, we
2540                // return ambiguity. Otherwise, if exactly one matches, equate
2541                // it with b_ty's projection.
2542                ty::ExistentialPredicate::Projection(target_projection) => {
2543                    let hr_target_projection = bound.rebind(target_projection);
2544
2545                    let mut matching_projections =
2546                        a_data.projection_bounds().filter(|&hr_source_projection| {
2547                            // Eager normalization means that we can just use can_eq
2548                            // here instead of equating and processing obligations.
2549                            hr_source_projection.item_def_id() == hr_target_projection.item_def_id()
2550                                && self.infcx.probe(|_| {
2551                                    self.infcx
2552                                        .enter_forall(hr_target_projection, |target_projection| {
2553                                            let source_projection =
2554                                                self.infcx.instantiate_binder_with_fresh_vars(
2555                                                    obligation.cause.span,
2556                                                    HigherRankedType,
2557                                                    hr_source_projection,
2558                                                );
2559                                            self.infcx
2560                                                .at(&obligation.cause, obligation.param_env)
2561                                                .eq_trace(
2562                                                    DefineOpaqueTypes::Yes,
2563                                                    ToTrace::to_trace(
2564                                                        &obligation.cause,
2565                                                        hr_target_projection,
2566                                                        hr_source_projection,
2567                                                    ),
2568                                                    target_projection,
2569                                                    source_projection,
2570                                                )
2571                                        })
2572                                        .is_ok()
2573                                })
2574                        });
2575
2576                    let Some(hr_source_projection) = matching_projections.next() else {
2577                        return Err(SelectionError::Unimplemented);
2578                    };
2579                    if matching_projections.next().is_some() {
2580                        return Ok(None);
2581                    }
2582                    nested.extend(
2583                        self.infcx
2584                            .enter_forall(hr_target_projection, |target_projection| {
2585                                let source_projection =
2586                                    self.infcx.instantiate_binder_with_fresh_vars(
2587                                        obligation.cause.span,
2588                                        HigherRankedType,
2589                                        hr_source_projection,
2590                                    );
2591                                self.infcx.at(&obligation.cause, obligation.param_env).eq_trace(
2592                                    DefineOpaqueTypes::Yes,
2593                                    ToTrace::to_trace(
2594                                        &obligation.cause,
2595                                        hr_target_projection,
2596                                        hr_source_projection,
2597                                    ),
2598                                    target_projection,
2599                                    source_projection,
2600                                )
2601                            })
2602                            .map_err(|_| SelectionError::Unimplemented)?
2603                            .into_obligations(),
2604                    );
2605                }
2606                // Check that b_ty's auto traits are present in a_ty's bounds.
2607                ty::ExistentialPredicate::AutoTrait(def_id) => {
2608                    if !a_auto_traits.contains(&def_id) {
2609                        return Err(SelectionError::Unimplemented);
2610                    }
2611                }
2612            }
2613        }
2614
2615        nested.push(Obligation::with_depth(
2616            tcx,
2617            obligation.cause.clone(),
2618            obligation.recursion_depth + 1,
2619            obligation.param_env,
2620            ty::Binder::dummy(ty::OutlivesClause(a_region, b_region)),
2621        ));
2622
2623        Ok(Some(nested))
2624    }
2625
2626    /// Normalize `where_clause_trait_ref` and try to match it against
2627    /// `obligation`. If successful, return any predicates that
2628    /// result from the normalization.
2629    fn match_where_clause_trait_ref(
2630        &mut self,
2631        obligation: &PolyTraitObligation<'tcx>,
2632        where_clause_trait_ref: ty::PolyTraitRef<'tcx>,
2633    ) -> Result<PredicateObligations<'tcx>, ()> {
2634        self.match_poly_trait_ref(obligation, where_clause_trait_ref)
2635    }
2636
2637    /// Returns `Ok` if `poly_trait_ref` being true implies that the
2638    /// obligation is satisfied.
2639    {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2639u32),
                                    ::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")]
2640    fn match_poly_trait_ref(
2641        &mut self,
2642        obligation: &PolyTraitObligation<'tcx>,
2643        poly_trait_ref: ty::PolyTraitRef<'tcx>,
2644    ) -> Result<PredicateObligations<'tcx>, ()> {
2645        let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
2646        let trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
2647            obligation.cause.span,
2648            HigherRankedType,
2649            poly_trait_ref,
2650        );
2651        self.infcx
2652            .at(&obligation.cause, obligation.param_env)
2653            .eq(DefineOpaqueTypes::No, predicate.trait_ref, trait_ref)
2654            .map(|InferOk { obligations, .. }| obligations)
2655            .map_err(|_| ())
2656    }
2657
2658    ///////////////////////////////////////////////////////////////////////////
2659    // Miscellany
2660
2661    fn match_fresh_trait_preds(
2662        &self,
2663        previous: ty::PolyTraitClause<'tcx>,
2664        current: ty::PolyTraitClause<'tcx>,
2665    ) -> bool {
2666        let mut matcher = _match::MatchAgainstFreshVars::new(self.tcx());
2667        matcher.relate(previous, current).is_ok()
2668    }
2669
2670    fn push_stack<'o>(
2671        &mut self,
2672        previous_stack: TraitObligationStackList<'o, 'tcx>,
2673        obligation: &'o PolyTraitObligation<'tcx>,
2674    ) -> TraitObligationStack<'o, 'tcx> {
2675        let fresh_trait_pred = obligation.predicate.fold_with(&mut self.freshener);
2676
2677        let dfn = previous_stack.cache.next_dfn();
2678        let depth = previous_stack.depth() + 1;
2679        TraitObligationStack {
2680            obligation,
2681            fresh_trait_pred,
2682            reached_depth: Cell::new(depth),
2683            previous: previous_stack,
2684            dfn,
2685            depth,
2686        }
2687    }
2688
2689    {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2689u32),
                                    ::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_span::macros::bug_impl(None,
                        format_args!("expected closure, found {0}", self_ty),
                        Location::caller());
                };
            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")]
2690    fn closure_trait_ref_unnormalized(
2691        &mut self,
2692        self_ty: Ty<'tcx>,
2693        fn_trait_def_id: DefId,
2694    ) -> ty::PolyTraitRef<'tcx> {
2695        let ty::Closure(_, args) = *self_ty.kind() else {
2696            bug!("expected closure, found {self_ty}");
2697        };
2698        let closure_sig = args.as_closure().sig();
2699
2700        closure_trait_ref_and_return_type(
2701            self.tcx(),
2702            fn_trait_def_id,
2703            self_ty,
2704            closure_sig,
2705            util::TupleArgumentsFlag::No,
2706        )
2707        .map_bound(|(trait_ref, _)| trait_ref)
2708    }
2709
2710    /// Returns the obligations that are implied by instantiating an
2711    /// impl or trait. The obligations are instantiated and fully
2712    /// normalized. This is used when confirming an impl or default
2713    /// impl.
2714    {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2714u32),
                                    ::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))]
2715    fn impl_or_trait_obligations(
2716        &mut self,
2717        cause: &ObligationCause<'tcx>,
2718        recursion_depth: usize,
2719        param_env: ty::ParamEnv<'tcx>,
2720        def_id: DefId,           // of impl or trait
2721        args: GenericArgs<'tcx>, // for impl or trait
2722        parent_trait_pred: ty::Binder<'tcx, ty::TraitClause<'tcx>>,
2723    ) -> PredicateObligations<'tcx> {
2724        let tcx = self.tcx();
2725
2726        // To allow for one-pass evaluation of the nested obligation,
2727        // each predicate must be preceded by the obligations required
2728        // to normalize it.
2729        // for example, if we have:
2730        //    impl<U: Iterator<Item: Copy>, V: Iterator<Item = U>> Foo for V
2731        // the impl will have the following predicates:
2732        //    <V as Iterator>::Item = U,
2733        //    U: Iterator, U: Sized,
2734        //    V: Iterator, V: Sized,
2735        //    <U as Iterator>::Item: Copy
2736        // When we instantiate, say, `V => IntoIter<u32>, U => $0`, the last
2737        // obligation will normalize to `<$0 as Iterator>::Item = $1` and
2738        // `$1: Copy`, so we must ensure the obligations are emitted in
2739        // that order.
2740        let clauses = tcx.clauses_of(def_id);
2741        assert_eq!(clauses.parent, None);
2742        let clauses = clauses.instantiate_own(tcx, args);
2743        let mut obligations = PredicateObligations::with_capacity(clauses.len());
2744        for (index, (clause, span)) in clauses.into_iter().enumerate() {
2745            let cause = if tcx.is_lang_item(parent_trait_pred.def_id(), LangItem::CoerceUnsized) {
2746                cause.clone()
2747            } else {
2748                cause.clone().derived_cause(parent_trait_pred, |derived| {
2749                    ObligationCauseCode::ImplDerived(Box::new(ImplDerivedCause {
2750                        derived,
2751                        impl_or_alias_def_id: def_id,
2752                        impl_def_clause_index: Some(index),
2753                        span,
2754                    }))
2755                })
2756            };
2757            let clause = normalize_with_depth_to(
2758                self,
2759                param_env,
2760                cause.clone(),
2761                recursion_depth,
2762                clause,
2763                &mut obligations,
2764            );
2765            obligations.push(Obligation {
2766                cause,
2767                recursion_depth,
2768                param_env,
2769                predicate: clause.as_predicate(),
2770            });
2771        }
2772
2773        // Register any outlives obligations from the trait here, cc #124336.
2774        if tcx.def_kind(def_id) == (DefKind::Impl { of_trait: true }) {
2775            for clause in tcx.impl_super_outlives(def_id).iter_instantiated(tcx, args) {
2776                let clause = normalize_with_depth_to(
2777                    self,
2778                    param_env,
2779                    cause.clone(),
2780                    recursion_depth,
2781                    clause,
2782                    &mut obligations,
2783                );
2784                obligations.push(Obligation {
2785                    cause: cause.clone(),
2786                    recursion_depth,
2787                    param_env,
2788                    predicate: clause.as_predicate(),
2789                });
2790            }
2791        }
2792
2793        obligations
2794    }
2795
2796    pub(super) fn should_stall_coroutine(&self, def_id: DefId) -> bool {
2797        match self.typing_mode() {
2798            TypingMode::Typeck { defining_opaque_types_and_generators: stalled_generators } => {
2799                def_id.as_local().is_some_and(|def_id| stalled_generators.contains(&def_id))
2800            }
2801            TypingMode::PostAnalysis
2802            | TypingMode::Reflection
2803            | TypingMode::Codegen
2804            | TypingMode::PostTypeckThroughBorrowck { defining_opaque_types: _ }
2805            | TypingMode::PostBorrowck { defined_opaque_types: _ } => false,
2806            TypingMode::Coherence => {
2807                {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("old solver coherence")));
}unreachable!("old solver coherence")
2808            }
2809        }
2810    }
2811}
2812
2813impl<'o, 'tcx> TraitObligationStack<'o, 'tcx> {
2814    fn list(&'o self) -> TraitObligationStackList<'o, 'tcx> {
2815        TraitObligationStackList::with(self)
2816    }
2817
2818    fn cache(&self) -> &'o ProvisionalEvaluationCache<'tcx> {
2819        self.previous.cache
2820    }
2821
2822    fn iter(&'o self) -> TraitObligationStackList<'o, 'tcx> {
2823        self.list()
2824    }
2825
2826    /// Indicates that attempting to evaluate this stack entry
2827    /// required accessing something from the stack at depth `reached_depth`.
2828    fn update_reached_depth(&self, reached_depth: usize) {
2829        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!(
2830            self.depth >= reached_depth,
2831            "invoked `update_reached_depth` with something under this stack: \
2832             self.depth={} reached_depth={}",
2833            self.depth,
2834            reached_depth,
2835        );
2836        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2836",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2836u32),
                        ::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");
2837        let mut p = self;
2838        while reached_depth < p.depth {
2839            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2839",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2839u32),
                        ::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");
2840            p.reached_depth.set(p.reached_depth.get().min(reached_depth));
2841            p = p.previous.head.unwrap();
2842        }
2843    }
2844}
2845
2846/// The "provisional evaluation cache" is used to store intermediate cache results
2847/// when solving auto traits. Auto traits are unusual in that they can support
2848/// cycles. So, for example, a "proof tree" like this would be ok:
2849///
2850/// - `Foo<T>: Send` :-
2851///   - `Bar<T>: Send` :-
2852///     - `Foo<T>: Send` -- cycle, but ok
2853///   - `Baz<T>: Send`
2854///
2855/// Here, to prove `Foo<T>: Send`, we have to prove `Bar<T>: Send` and
2856/// `Baz<T>: Send`. Proving `Bar<T>: Send` in turn required `Foo<T>: Send`.
2857/// For non-auto traits, this cycle would be an error, but for auto traits (because
2858/// they are coinductive) it is considered ok.
2859///
2860/// However, there is a complication: at the point where we have
2861/// "proven" `Bar<T>: Send`, we have in fact only proven it
2862/// *provisionally*. In particular, we proved that `Bar<T>: Send`
2863/// *under the assumption* that `Foo<T>: Send`. But what if we later
2864/// find out this assumption is wrong?  Specifically, we could
2865/// encounter some kind of error proving `Baz<T>: Send`. In that case,
2866/// `Bar<T>: Send` didn't turn out to be true.
2867///
2868/// In Issue #60010, we found a bug in rustc where it would cache
2869/// these intermediate results. This was fixed in #60444 by disabling
2870/// *all* caching for things involved in a cycle -- in our example,
2871/// that would mean we don't cache that `Bar<T>: Send`. But this led
2872/// to large slowdowns.
2873///
2874/// Specifically, imagine this scenario, where proving `Baz<T>: Send`
2875/// first requires proving `Bar<T>: Send` (which is true:
2876///
2877/// - `Foo<T>: Send` :-
2878///   - `Bar<T>: Send` :-
2879///     - `Foo<T>: Send` -- cycle, but ok
2880///   - `Baz<T>: Send`
2881///     - `Bar<T>: Send` -- would be nice for this to be a cache hit!
2882///     - `*const T: Send` -- but what if we later encounter an error?
2883///
2884/// The *provisional evaluation cache* resolves this issue. It stores
2885/// cache results that we've proven but which were involved in a cycle
2886/// in some way. We track the minimal stack depth (i.e., the
2887/// farthest from the top of the stack) that we are dependent on.
2888/// The idea is that the cache results within are all valid -- so long as
2889/// none of the nodes in between the current node and the node at that minimum
2890/// depth result in an error (in which case the cached results are just thrown away).
2891///
2892/// During evaluation, we consult this provisional cache and rely on
2893/// it. Accessing a cached value is considered equivalent to accessing
2894/// a result at `reached_depth`, so it marks the *current* solution as
2895/// provisional as well. If an error is encountered, we toss out any
2896/// provisional results added from the subtree that encountered the
2897/// error. When we pop the node at `reached_depth` from the stack, we
2898/// can commit all the things that remain in the provisional cache.
2899struct ProvisionalEvaluationCache<'tcx> {
2900    /// next "depth first number" to issue -- just a counter
2901    dfn: Cell<usize>,
2902
2903    /// Map from cache key to the provisionally evaluated thing.
2904    /// The cache entries contain the result but also the DFN in which they
2905    /// were added. The DFN is used to clear out values on failure.
2906    ///
2907    /// Imagine we have a stack like:
2908    ///
2909    /// - `A B C` and we add a cache for the result of C (DFN 2)
2910    /// - Then we have a stack `A B D` where `D` has DFN 3
2911    /// - We try to solve D by evaluating E: `A B D E` (DFN 4)
2912    /// - `E` generates various cache entries which have cyclic dependencies on `B`
2913    ///   - `A B D E F` and so forth
2914    ///   - the DFN of `F` for example would be 5
2915    /// - then we determine that `E` is in error -- we will then clear
2916    ///   all cache values whose DFN is >= 4 -- in this case, that
2917    ///   means the cached value for `F`.
2918    map: RefCell<FxIndexMap<ty::PolyTraitClause<'tcx>, ProvisionalEvaluation>>,
2919
2920    /// The stack of terms that we assume to be well-formed because a `WF(term)` predicate
2921    /// is on the stack above (and because of wellformedness is coinductive).
2922    /// In an "ideal" world, this would share a stack with trait predicates in
2923    /// `TraitObligationStack`. However, trait predicates are *much* hotter than
2924    /// `WellFormed` predicates, and it's very likely that the additional matches
2925    /// will have a perf effect. The value here is the well-formed `GenericArg`
2926    /// and the depth of the trait predicate *above* that well-formed predicate.
2927    wf_args: RefCell<Vec<(ty::Term<'tcx>, usize)>>,
2928}
2929
2930/// A cache value for the provisional cache: contains the depth-first
2931/// number (DFN) and result.
2932#[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]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<usize>;
        let _: ::core::clone::AssertParamIsClone<EvaluationResult>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for ProvisionalEvaluation {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "ProvisionalEvaluation from_dfn reached_depth result",
            &self.from_dfn, &self.reached_depth, &&self.result)
    }
}Debug)]
2933struct ProvisionalEvaluation {
2934    from_dfn: usize,
2935    reached_depth: usize,
2936    result: EvaluationResult,
2937}
2938
2939impl<'tcx> Default for ProvisionalEvaluationCache<'tcx> {
2940    fn default() -> Self {
2941        Self { dfn: Cell::new(0), map: Default::default(), wf_args: Default::default() }
2942    }
2943}
2944
2945impl<'tcx> ProvisionalEvaluationCache<'tcx> {
2946    /// Get the next DFN in sequence (basically a counter).
2947    fn next_dfn(&self) -> usize {
2948        let result = self.dfn.get();
2949        self.dfn.set(result + 1);
2950        result
2951    }
2952
2953    /// Check the provisional cache for any result for
2954    /// `fresh_trait_pred`. If there is a hit, then you must consider
2955    /// it an access to the stack slots at depth
2956    /// `reached_depth` (from the returned value).
2957    fn get_provisional(
2958        &self,
2959        fresh_trait_pred: ty::PolyTraitClause<'tcx>,
2960    ) -> Option<ProvisionalEvaluation> {
2961        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2961",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2961u32),
                        ::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!(
2962            ?fresh_trait_pred,
2963            "get_provisional = {:#?}",
2964            self.map.borrow().get(&fresh_trait_pred),
2965        );
2966        Some(*self.map.borrow().get(&fresh_trait_pred)?)
2967    }
2968
2969    /// Insert a provisional result into the cache. The result came
2970    /// from the node with the given DFN. It accessed a minimum depth
2971    /// of `reached_depth` to compute. It evaluated `fresh_trait_pred`
2972    /// and resulted in `result`.
2973    fn insert_provisional(
2974        &self,
2975        from_dfn: usize,
2976        reached_depth: usize,
2977        fresh_trait_pred: ty::PolyTraitClause<'tcx>,
2978        result: EvaluationResult,
2979    ) {
2980        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2980",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2980u32),
                        ::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");
2981
2982        let mut map = self.map.borrow_mut();
2983
2984        // Subtle: when we complete working on the DFN `from_dfn`, anything
2985        // that remains in the provisional cache must be dependent on some older
2986        // stack entry than `from_dfn`. We have to update their depth with our transitive
2987        // depth in that case or else it would be referring to some popped note.
2988        //
2989        // Example:
2990        // A (reached depth 0)
2991        //   ...
2992        //      B // depth 1 -- reached depth = 0
2993        //          C // depth 2 -- reached depth = 1 (should be 0)
2994        //              B
2995        //          A // depth 0
2996        //   D (reached depth 1)
2997        //      C (cache -- reached depth = 2)
2998        for (_k, v) in &mut *map {
2999            if v.from_dfn >= from_dfn {
3000                v.reached_depth = reached_depth.min(v.reached_depth);
3001            }
3002        }
3003
3004        map.insert(fresh_trait_pred, ProvisionalEvaluation { from_dfn, reached_depth, result });
3005    }
3006
3007    /// Invoked when the node with dfn `dfn` does not get a successful
3008    /// result. This will clear out any provisional cache entries
3009    /// originating from nodes visited before this node (`from_dfn < dfn`).
3010    /// This is because the provisional entries are things which must
3011    /// assume that the things on the stack at the time of their creation
3012    /// succeeded -- since the failing node is presently at the top of
3013    /// the stack, these provisional entries must either depend on it or
3014    /// some ancestor of it.
3015    fn on_failure(&self, dfn: usize) {
3016        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:3016",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3016u32),
                        ::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");
3017        self.map.borrow_mut().retain(|key, eval| {
3018            if eval.from_dfn < dfn {
3019                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:3019",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3019u32),
                        ::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);
3020                false
3021            } else {
3022                true
3023            }
3024        });
3025    }
3026
3027    /// Invoked when the node at depth `depth` completed without
3028    /// depending on anything higher in the stack (if that completion
3029    /// was a failure, then `on_failure` should have been invoked
3030    /// already).
3031    ///
3032    /// Note that we may still have provisional cache items remaining
3033    /// in the cache when this is done. For example, if there is a
3034    /// cycle:
3035    ///
3036    /// * A depends on...
3037    ///     * B depends on A
3038    ///     * C depends on...
3039    ///         * D depends on C
3040    ///     * ...
3041    ///
3042    /// Then as we complete the C node we will have a provisional cache
3043    /// with results for A, B, C, and D. This method would clear out
3044    /// the C and D results, but leave A and B provisional.
3045    ///
3046    /// This is determined based on the DFN: we remove any provisional
3047    /// results created since `dfn` started (e.g., in our example, dfn
3048    /// would be 2, representing the C node, and hence we would
3049    /// remove the result for D, which has DFN 3, but not the results for
3050    /// A and B, which have DFNs 0 and 1 respectively).
3051    ///
3052    /// Note that we *do not* attempt to cache these cycle participants
3053    /// in the evaluation cache. Doing so would require carefully computing
3054    /// the correct `DepNode` to store in the cache entry:
3055    /// cycle participants may implicitly depend on query results
3056    /// related to other participants in the cycle, due to our logic
3057    /// which examines the evaluation stack.
3058    ///
3059    /// We used to try to perform this caching,
3060    /// but it lead to multiple incremental compilation ICEs
3061    /// (see #92987 and #96319), and was very hard to understand.
3062    /// Fortunately, removing the caching didn't seem to
3063    /// have a performance impact in practice.
3064    fn on_completion(&self, dfn: usize) {
3065        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:3065",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3065u32),
                        ::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");
3066        self.map.borrow_mut().retain(|fresh_trait_pred, eval| {
3067            if eval.from_dfn >= dfn {
3068                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:3068",
                        "rustc_trait_selection::traits::select",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3068u32),
                        ::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");
3069                return false;
3070            }
3071            true
3072        });
3073    }
3074}
3075
3076#[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]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _:
                ::core::clone::AssertParamIsClone<&'o ProvisionalEvaluationCache<'tcx>>;
        let _:
                ::core::clone::AssertParamIsClone<Option<&'o TraitObligationStack<'o,
                'tcx>>>;
        *self
    }
}Clone)]
3077struct TraitObligationStackList<'o, 'tcx> {
3078    cache: &'o ProvisionalEvaluationCache<'tcx>,
3079    head: Option<&'o TraitObligationStack<'o, 'tcx>>,
3080}
3081
3082impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> {
3083    fn empty(cache: &'o ProvisionalEvaluationCache<'tcx>) -> TraitObligationStackList<'o, 'tcx> {
3084        TraitObligationStackList { cache, head: None }
3085    }
3086
3087    fn with(r: &'o TraitObligationStack<'o, 'tcx>) -> TraitObligationStackList<'o, 'tcx> {
3088        TraitObligationStackList { cache: r.cache(), head: Some(r) }
3089    }
3090
3091    fn head(&self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
3092        self.head
3093    }
3094
3095    fn depth(&self) -> usize {
3096        if let Some(head) = self.head { head.depth } else { 0 }
3097    }
3098}
3099
3100impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> {
3101    type Item = &'o TraitObligationStack<'o, 'tcx>;
3102
3103    fn next(&mut self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
3104        let o = self.head?;
3105        *self = o.previous;
3106        Some(o)
3107    }
3108}
3109
3110impl<'o, 'tcx> fmt::Debug for TraitObligationStack<'o, 'tcx> {
3111    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3112        f.write_fmt(format_args!("TraitObligationStack({0:?})", self.obligation))write!(f, "TraitObligationStack({:?})", self.obligation)
3113    }
3114}
3115
3116pub(crate) enum ProjectionMatchesProjection {
3117    Yes,
3118    Ambiguous,
3119    No,
3120}
3121
3122#[derive(#[automatically_derived]impl<'tcx> ::core::clone::Clone for
    AutoImplConstituents<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        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]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "AutoImplConstituents types assumptions", &self.types,
            &&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)]
3123pub(crate) struct AutoImplConstituents<'tcx> {
3124    pub types: Vec<Ty<'tcx>>,
3125    pub assumptions: Vec<ty::ArgOutlivesClause<'tcx>>,
3126}