Skip to main content

rustc_trait_selection/traits/select/
confirmation.rs

1//! Confirmation.
2//!
3//! Confirmation unifies the output type parameters of the trait
4//! with the values found in the obligation, possibly yielding a
5//! type error. See the [rustc dev guide] for more details.
6//!
7//! [rustc dev guide]:
8//! https://rustc-dev-guide.rust-lang.org/traits/resolution.html#confirmation
9
10use std::ops::ControlFlow;
11
12use rustc_data_structures::stack::ensure_sufficient_stack;
13use rustc_hir::lang_items::LangItem;
14use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk};
15use rustc_infer::traits::ObligationCauseCode;
16use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData};
17use rustc_middle::ty::{self, GenericArgsRef, Region, SizedTraitKind, Ty, TyCtxt, Upcast};
18use rustc_middle::{bug, span_bug};
19use rustc_span::def_id::DefId;
20use thin_vec::thin_vec;
21use tracing::{debug, instrument};
22
23use super::SelectionCandidate::{self, *};
24use super::{PredicateObligations, SelectionContext};
25use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to};
26use crate::traits::util::{self, closure_trait_ref_and_return_type};
27use crate::traits::{
28    ImplSource, ImplSourceUserDefinedData, Normalized, Obligation, ObligationCause,
29    PolyTraitObligation, PredicateObligation, Selection, SelectionError, TraitObligation,
30};
31
32impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
33    #[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("confirm_candidate",
                                    "rustc_trait_selection::traits::select::confirmation",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(33u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&["obligation",
                                                    "candidate"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
                                                            as &dyn 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<Selection<'tcx>, SelectionError<'tcx>> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            Ok(match candidate {
                    SizedCandidate => {
                        let data = self.confirm_builtin_candidate(obligation);
                        ImplSource::Builtin(BuiltinImplSource::Misc, data)
                    }
                    BuiltinCandidate => {
                        let data = self.confirm_builtin_candidate(obligation);
                        ImplSource::Builtin(BuiltinImplSource::Misc, data)
                    }
                    TransmutabilityCandidate => {
                        let data =
                            self.confirm_transmutability_candidate(obligation)?;
                        ImplSource::Builtin(BuiltinImplSource::Misc, data)
                    }
                    ParamCandidate(param) => {
                        let obligations =
                            self.confirm_param_candidate(obligation,
                                param.map_bound(|t| t.trait_ref));
                        ImplSource::Param(obligations)
                    }
                    ImplCandidate(impl_def_id) => {
                        ImplSource::UserDefined(self.confirm_impl_candidate(obligation,
                                impl_def_id))
                    }
                    AutoImplCandidate => {
                        let data = self.confirm_auto_impl_candidate(obligation)?;
                        ImplSource::Builtin(BuiltinImplSource::Misc, data)
                    }
                    ProjectionCandidate { idx, .. } => {
                        let obligations =
                            self.confirm_projection_candidate(obligation, idx)?;
                        ImplSource::Param(obligations)
                    }
                    ObjectCandidate(idx) =>
                        self.confirm_object_candidate(obligation, idx)?,
                    ClosureCandidate { .. } => {
                        let vtable_closure =
                            self.confirm_closure_candidate(obligation)?;
                        ImplSource::Builtin(BuiltinImplSource::Misc, vtable_closure)
                    }
                    AsyncClosureCandidate => {
                        let vtable_closure =
                            self.confirm_async_closure_candidate(obligation)?;
                        ImplSource::Builtin(BuiltinImplSource::Misc, vtable_closure)
                    }
                    AsyncFnKindHelperCandidate => {
                        ImplSource::Builtin(BuiltinImplSource::Misc,
                            PredicateObligations::new())
                    }
                    CoroutineCandidate => {
                        let vtable_coroutine =
                            self.confirm_coroutine_candidate(obligation)?;
                        ImplSource::Builtin(BuiltinImplSource::Misc,
                            vtable_coroutine)
                    }
                    FutureCandidate => {
                        let vtable_future =
                            self.confirm_future_candidate(obligation)?;
                        ImplSource::Builtin(BuiltinImplSource::Misc, vtable_future)
                    }
                    IteratorCandidate => {
                        let vtable_iterator =
                            self.confirm_iterator_candidate(obligation)?;
                        ImplSource::Builtin(BuiltinImplSource::Misc,
                            vtable_iterator)
                    }
                    AsyncIteratorCandidate => {
                        let vtable_iterator =
                            self.confirm_async_iterator_candidate(obligation)?;
                        ImplSource::Builtin(BuiltinImplSource::Misc,
                            vtable_iterator)
                    }
                    FnPointerCandidate => {
                        let data = self.confirm_fn_pointer_candidate(obligation)?;
                        ImplSource::Builtin(BuiltinImplSource::Misc, data)
                    }
                    PointerLikeCandidate => {
                        let data = self.confirm_pointer_like_candidate(obligation);
                        ImplSource::Builtin(BuiltinImplSource::Misc, data)
                    }
                    TraitAliasCandidate => {
                        let data = self.confirm_trait_alias_candidate(obligation);
                        ImplSource::Builtin(BuiltinImplSource::Misc, data)
                    }
                    BuiltinObjectCandidate => {
                        ImplSource::Builtin(BuiltinImplSource::Misc,
                            PredicateObligations::new())
                    }
                    BuiltinUnsizeCandidate =>
                        self.confirm_builtin_unsize_candidate(obligation)?,
                    TraitUpcastingUnsizeCandidate(idx) => {
                        self.confirm_trait_upcasting_unsize_candidate(obligation,
                                idx)?
                    }
                    BikeshedGuaranteedNoDropCandidate => {
                        self.confirm_bikeshed_guaranteed_no_drop_candidate(obligation)
                    }
                })
        }
    }
}#[instrument(level = "debug", skip(self))]
34    pub(super) fn confirm_candidate(
35        &mut self,
36        obligation: &PolyTraitObligation<'tcx>,
37        candidate: SelectionCandidate<'tcx>,
38    ) -> Result<Selection<'tcx>, SelectionError<'tcx>> {
39        Ok(match candidate {
40            SizedCandidate => {
41                let data = self.confirm_builtin_candidate(obligation);
42                ImplSource::Builtin(BuiltinImplSource::Misc, data)
43            }
44
45            BuiltinCandidate => {
46                let data = self.confirm_builtin_candidate(obligation);
47                ImplSource::Builtin(BuiltinImplSource::Misc, data)
48            }
49
50            TransmutabilityCandidate => {
51                let data = self.confirm_transmutability_candidate(obligation)?;
52                ImplSource::Builtin(BuiltinImplSource::Misc, data)
53            }
54
55            ParamCandidate(param) => {
56                let obligations =
57                    self.confirm_param_candidate(obligation, param.map_bound(|t| t.trait_ref));
58                ImplSource::Param(obligations)
59            }
60
61            ImplCandidate(impl_def_id) => {
62                ImplSource::UserDefined(self.confirm_impl_candidate(obligation, impl_def_id))
63            }
64
65            AutoImplCandidate => {
66                let data = self.confirm_auto_impl_candidate(obligation)?;
67                ImplSource::Builtin(BuiltinImplSource::Misc, data)
68            }
69
70            ProjectionCandidate { idx, .. } => {
71                let obligations = self.confirm_projection_candidate(obligation, idx)?;
72                ImplSource::Param(obligations)
73            }
74
75            ObjectCandidate(idx) => self.confirm_object_candidate(obligation, idx)?,
76
77            ClosureCandidate { .. } => {
78                let vtable_closure = self.confirm_closure_candidate(obligation)?;
79                ImplSource::Builtin(BuiltinImplSource::Misc, vtable_closure)
80            }
81
82            AsyncClosureCandidate => {
83                let vtable_closure = self.confirm_async_closure_candidate(obligation)?;
84                ImplSource::Builtin(BuiltinImplSource::Misc, vtable_closure)
85            }
86
87            // No nested obligations or confirmation process. The checks that we do in
88            // candidate assembly are sufficient.
89            AsyncFnKindHelperCandidate => {
90                ImplSource::Builtin(BuiltinImplSource::Misc, PredicateObligations::new())
91            }
92
93            CoroutineCandidate => {
94                let vtable_coroutine = self.confirm_coroutine_candidate(obligation)?;
95                ImplSource::Builtin(BuiltinImplSource::Misc, vtable_coroutine)
96            }
97
98            FutureCandidate => {
99                let vtable_future = self.confirm_future_candidate(obligation)?;
100                ImplSource::Builtin(BuiltinImplSource::Misc, vtable_future)
101            }
102
103            IteratorCandidate => {
104                let vtable_iterator = self.confirm_iterator_candidate(obligation)?;
105                ImplSource::Builtin(BuiltinImplSource::Misc, vtable_iterator)
106            }
107
108            AsyncIteratorCandidate => {
109                let vtable_iterator = self.confirm_async_iterator_candidate(obligation)?;
110                ImplSource::Builtin(BuiltinImplSource::Misc, vtable_iterator)
111            }
112
113            FnPointerCandidate => {
114                let data = self.confirm_fn_pointer_candidate(obligation)?;
115                ImplSource::Builtin(BuiltinImplSource::Misc, data)
116            }
117
118            PointerLikeCandidate => {
119                let data = self.confirm_pointer_like_candidate(obligation);
120                ImplSource::Builtin(BuiltinImplSource::Misc, data)
121            }
122
123            TraitAliasCandidate => {
124                let data = self.confirm_trait_alias_candidate(obligation);
125                ImplSource::Builtin(BuiltinImplSource::Misc, data)
126            }
127
128            BuiltinObjectCandidate => {
129                // This indicates something like `Trait + Send: Send`. In this case, we know that
130                // this holds because that's what the object type is telling us, and there's really
131                // no additional obligations to prove and no types in particular to unify, etc.
132                ImplSource::Builtin(BuiltinImplSource::Misc, PredicateObligations::new())
133            }
134
135            BuiltinUnsizeCandidate => self.confirm_builtin_unsize_candidate(obligation)?,
136
137            TraitUpcastingUnsizeCandidate(idx) => {
138                self.confirm_trait_upcasting_unsize_candidate(obligation, idx)?
139            }
140
141            BikeshedGuaranteedNoDropCandidate => {
142                self.confirm_bikeshed_guaranteed_no_drop_candidate(obligation)
143            }
144        })
145    }
146
147    fn confirm_projection_candidate(
148        &mut self,
149        obligation: &PolyTraitObligation<'tcx>,
150        idx: usize,
151    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
152        let placeholder_trait_predicate =
153            self.infcx.enter_forall_and_leak_universe(obligation.predicate).trait_ref;
154        let placeholder_self_ty = self.infcx.shallow_resolve(placeholder_trait_predicate.self_ty());
155        let candidate_predicate = self
156            .for_each_item_bound(
157                placeholder_self_ty,
158                |_, clause, clause_idx, _| {
159                    if clause_idx == idx {
160                        ControlFlow::Break(clause)
161                    } else {
162                        ControlFlow::Continue(())
163                    }
164                },
165                || ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
166            )
167            .break_value()
168            .expect("expected to index into clause that exists");
169        let candidate_predicate = candidate_predicate
170            .as_trait_clause()
171            .expect("projection candidate is not a trait predicate");
172        let candidate_predicate =
173            util::lazily_elaborate_sizedness_candidate(self.infcx, obligation, candidate_predicate);
174
175        let candidate = candidate_predicate.map_bound(|t| t.trait_ref);
176
177        let candidate = self.infcx.instantiate_binder_with_fresh_vars(
178            obligation.cause.span,
179            BoundRegionConversionTime::HigherRankedType,
180            candidate,
181        );
182        let mut obligations = PredicateObligations::new();
183        let candidate = normalize_with_depth_to(
184            self,
185            obligation.param_env,
186            obligation.cause.clone(),
187            obligation.recursion_depth + 1,
188            candidate,
189            &mut obligations,
190        );
191
192        obligations.extend(
193            self.infcx
194                .at(&obligation.cause, obligation.param_env)
195                .eq(DefineOpaqueTypes::No, placeholder_trait_predicate, candidate)
196                .map(|InferOk { obligations, .. }| obligations)
197                .map_err(|_| SelectionError::Unimplemented)?,
198        );
199
200        Ok(obligations)
201    }
202
203    fn confirm_param_candidate(
204        &mut self,
205        obligation: &PolyTraitObligation<'tcx>,
206        param: ty::PolyTraitRef<'tcx>,
207    ) -> PredicateObligations<'tcx> {
208        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:208",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(208u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "obligation", "param"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("confirm_param_candidate")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&obligation)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&param) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?obligation, ?param, "confirm_param_candidate");
209
210        let param = util::lazily_elaborate_sizedness_candidate(
211            self.infcx,
212            obligation,
213            param.upcast(self.infcx.tcx),
214        )
215        .map_bound(|p| p.trait_ref);
216
217        // During evaluation, we already checked that this
218        // where-clause trait-ref could be unified with the obligation
219        // trait-ref. Repeat that unification now without any
220        // transactional boundary; it should not fail.
221        match self.match_where_clause_trait_ref(obligation, param) {
222            Ok(obligations) => obligations,
223            Err(()) => {
224                ::rustc_middle::util::bug::bug_fmt(format_args!("Where clause `{0:?}` was applicable to `{1:?}` but now is not",
        param, obligation));bug!(
225                    "Where clause `{:?}` was applicable to `{:?}` but now is not",
226                    param,
227                    obligation
228                );
229            }
230        }
231    }
232
233    x;#[instrument(level = "debug", skip(self), ret)]
234    fn confirm_builtin_candidate(
235        &mut self,
236        obligation: &PolyTraitObligation<'tcx>,
237    ) -> PredicateObligations<'tcx> {
238        debug!(?obligation, "confirm_builtin_candidate");
239        let tcx = self.tcx();
240        let trait_def = obligation.predicate.def_id();
241        let self_ty = self.infcx.shallow_resolve(
242            self.infcx.enter_forall_and_leak_universe(obligation.predicate.self_ty()),
243        );
244        let types = match tcx.as_lang_item(trait_def) {
245            Some(LangItem::Sized) => self.sizedness_conditions(self_ty, SizedTraitKind::Sized),
246            Some(LangItem::MetaSized) => {
247                self.sizedness_conditions(self_ty, SizedTraitKind::MetaSized)
248            }
249            Some(LangItem::PointeeSized) => {
250                bug!("`PointeeSized` is removing during lowering");
251            }
252            Some(LangItem::Copy | LangItem::Clone | LangItem::TrivialClone) => {
253                self.copy_clone_conditions(self_ty)
254            }
255            Some(LangItem::FusedIterator) => {
256                if self.coroutine_is_gen(self_ty) {
257                    ty::Binder::dummy(vec![])
258                } else {
259                    unreachable!("tried to assemble `FusedIterator` for non-gen coroutine");
260                }
261            }
262            Some(
263                LangItem::Destruct
264                | LangItem::DiscriminantKind
265                | LangItem::Field
266                | LangItem::FnPtrTrait
267                | LangItem::PointeeTrait
268                | LangItem::Tuple
269                | LangItem::Unpin,
270            ) => ty::Binder::dummy(vec![]),
271            other => bug!("unexpected builtin trait {trait_def:?} ({other:?})"),
272        };
273        let types = self.infcx.enter_forall_and_leak_universe(types);
274
275        let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
276        self.collect_predicates_for_types(
277            obligation.param_env,
278            cause,
279            obligation.recursion_depth + 1,
280            trait_def,
281            types,
282        )
283    }
284
285    #[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("confirm_transmutability_candidate",
                                    "rustc_trait_selection::traits::select::confirmation",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(285u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&["obligation"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn 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>, SelectionError<'tcx>> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            use rustc_transmute::{Answer, Assume, Condition};
            #[doc =
            " Flatten the `Condition` tree into a conjunction of obligations."]
            fn flatten_answer_tree<'tcx>(tcx: TyCtxt<'tcx>,
                obligation: &PolyTraitObligation<'tcx>,
                cond: Condition<Region<'tcx>, Ty<'tcx>>, assume: Assume)
                -> PredicateObligations<'tcx> {
                {}

                #[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("flatten_answer_tree",
                                                    "rustc_trait_selection::traits::select::confirmation",
                                                    ::tracing::Level::DEBUG,
                                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(293u32),
                                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                                    ::tracing_core::field::FieldSet::new(&["cond", "assume"],
                                                        ::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};
                                                let mut iter = meta.fields().iter();
                                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&cond)
                                                                            as &dyn Value)),
                                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assume)
                                                                            as &dyn 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;
                        }
                        {
                            match cond {
                                Condition::IfAll(conds) | Condition::IfAny(conds) =>
                                    conds.into_iter().flat_map(|cond|
                                                flatten_answer_tree(tcx, obligation, cond,
                                                    assume)).collect(),
                                Condition::Immutable { ty } => {
                                    let trait_ref =
                                        ty::TraitRef::new(tcx,
                                            tcx.require_lang_item(LangItem::Freeze,
                                                obligation.cause.span), [ty::GenericArg::from(ty)]);
                                    {
                                        let len = [()].len();
                                        let mut vec = ::thin_vec::ThinVec::with_capacity(len);
                                        vec.push(Obligation::with_depth(tcx,
                                                obligation.cause.clone(), obligation.recursion_depth + 1,
                                                obligation.param_env, trait_ref));
                                        vec
                                    }
                                }
                                Condition::Outlives { long, short } => {
                                    let outlives = ty::OutlivesPredicate(long, short);
                                    {
                                        let len = [()].len();
                                        let mut vec = ::thin_vec::ThinVec::with_capacity(len);
                                        vec.push(Obligation::with_depth(tcx,
                                                obligation.cause.clone(), obligation.recursion_depth + 1,
                                                obligation.param_env, outlives));
                                        vec
                                    }
                                }
                                Condition::Transmutable { src, dst } => {
                                    let transmute_trait = obligation.predicate.def_id();
                                    let assume =
                                        obligation.predicate.skip_binder().trait_ref.args.const_at(2);
                                    let trait_ref =
                                        ty::TraitRef::new(tcx, transmute_trait,
                                            [ty::GenericArg::from(dst), ty::GenericArg::from(src),
                                                    ty::GenericArg::from(assume)]);
                                    {
                                        let len = [()].len();
                                        let mut vec = ::thin_vec::ThinVec::with_capacity(len);
                                        vec.push(Obligation::with_depth(tcx,
                                                obligation.cause.clone(), obligation.recursion_depth + 1,
                                                obligation.param_env, trait_ref));
                                        vec
                                    }
                                }
                            }
                        }
                    }
                }
            }
            let predicate =
                self.infcx.enter_forall_and_leak_universe(obligation.predicate);
            let mut assume = predicate.trait_ref.args.const_at(2);
            if self.tcx().features().generic_const_exprs() {
                assume =
                    crate::traits::evaluate_const(self.infcx, assume,
                        obligation.param_env)
            }
            let Some(assume) =
                rustc_transmute::Assume::from_const(self.infcx.tcx,
                    assume) else { return Err(SelectionError::Unimplemented); };
            let dst = predicate.trait_ref.args.type_at(0);
            let src = predicate.trait_ref.args.type_at(1);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:367",
                                    "rustc_trait_selection::traits::select::confirmation",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(367u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&["src", "dst"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&src) as
                                                        &dyn Value)),
                                            (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&dst) as
                                                        &dyn Value))])
                        });
                } else { ; }
            };
            let mut transmute_env =
                rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx);
            let maybe_transmutable =
                transmute_env.is_transmutable(src, dst, assume);
            let fully_flattened =
                match maybe_transmutable {
                    Answer::No(_) => Err(SelectionError::Unimplemented)?,
                    Answer::If(cond) =>
                        flatten_answer_tree(self.tcx(), obligation, cond, assume),
                    Answer::Yes => PredicateObligations::new(),
                };
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:377",
                                    "rustc_trait_selection::traits::select::confirmation",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(377u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&["fully_flattened"],
                                        ::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};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&fully_flattened)
                                                        as &dyn Value))])
                        });
                } else { ; }
            };
            Ok(fully_flattened)
        }
    }
}#[instrument(level = "debug", skip(self))]
286    fn confirm_transmutability_candidate(
287        &mut self,
288        obligation: &PolyTraitObligation<'tcx>,
289    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
290        use rustc_transmute::{Answer, Assume, Condition};
291
292        /// Flatten the `Condition` tree into a conjunction of obligations.
293        #[instrument(level = "debug", skip(tcx, obligation))]
294        fn flatten_answer_tree<'tcx>(
295            tcx: TyCtxt<'tcx>,
296            obligation: &PolyTraitObligation<'tcx>,
297            cond: Condition<Region<'tcx>, Ty<'tcx>>,
298            assume: Assume,
299        ) -> PredicateObligations<'tcx> {
300            match cond {
301                // FIXME(bryangarza): Add separate `IfAny` case, instead of treating as `IfAll`
302                // Not possible until the trait solver supports disjunctions of obligations
303                Condition::IfAll(conds) | Condition::IfAny(conds) => conds
304                    .into_iter()
305                    .flat_map(|cond| flatten_answer_tree(tcx, obligation, cond, assume))
306                    .collect(),
307                Condition::Immutable { ty } => {
308                    let trait_ref = ty::TraitRef::new(
309                        tcx,
310                        tcx.require_lang_item(LangItem::Freeze, obligation.cause.span),
311                        [ty::GenericArg::from(ty)],
312                    );
313                    thin_vec![Obligation::with_depth(
314                        tcx,
315                        obligation.cause.clone(),
316                        obligation.recursion_depth + 1,
317                        obligation.param_env,
318                        trait_ref,
319                    )]
320                }
321                Condition::Outlives { long, short } => {
322                    let outlives = ty::OutlivesPredicate(long, short);
323                    thin_vec![Obligation::with_depth(
324                        tcx,
325                        obligation.cause.clone(),
326                        obligation.recursion_depth + 1,
327                        obligation.param_env,
328                        outlives,
329                    )]
330                }
331                Condition::Transmutable { src, dst } => {
332                    let transmute_trait = obligation.predicate.def_id();
333                    let assume = obligation.predicate.skip_binder().trait_ref.args.const_at(2);
334                    let trait_ref = ty::TraitRef::new(
335                        tcx,
336                        transmute_trait,
337                        [
338                            ty::GenericArg::from(dst),
339                            ty::GenericArg::from(src),
340                            ty::GenericArg::from(assume),
341                        ],
342                    );
343                    thin_vec![Obligation::with_depth(
344                        tcx,
345                        obligation.cause.clone(),
346                        obligation.recursion_depth + 1,
347                        obligation.param_env,
348                        trait_ref,
349                    )]
350                }
351            }
352        }
353
354        let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
355
356        let mut assume = predicate.trait_ref.args.const_at(2);
357        if self.tcx().features().generic_const_exprs() {
358            assume = crate::traits::evaluate_const(self.infcx, assume, obligation.param_env)
359        }
360        let Some(assume) = rustc_transmute::Assume::from_const(self.infcx.tcx, assume) else {
361            return Err(SelectionError::Unimplemented);
362        };
363
364        let dst = predicate.trait_ref.args.type_at(0);
365        let src = predicate.trait_ref.args.type_at(1);
366
367        debug!(?src, ?dst);
368        let mut transmute_env = rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx);
369        let maybe_transmutable = transmute_env.is_transmutable(src, dst, assume);
370
371        let fully_flattened = match maybe_transmutable {
372            Answer::No(_) => Err(SelectionError::Unimplemented)?,
373            Answer::If(cond) => flatten_answer_tree(self.tcx(), obligation, cond, assume),
374            Answer::Yes => PredicateObligations::new(),
375        };
376
377        debug!(?fully_flattened);
378        Ok(fully_flattened)
379    }
380
381    /// This handles the case where an `auto trait Foo` impl is being used.
382    /// The idea is that the impl applies to `X : Foo` if the following conditions are met:
383    ///
384    /// 1. For each constituent type `Y` in `X`, `Y : Foo` holds
385    /// 2. For each where-clause `C` declared on `Foo`, `[Self => X] C` holds.
386    fn confirm_auto_impl_candidate(
387        &mut self,
388        obligation: &PolyTraitObligation<'tcx>,
389    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
390        ensure_sufficient_stack(|| {
391            match (&obligation.predicate.polarity(), &ty::PredicatePolarity::Positive) {
    (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);
        }
    }
};assert_eq!(obligation.predicate.polarity(), ty::PredicatePolarity::Positive);
392
393            let self_ty =
394                obligation.predicate.self_ty().map_bound(|ty| self.infcx.shallow_resolve(ty));
395            let self_ty = self.infcx.enter_forall_and_leak_universe(self_ty);
396
397            let constituents = self.constituent_types_for_auto_trait(self_ty)?;
398            let constituents = self.infcx.enter_forall_and_leak_universe(constituents);
399
400            let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
401            let mut obligations = self.collect_predicates_for_types(
402                obligation.param_env,
403                cause.clone(),
404                obligation.recursion_depth + 1,
405                obligation.predicate.def_id(),
406                constituents.types,
407            );
408
409            // Only normalize these goals if `-Zhigher-ranked-assumptions` is enabled, since
410            // we don't want to cause ourselves to do extra work if we're not even able to
411            // take advantage of these assumption clauses.
412            if self.tcx().sess.opts.unstable_opts.higher_ranked_assumptions {
413                // FIXME(coroutine_clone): We could uplift this into `collect_predicates_for_types`
414                // and do this for `Copy`/`Clone` too, but that's feature-gated so it doesn't really
415                // matter yet.
416                for assumption in constituents.assumptions {
417                    let assumption = normalize_with_depth_to(
418                        self,
419                        obligation.param_env,
420                        cause.clone(),
421                        obligation.recursion_depth + 1,
422                        assumption,
423                        &mut obligations,
424                    );
425                    self.infcx.register_region_assumption(assumption);
426                }
427            }
428
429            Ok(obligations)
430        })
431    }
432
433    fn confirm_impl_candidate(
434        &mut self,
435        obligation: &PolyTraitObligation<'tcx>,
436        impl_def_id: DefId,
437    ) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>> {
438        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:438",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(438u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "obligation", "impl_def_id"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("confirm_impl_candidate")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&obligation)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&impl_def_id)
                                            as &dyn Value))])
            });
    } else { ; }
};debug!(?obligation, ?impl_def_id, "confirm_impl_candidate");
439
440        // First, create the generic parameters by matching the impl again,
441        // this time not in a probe.
442        let args = self.rematch_impl(impl_def_id, obligation);
443        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:443",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(443u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message", "args"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("impl args")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&args) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?args, "impl args");
444        ensure_sufficient_stack(|| {
445            self.vtable_impl(
446                impl_def_id,
447                args,
448                &obligation.cause,
449                obligation.recursion_depth + 1,
450                obligation.param_env,
451                obligation.predicate,
452            )
453        })
454    }
455
456    fn vtable_impl(
457        &mut self,
458        impl_def_id: DefId,
459        args: Normalized<'tcx, GenericArgsRef<'tcx>>,
460        cause: &ObligationCause<'tcx>,
461        recursion_depth: usize,
462        param_env: ty::ParamEnv<'tcx>,
463        parent_trait_pred: ty::Binder<'tcx, ty::TraitPredicate<'tcx>>,
464    ) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>> {
465        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:465",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(465u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "impl_def_id", "args", "recursion_depth"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("vtable_impl")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&impl_def_id)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&args) as
                                            &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&recursion_depth)
                                            as &dyn Value))])
            });
    } else { ; }
};debug!(?impl_def_id, ?args, ?recursion_depth, "vtable_impl");
466
467        let mut impl_obligations = self.impl_or_trait_obligations(
468            cause,
469            recursion_depth,
470            param_env,
471            impl_def_id,
472            args.value,
473            parent_trait_pred,
474        );
475
476        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:476",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(476u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "impl_obligations"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("vtable_impl")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&impl_obligations)
                                            as &dyn Value))])
            });
    } else { ; }
};debug!(?impl_obligations, "vtable_impl");
477
478        // Because of RFC447, the impl-trait-ref and obligations
479        // are sufficient to determine the impl args, without
480        // relying on projections in the impl-trait-ref.
481        //
482        // e.g., `impl<U: Tr, V: Iterator<Item=U>> Foo<<U as Tr>::T> for V`
483        impl_obligations.extend(args.obligations);
484
485        ImplSourceUserDefinedData { impl_def_id, args: args.value, nested: impl_obligations }
486    }
487
488    fn confirm_object_candidate(
489        &mut self,
490        obligation: &PolyTraitObligation<'tcx>,
491        index: usize,
492    ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
493        let tcx = self.tcx();
494        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:494",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(494u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "obligation", "index"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("confirm_object_candidate")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&obligation)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&index) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?obligation, ?index, "confirm_object_candidate");
495
496        let trait_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
497        let self_ty = self.infcx.shallow_resolve(trait_predicate.self_ty());
498        let ty::Dynamic(data, ..) = *self_ty.kind() else {
499            ::rustc_middle::util::bug::span_bug_fmt(obligation.cause.span,
    format_args!("object candidate with non-object"));span_bug!(obligation.cause.span, "object candidate with non-object");
500        };
501
502        let object_trait_ref = data.principal().unwrap_or_else(|| {
503            ::rustc_middle::util::bug::span_bug_fmt(obligation.cause.span,
    format_args!("object candidate with no principal"))span_bug!(obligation.cause.span, "object candidate with no principal")
504        });
505        let object_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
506            obligation.cause.span,
507            BoundRegionConversionTime::HigherRankedType,
508            object_trait_ref,
509        );
510        let object_trait_ref = object_trait_ref.with_self_ty(self.tcx(), self_ty);
511
512        let mut nested = PredicateObligations::new();
513
514        let mut supertraits = util::supertraits(tcx, ty::Binder::dummy(object_trait_ref));
515        let unnormalized_upcast_trait_ref =
516            supertraits.nth(index).expect("supertraits iterator no longer has as many elements");
517
518        let upcast_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
519            obligation.cause.span,
520            BoundRegionConversionTime::HigherRankedType,
521            unnormalized_upcast_trait_ref,
522        );
523        let upcast_trait_ref = normalize_with_depth_to(
524            self,
525            obligation.param_env,
526            obligation.cause.clone(),
527            obligation.recursion_depth + 1,
528            upcast_trait_ref,
529            &mut nested,
530        );
531
532        nested.extend(
533            self.infcx
534                .at(&obligation.cause, obligation.param_env)
535                .eq(DefineOpaqueTypes::No, trait_predicate.trait_ref, upcast_trait_ref)
536                .map(|InferOk { obligations, .. }| obligations)
537                .map_err(|_| SelectionError::Unimplemented)?,
538        );
539
540        // Check supertraits hold. This is so that their associated type bounds
541        // will be checked in the code below.
542        for (supertrait, _) in tcx
543            .explicit_super_predicates_of(trait_predicate.def_id())
544            .iter_instantiated_copied(tcx, trait_predicate.trait_ref.args)
545        {
546            let normalized_supertrait = normalize_with_depth_to(
547                self,
548                obligation.param_env,
549                obligation.cause.clone(),
550                obligation.recursion_depth + 1,
551                supertrait,
552                &mut nested,
553            );
554            nested.push(obligation.with(tcx, normalized_supertrait));
555        }
556
557        let assoc_types: Vec<_> = tcx
558            .associated_items(trait_predicate.def_id())
559            .in_definition_order()
560            // Associated types that require `Self: Sized` do not show up in the built-in
561            // implementation of `Trait for dyn Trait`, and can be dropped here.
562            .filter(|item| !tcx.generics_require_sized_self(item.def_id))
563            .filter_map(|item| if item.is_type() { Some(item.def_id) } else { None })
564            .collect();
565
566        for assoc_type in assoc_types {
567            let defs: &ty::Generics = tcx.generics_of(assoc_type);
568
569            if !defs.own_params.is_empty() {
570                tcx.dcx().span_delayed_bug(
571                    obligation.cause.span,
572                    "GATs in trait object shouldn't have been considered",
573                );
574                return Err(SelectionError::TraitDynIncompatible(trait_predicate.trait_ref.def_id));
575            }
576
577            // This maybe belongs in wf, but that can't (doesn't) handle
578            // higher-ranked things.
579            // Prevent, e.g., `dyn Iterator<Item = str>`.
580            for bound in self.tcx().item_bounds(assoc_type).transpose_iter() {
581                let normalized_bound = normalize_with_depth_to(
582                    self,
583                    obligation.param_env,
584                    obligation.cause.clone(),
585                    obligation.recursion_depth + 1,
586                    bound.instantiate(tcx, trait_predicate.trait_ref.args),
587                    &mut nested,
588                );
589                nested.push(obligation.with(tcx, normalized_bound));
590            }
591        }
592
593        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:593",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(593u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message", "nested"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("object nested obligations")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&nested) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?nested, "object nested obligations");
594
595        Ok(ImplSource::Builtin(BuiltinImplSource::Object(index), nested))
596    }
597
598    fn confirm_fn_pointer_candidate(
599        &mut self,
600        obligation: &PolyTraitObligation<'tcx>,
601    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
602        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:602",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(602u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "obligation"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("confirm_fn_pointer_candidate")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&obligation)
                                            as &dyn Value))])
            });
    } else { ; }
};debug!(?obligation, "confirm_fn_pointer_candidate");
603        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
604        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
605
606        let tcx = self.tcx();
607        let sig = self_ty.fn_sig(tcx);
608        let trait_ref = closure_trait_ref_and_return_type(
609            tcx,
610            obligation.predicate.def_id(),
611            self_ty,
612            sig,
613            util::TupleArgumentsFlag::Yes,
614        )
615        .map_bound(|(trait_ref, _)| trait_ref);
616
617        let mut nested =
618            self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?;
619        let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
620
621        // Confirm the `type Output: Sized;` bound that is present on `FnOnce`
622        let output_ty = self.infcx.enter_forall_and_leak_universe(sig.output());
623        let output_ty = normalize_with_depth_to(
624            self,
625            obligation.param_env,
626            cause.clone(),
627            obligation.recursion_depth,
628            output_ty,
629            &mut nested,
630        );
631        let tr = ty::TraitRef::new(
632            self.tcx(),
633            self.tcx().require_lang_item(LangItem::Sized, cause.span),
634            [output_ty],
635        );
636        nested.push(Obligation::new(self.infcx.tcx, cause, obligation.param_env, tr));
637
638        Ok(nested)
639    }
640
641    fn confirm_pointer_like_candidate(
642        &mut self,
643        obligation: &PolyTraitObligation<'tcx>,
644    ) -> PredicateObligations<'tcx> {
645        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:645",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(645u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "obligation"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("confirm_pointer_like_candidate")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&obligation)
                                            as &dyn Value))])
            });
    } else { ; }
};debug!(?obligation, "confirm_pointer_like_candidate");
646        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
647        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
648        let ty::Pat(base, _) = *self_ty.kind() else { ::rustc_middle::util::bug::bug_fmt(format_args!("impossible case reached"))bug!() };
649        let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
650
651        self.collect_predicates_for_types(
652            obligation.param_env,
653            cause,
654            obligation.recursion_depth + 1,
655            placeholder_predicate.def_id(),
656            ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [base]))vec![base],
657        )
658    }
659
660    fn confirm_trait_alias_candidate(
661        &mut self,
662        obligation: &PolyTraitObligation<'tcx>,
663    ) -> PredicateObligations<'tcx> {
664        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:664",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(664u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "obligation"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("confirm_trait_alias_candidate")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&obligation)
                                            as &dyn Value))])
            });
    } else { ; }
};debug!(?obligation, "confirm_trait_alias_candidate");
665
666        let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
667        let trait_ref = predicate.trait_ref;
668        let trait_def_id = trait_ref.def_id;
669        let args = trait_ref.args;
670
671        let trait_obligations = self.impl_or_trait_obligations(
672            &obligation.cause,
673            obligation.recursion_depth,
674            obligation.param_env,
675            trait_def_id,
676            args,
677            obligation.predicate,
678        );
679
680        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:680",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(680u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "trait_def_id", "trait_obligations"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("trait alias obligations")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&trait_def_id)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&trait_obligations)
                                            as &dyn Value))])
            });
    } else { ; }
};debug!(?trait_def_id, ?trait_obligations, "trait alias obligations");
681
682        trait_obligations
683    }
684
685    fn confirm_coroutine_candidate(
686        &mut self,
687        obligation: &PolyTraitObligation<'tcx>,
688    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
689        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
690        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
691        let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
692            ::rustc_middle::util::bug::bug_fmt(format_args!("closure candidate for non-closure {0:?}",
        obligation));bug!("closure candidate for non-closure {:?}", obligation);
693        };
694
695        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:695",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(695u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "obligation", "coroutine_def_id", "args"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("confirm_coroutine_candidate")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&obligation)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&coroutine_def_id)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&args) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_coroutine_candidate");
696
697        let coroutine_sig = args.as_coroutine().sig();
698
699        let (trait_ref, _, _) = super::util::coroutine_trait_ref_and_outputs(
700            self.tcx(),
701            obligation.predicate.def_id(),
702            self_ty,
703            coroutine_sig,
704        );
705
706        let nested = self.equate_trait_refs(
707            obligation.with(self.tcx(), placeholder_predicate),
708            ty::Binder::dummy(trait_ref),
709        )?;
710        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:710",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(710u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "trait_ref", "nested"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("coroutine candidate obligations")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&trait_ref)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&nested) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?trait_ref, ?nested, "coroutine candidate obligations");
711
712        Ok(nested)
713    }
714
715    fn confirm_future_candidate(
716        &mut self,
717        obligation: &PolyTraitObligation<'tcx>,
718    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
719        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
720        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
721        let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
722            ::rustc_middle::util::bug::bug_fmt(format_args!("closure candidate for non-closure {0:?}",
        obligation));bug!("closure candidate for non-closure {:?}", obligation);
723        };
724
725        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:725",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(725u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "obligation", "coroutine_def_id", "args"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("confirm_future_candidate")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&obligation)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&coroutine_def_id)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&args) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_future_candidate");
726
727        let coroutine_sig = args.as_coroutine().sig();
728
729        let (trait_ref, _) = super::util::future_trait_ref_and_outputs(
730            self.tcx(),
731            obligation.predicate.def_id(),
732            self_ty,
733            coroutine_sig,
734        );
735
736        let nested = self.equate_trait_refs(
737            obligation.with(self.tcx(), placeholder_predicate),
738            ty::Binder::dummy(trait_ref),
739        )?;
740        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:740",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(740u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "trait_ref", "nested"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("future candidate obligations")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&trait_ref)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&nested) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?trait_ref, ?nested, "future candidate obligations");
741
742        Ok(nested)
743    }
744
745    fn confirm_iterator_candidate(
746        &mut self,
747        obligation: &PolyTraitObligation<'tcx>,
748    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
749        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
750        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
751        let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
752            ::rustc_middle::util::bug::bug_fmt(format_args!("closure candidate for non-closure {0:?}",
        obligation));bug!("closure candidate for non-closure {:?}", obligation);
753        };
754
755        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:755",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(755u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "obligation", "coroutine_def_id", "args"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("confirm_iterator_candidate")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&obligation)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&coroutine_def_id)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&args) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_iterator_candidate");
756
757        let gen_sig = args.as_coroutine().sig();
758
759        let (trait_ref, _) = super::util::iterator_trait_ref_and_outputs(
760            self.tcx(),
761            obligation.predicate.def_id(),
762            self_ty,
763            gen_sig,
764        );
765
766        let nested = self.equate_trait_refs(
767            obligation.with(self.tcx(), placeholder_predicate),
768            ty::Binder::dummy(trait_ref),
769        )?;
770        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:770",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(770u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "trait_ref", "nested"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("iterator candidate obligations")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&trait_ref)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&nested) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?trait_ref, ?nested, "iterator candidate obligations");
771
772        Ok(nested)
773    }
774
775    fn confirm_async_iterator_candidate(
776        &mut self,
777        obligation: &PolyTraitObligation<'tcx>,
778    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
779        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
780        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
781        let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
782            ::rustc_middle::util::bug::bug_fmt(format_args!("closure candidate for non-closure {0:?}",
        obligation));bug!("closure candidate for non-closure {:?}", obligation);
783        };
784
785        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:785",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(785u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "obligation", "coroutine_def_id", "args"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("confirm_async_iterator_candidate")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&obligation)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&coroutine_def_id)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&args) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_async_iterator_candidate");
786
787        let gen_sig = args.as_coroutine().sig();
788
789        let (trait_ref, _) = super::util::async_iterator_trait_ref_and_outputs(
790            self.tcx(),
791            obligation.predicate.def_id(),
792            self_ty,
793            gen_sig,
794        );
795
796        let nested = self.equate_trait_refs(
797            obligation.with(self.tcx(), placeholder_predicate),
798            ty::Binder::dummy(trait_ref),
799        )?;
800        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:800",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(800u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        "trait_ref", "nested"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("iterator candidate obligations")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&trait_ref)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&nested) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?trait_ref, ?nested, "iterator candidate obligations");
801
802        Ok(nested)
803    }
804
805    #[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("confirm_closure_candidate",
                                    "rustc_trait_selection::traits::select::confirmation",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(805u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&["obligation"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn 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>, SelectionError<'tcx>> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            let placeholder_predicate =
                self.infcx.enter_forall_and_leak_universe(obligation.predicate);
            let self_ty: Ty<'_> =
                self.infcx.shallow_resolve(placeholder_predicate.self_ty());
            let trait_ref =
                match *self_ty.kind() {
                    ty::Closure(..) => {
                        self.closure_trait_ref_unnormalized(self_ty,
                            obligation.predicate.def_id())
                    }
                    ty::CoroutineClosure(_, args) => {
                        args.as_coroutine_closure().coroutine_closure_sig().map_bound(|sig|
                                {
                                    ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(),
                                        [self_ty, sig.tupled_inputs_ty])
                                })
                    }
                    _ => {
                        ::rustc_middle::util::bug::bug_fmt(format_args!("closure candidate for non-closure {0:?}",
                                obligation));
                    }
                };
            self.equate_trait_refs(obligation.with(self.tcx(),
                    placeholder_predicate), trait_ref)
        }
    }
}#[instrument(skip(self), level = "debug")]
806    fn confirm_closure_candidate(
807        &mut self,
808        obligation: &PolyTraitObligation<'tcx>,
809    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
810        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
811        let self_ty: Ty<'_> = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
812
813        let trait_ref = match *self_ty.kind() {
814            ty::Closure(..) => {
815                self.closure_trait_ref_unnormalized(self_ty, obligation.predicate.def_id())
816            }
817            ty::CoroutineClosure(_, args) => {
818                args.as_coroutine_closure().coroutine_closure_sig().map_bound(|sig| {
819                    ty::TraitRef::new(
820                        self.tcx(),
821                        obligation.predicate.def_id(),
822                        [self_ty, sig.tupled_inputs_ty],
823                    )
824                })
825            }
826            _ => {
827                bug!("closure candidate for non-closure {:?}", obligation);
828            }
829        };
830
831        self.equate_trait_refs(obligation.with(self.tcx(), placeholder_predicate), trait_ref)
832    }
833
834    #[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("confirm_async_closure_candidate",
                                    "rustc_trait_selection::traits::select::confirmation",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(834u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&["obligation"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn 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>, SelectionError<'tcx>> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            let placeholder_predicate =
                self.infcx.enter_forall_and_leak_universe(obligation.predicate);
            let self_ty =
                self.infcx.shallow_resolve(placeholder_predicate.self_ty());
            let tcx = self.tcx();
            let mut nested = PredicateObligations::new();
            let (trait_ref, kind_ty) =
                match *self_ty.kind() {
                    ty::CoroutineClosure(_, args) => {
                        let args = args.as_coroutine_closure();
                        let trait_ref =
                            args.coroutine_closure_sig().map_bound(|sig|
                                    {
                                        ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(),
                                            [self_ty, sig.tupled_inputs_ty])
                                    });
                        (trait_ref, args.kind_ty())
                    }
                    ty::FnDef(..) | ty::FnPtr(..) => {
                        let sig = self_ty.fn_sig(tcx);
                        let trait_ref =
                            sig.map_bound(|sig|
                                    {
                                        ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(),
                                            [self_ty, Ty::new_tup(tcx, sig.inputs())])
                                    });
                        let future_trait_def_id =
                            tcx.require_lang_item(LangItem::Future,
                                obligation.cause.span);
                        nested.push(obligation.with(tcx,
                                sig.output().map_bound(|output_ty|
                                        {
                                            ty::TraitRef::new(tcx, future_trait_def_id, [output_ty])
                                        })));
                        let sized_trait_def_id =
                            tcx.require_lang_item(LangItem::Sized,
                                obligation.cause.span);
                        nested.push(obligation.with(tcx,
                                sig.output().map_bound(|output_ty|
                                        {
                                            ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
                                        })));
                        (trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn))
                    }
                    ty::Closure(_, args) => {
                        let args = args.as_closure();
                        let sig = args.sig();
                        let trait_ref =
                            sig.map_bound(|sig|
                                    {
                                        ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(),
                                            [self_ty, sig.inputs()[0]])
                                    });
                        let future_trait_def_id =
                            tcx.require_lang_item(LangItem::Future,
                                obligation.cause.span);
                        let placeholder_output_ty =
                            self.infcx.enter_forall_and_leak_universe(sig.output());
                        nested.push(obligation.with(tcx,
                                ty::TraitRef::new(tcx, future_trait_def_id,
                                    [placeholder_output_ty])));
                        let sized_trait_def_id =
                            tcx.require_lang_item(LangItem::Sized,
                                obligation.cause.span);
                        nested.push(obligation.with(tcx,
                                sig.output().map_bound(|output_ty|
                                        {
                                            ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
                                        })));
                        (trait_ref, args.kind_ty())
                    }
                    _ =>
                        ::rustc_middle::util::bug::bug_fmt(format_args!("expected callable type for AsyncFn candidate")),
                };
            nested.extend(self.equate_trait_refs(obligation.with(tcx,
                            placeholder_predicate), trait_ref)?);
            let goal_kind =
                self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
            if let Some(closure_kind) =
                    self.infcx.shallow_resolve(kind_ty).to_opt_closure_kind() {
                if !closure_kind.extends(goal_kind) {
                    return Err(SelectionError::Unimplemented);
                }
            } else {
                nested.push(Obligation::new(self.tcx(),
                        obligation.derived_cause(ObligationCauseCode::BuiltinDerived),
                        obligation.param_env,
                        ty::TraitRef::new(self.tcx(),
                            self.tcx().require_lang_item(LangItem::AsyncFnKindHelper,
                                obligation.cause.span),
                            [kind_ty, Ty::from_closure_kind(self.tcx(), goal_kind)])));
            }
            Ok(nested)
        }
    }
}#[instrument(skip(self), level = "debug")]
835    fn confirm_async_closure_candidate(
836        &mut self,
837        obligation: &PolyTraitObligation<'tcx>,
838    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
839        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
840        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
841
842        let tcx = self.tcx();
843
844        let mut nested = PredicateObligations::new();
845        let (trait_ref, kind_ty) = match *self_ty.kind() {
846            ty::CoroutineClosure(_, args) => {
847                let args = args.as_coroutine_closure();
848                let trait_ref = args.coroutine_closure_sig().map_bound(|sig| {
849                    ty::TraitRef::new(
850                        self.tcx(),
851                        obligation.predicate.def_id(),
852                        [self_ty, sig.tupled_inputs_ty],
853                    )
854                });
855
856                // Note that unlike below, we don't need to check `Future + Sized` for
857                // the output coroutine because they are `Future + Sized` by construction.
858
859                (trait_ref, args.kind_ty())
860            }
861            ty::FnDef(..) | ty::FnPtr(..) => {
862                let sig = self_ty.fn_sig(tcx);
863                let trait_ref = sig.map_bound(|sig| {
864                    ty::TraitRef::new(
865                        self.tcx(),
866                        obligation.predicate.def_id(),
867                        [self_ty, Ty::new_tup(tcx, sig.inputs())],
868                    )
869                });
870
871                // We must additionally check that the return type impls `Future + Sized`.
872                let future_trait_def_id =
873                    tcx.require_lang_item(LangItem::Future, obligation.cause.span);
874                nested.push(obligation.with(
875                    tcx,
876                    sig.output().map_bound(|output_ty| {
877                        ty::TraitRef::new(tcx, future_trait_def_id, [output_ty])
878                    }),
879                ));
880                let sized_trait_def_id =
881                    tcx.require_lang_item(LangItem::Sized, obligation.cause.span);
882                nested.push(obligation.with(
883                    tcx,
884                    sig.output().map_bound(|output_ty| {
885                        ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
886                    }),
887                ));
888
889                (trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn))
890            }
891            ty::Closure(_, args) => {
892                let args = args.as_closure();
893                let sig = args.sig();
894                let trait_ref = sig.map_bound(|sig| {
895                    ty::TraitRef::new(
896                        self.tcx(),
897                        obligation.predicate.def_id(),
898                        [self_ty, sig.inputs()[0]],
899                    )
900                });
901
902                // We must additionally check that the return type impls `Future + Sized`.
903                let future_trait_def_id =
904                    tcx.require_lang_item(LangItem::Future, obligation.cause.span);
905                let placeholder_output_ty = self.infcx.enter_forall_and_leak_universe(sig.output());
906                nested.push(obligation.with(
907                    tcx,
908                    ty::TraitRef::new(tcx, future_trait_def_id, [placeholder_output_ty]),
909                ));
910                let sized_trait_def_id =
911                    tcx.require_lang_item(LangItem::Sized, obligation.cause.span);
912                nested.push(obligation.with(
913                    tcx,
914                    sig.output().map_bound(|output_ty| {
915                        ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
916                    }),
917                ));
918
919                (trait_ref, args.kind_ty())
920            }
921            _ => bug!("expected callable type for AsyncFn candidate"),
922        };
923
924        nested.extend(
925            self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?,
926        );
927
928        let goal_kind =
929            self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
930
931        // If we have not yet determined the `ClosureKind` of the closure or coroutine-closure,
932        // then additionally register an `AsyncFnKindHelper` goal which will fail if the kind
933        // is constrained to an insufficient type later on.
934        if let Some(closure_kind) = self.infcx.shallow_resolve(kind_ty).to_opt_closure_kind() {
935            if !closure_kind.extends(goal_kind) {
936                return Err(SelectionError::Unimplemented);
937            }
938        } else {
939            nested.push(Obligation::new(
940                self.tcx(),
941                obligation.derived_cause(ObligationCauseCode::BuiltinDerived),
942                obligation.param_env,
943                ty::TraitRef::new(
944                    self.tcx(),
945                    self.tcx()
946                        .require_lang_item(LangItem::AsyncFnKindHelper, obligation.cause.span),
947                    [kind_ty, Ty::from_closure_kind(self.tcx(), goal_kind)],
948                ),
949            ));
950        }
951
952        Ok(nested)
953    }
954
955    /// In the case of closure types and fn pointers,
956    /// we currently treat the input type parameters on the trait as
957    /// outputs. This means that when we have a match we have only
958    /// considered the self type, so we have to go back and make sure
959    /// to relate the argument types too. This is kind of wrong, but
960    /// since we control the full set of impls, also not that wrong,
961    /// and it DOES yield better error messages (since we don't report
962    /// errors as if there is no applicable impl, but rather report
963    /// errors are about mismatched argument types.
964    ///
965    /// Here is an example. Imagine we have a closure expression
966    /// and we desugared it so that the type of the expression is
967    /// `Closure`, and `Closure` expects `i32` as argument. Then it
968    /// is "as if" the compiler generated this impl:
969    /// ```ignore (illustrative)
970    /// impl Fn(i32) for Closure { ... }
971    /// ```
972    /// Now imagine our obligation is `Closure: Fn(usize)`. So far
973    /// we have matched the self type `Closure`. At this point we'll
974    /// compare the `i32` to `usize` and generate an error.
975    ///
976    /// Note that this checking occurs *after* the impl has selected,
977    /// because these output type parameters should not affect the
978    /// selection of the impl. Therefore, if there is a mismatch, we
979    /// report an error to the user.
980    #[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() ||
            { false } {
        __tracing_attr_span =
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("equate_trait_refs",
                                    "rustc_trait_selection::traits::select::confirmation",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(980u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&["obligation",
                                                    "found_trait_ref"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&found_trait_ref)
                                                            as &dyn 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>, SelectionError<'tcx>> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            let found_trait_ref =
                self.infcx.instantiate_binder_with_fresh_vars(obligation.cause.span,
                    BoundRegionConversionTime::HigherRankedType,
                    found_trait_ref);
            let Normalized {
                    obligations: nested,
                    value: (obligation_trait_ref, found_trait_ref) } =
                ensure_sufficient_stack(||
                        {
                            normalize_with_depth(self, obligation.param_env,
                                obligation.cause.clone(), obligation.recursion_depth + 1,
                                (obligation.predicate.trait_ref, found_trait_ref))
                        });
            self.infcx.at(&obligation.cause,
                            obligation.param_env).eq(DefineOpaqueTypes::Yes,
                        obligation_trait_ref,
                        found_trait_ref).map(|InferOk { mut obligations, .. }|
                        {
                            obligations.extend(nested);
                            obligations
                        }).map_err(|terr|
                    {
                        SelectionError::SignatureMismatch(Box::new(SignatureMismatchData {
                                    expected_trait_ref: obligation_trait_ref,
                                    found_trait_ref,
                                    terr,
                                }))
                    })
        }
    }
}#[instrument(skip(self), level = "trace")]
981    fn equate_trait_refs(
982        &mut self,
983        obligation: TraitObligation<'tcx>,
984        found_trait_ref: ty::PolyTraitRef<'tcx>,
985    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
986        let found_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
987            obligation.cause.span,
988            BoundRegionConversionTime::HigherRankedType,
989            found_trait_ref,
990        );
991        // Normalize the obligation and expected trait refs together, because why not
992        let Normalized { obligations: nested, value: (obligation_trait_ref, found_trait_ref) } =
993            ensure_sufficient_stack(|| {
994                normalize_with_depth(
995                    self,
996                    obligation.param_env,
997                    obligation.cause.clone(),
998                    obligation.recursion_depth + 1,
999                    (obligation.predicate.trait_ref, found_trait_ref),
1000                )
1001            });
1002
1003        // needed to define opaque types for tests/ui/type-alias-impl-trait/assoc-projection-ice.rs
1004        self.infcx
1005            .at(&obligation.cause, obligation.param_env)
1006            .eq(DefineOpaqueTypes::Yes, obligation_trait_ref, found_trait_ref)
1007            .map(|InferOk { mut obligations, .. }| {
1008                obligations.extend(nested);
1009                obligations
1010            })
1011            .map_err(|terr| {
1012                SelectionError::SignatureMismatch(Box::new(SignatureMismatchData {
1013                    expected_trait_ref: obligation_trait_ref,
1014                    found_trait_ref,
1015                    terr,
1016                }))
1017            })
1018    }
1019
1020    fn confirm_trait_upcasting_unsize_candidate(
1021        &mut self,
1022        obligation: &PolyTraitObligation<'tcx>,
1023        idx: usize,
1024    ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
1025        let tcx = self.tcx();
1026
1027        // `assemble_candidates_for_unsizing` should ensure there are no late-bound
1028        // regions here. See the comment there for more details.
1029        let predicate = obligation.predicate.no_bound_vars().unwrap();
1030        let a_ty = self.infcx.shallow_resolve(predicate.self_ty());
1031        let b_ty = self.infcx.shallow_resolve(predicate.trait_ref.args.type_at(1));
1032
1033        let ty::Dynamic(a_data, a_region) = *a_ty.kind() else {
1034            ::rustc_middle::util::bug::bug_fmt(format_args!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`"))bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
1035        };
1036        let ty::Dynamic(b_data, b_region) = *b_ty.kind() else {
1037            ::rustc_middle::util::bug::bug_fmt(format_args!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`"))bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
1038        };
1039
1040        let source_principal = a_data.principal().unwrap().with_self_ty(tcx, a_ty);
1041        let unnormalized_upcast_principal =
1042            util::supertraits(tcx, source_principal).nth(idx).unwrap();
1043
1044        let nested = self
1045            .match_upcast_principal(
1046                obligation,
1047                unnormalized_upcast_principal,
1048                a_data,
1049                b_data,
1050                a_region,
1051                b_region,
1052            )?
1053            .expect("did not expect ambiguity during confirmation");
1054
1055        Ok(ImplSource::Builtin(BuiltinImplSource::TraitUpcasting(idx), nested))
1056    }
1057
1058    fn confirm_builtin_unsize_candidate(
1059        &mut self,
1060        obligation: &PolyTraitObligation<'tcx>,
1061    ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
1062        let tcx = self.tcx();
1063
1064        // `assemble_candidates_for_unsizing` should ensure there are no late-bound
1065        // regions here. See the comment there for more details.
1066        let source = self.infcx.shallow_resolve(obligation.self_ty().no_bound_vars().unwrap());
1067        let target = obligation.predicate.skip_binder().trait_ref.args.type_at(1);
1068        let target = self.infcx.shallow_resolve(target);
1069        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:1069",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(1069u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message", "source",
                                        "target"],
                            ::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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("confirm_builtin_unsize_candidate")
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&source) as
                                            &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&target) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?source, ?target, "confirm_builtin_unsize_candidate");
1070
1071        Ok(match (source.kind(), target.kind()) {
1072            // `dyn Trait + Kx + 'a` -> `dyn Trait + Ky + 'b` (auto traits and lifetime subtyping).
1073            (&ty::Dynamic(data_a, r_a), &ty::Dynamic(data_b, r_b)) => {
1074                // See `assemble_candidates_for_unsizing` for more info.
1075                // We already checked the compatibility of auto traits within `assemble_candidates_for_unsizing`.
1076                let existential_predicates = if data_b.principal().is_some() {
1077                    tcx.mk_poly_existential_predicates_from_iter(
1078                        data_a
1079                            .principal()
1080                            .map(|b| b.map_bound(ty::ExistentialPredicate::Trait))
1081                            .into_iter()
1082                            .chain(
1083                                data_a
1084                                    .projection_bounds()
1085                                    .map(|b| b.map_bound(ty::ExistentialPredicate::Projection)),
1086                            )
1087                            .chain(
1088                                data_b
1089                                    .auto_traits()
1090                                    .map(ty::ExistentialPredicate::AutoTrait)
1091                                    .map(ty::Binder::dummy),
1092                            ),
1093                    )
1094                } else {
1095                    // If we're unsizing to a dyn type that has no principal, then drop
1096                    // the principal and projections from the type. We use the auto traits
1097                    // from the RHS type since as we noted that we've checked for auto
1098                    // trait compatibility during unsizing.
1099                    tcx.mk_poly_existential_predicates_from_iter(
1100                        data_b
1101                            .auto_traits()
1102                            .map(ty::ExistentialPredicate::AutoTrait)
1103                            .map(ty::Binder::dummy),
1104                    )
1105                };
1106                let source_trait = Ty::new_dynamic(tcx, existential_predicates, r_b);
1107
1108                // Require that the traits involved in this upcast are **equal**;
1109                // only the **lifetime bound** is changed.
1110                let InferOk { mut obligations, .. } = self
1111                    .infcx
1112                    .at(&obligation.cause, obligation.param_env)
1113                    .sup(DefineOpaqueTypes::Yes, target, source_trait)
1114                    .map_err(|_| SelectionError::Unimplemented)?;
1115
1116                // Register one obligation for 'a: 'b.
1117                let outlives = ty::OutlivesPredicate(r_a, r_b);
1118                obligations.push(Obligation::with_depth(
1119                    tcx,
1120                    obligation.cause.clone(),
1121                    obligation.recursion_depth + 1,
1122                    obligation.param_env,
1123                    obligation.predicate.rebind(outlives),
1124                ));
1125
1126                ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1127            }
1128
1129            // `T` -> `dyn Trait`
1130            (_, &ty::Dynamic(data, r)) => {
1131                let mut object_dids = data.auto_traits().chain(data.principal_def_id());
1132                if let Some(did) = object_dids.find(|did| !tcx.is_dyn_compatible(*did)) {
1133                    return Err(SelectionError::TraitDynIncompatible(did));
1134                }
1135
1136                let predicate_to_obligation = |predicate| {
1137                    Obligation::with_depth(
1138                        tcx,
1139                        obligation.cause.clone(),
1140                        obligation.recursion_depth + 1,
1141                        obligation.param_env,
1142                        predicate,
1143                    )
1144                };
1145
1146                // Create obligations:
1147                //  - Casting `T` to `Trait`
1148                //  - For all the various builtin bounds attached to the object cast. (In other
1149                //  words, if the object type is `Foo + Send`, this would create an obligation for
1150                //  the `Send` check.)
1151                //  - Projection predicates
1152                let mut nested: PredicateObligations<'_> = data
1153                    .iter()
1154                    .map(|predicate| predicate_to_obligation(predicate.with_self_ty(tcx, source)))
1155                    .collect();
1156
1157                // We can only make objects from sized types.
1158                let tr = ty::TraitRef::new(
1159                    tcx,
1160                    tcx.require_lang_item(LangItem::Sized, obligation.cause.span),
1161                    [source],
1162                );
1163                nested.push(predicate_to_obligation(tr.upcast(tcx)));
1164
1165                // If the type is `Foo + 'a`, ensure that the type
1166                // being cast to `Foo + 'a` outlives `'a`:
1167                let outlives = ty::OutlivesPredicate(source, r);
1168                nested.push(predicate_to_obligation(
1169                    ty::ClauseKind::TypeOutlives(outlives).upcast(tcx),
1170                ));
1171
1172                ImplSource::Builtin(BuiltinImplSource::Misc, nested)
1173            }
1174
1175            // `[T; n]` -> `[T]`
1176            (&ty::Array(a, _), &ty::Slice(b)) => {
1177                let InferOk { obligations, .. } = self
1178                    .infcx
1179                    .at(&obligation.cause, obligation.param_env)
1180                    .eq(DefineOpaqueTypes::Yes, b, a)
1181                    .map_err(|_| SelectionError::Unimplemented)?;
1182
1183                ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1184            }
1185
1186            // `Struct<T>` -> `Struct<U>`
1187            (&ty::Adt(def, args_a), &ty::Adt(_, args_b)) => {
1188                let unsizing_params = tcx.unsizing_params_for_adt(def.did());
1189                if unsizing_params.is_empty() {
1190                    return Err(SelectionError::Unimplemented);
1191                }
1192
1193                let tail_field = def.non_enum_variant().tail();
1194                let tail_field_ty = tcx.type_of(tail_field.did);
1195
1196                let mut nested = PredicateObligations::new();
1197
1198                // Extract `TailField<T>` and `TailField<U>` from `Struct<T>` and `Struct<U>`,
1199                // normalizing in the process, since `type_of` returns something directly from
1200                // HIR ty lowering (which means it's un-normalized).
1201                let source_tail = normalize_with_depth_to(
1202                    self,
1203                    obligation.param_env,
1204                    obligation.cause.clone(),
1205                    obligation.recursion_depth + 1,
1206                    tail_field_ty.instantiate(tcx, args_a),
1207                    &mut nested,
1208                );
1209                let target_tail = normalize_with_depth_to(
1210                    self,
1211                    obligation.param_env,
1212                    obligation.cause.clone(),
1213                    obligation.recursion_depth + 1,
1214                    tail_field_ty.instantiate(tcx, args_b),
1215                    &mut nested,
1216                );
1217
1218                // Check that the source struct with the target's
1219                // unsizing parameters is equal to the target.
1220                let args =
1221                    tcx.mk_args_from_iter(args_a.iter().enumerate().map(|(i, k)| {
1222                        if unsizing_params.contains(i as u32) { args_b[i] } else { k }
1223                    }));
1224                let new_struct = Ty::new_adt(tcx, def, args);
1225                let InferOk { obligations, .. } = self
1226                    .infcx
1227                    .at(&obligation.cause, obligation.param_env)
1228                    .eq(DefineOpaqueTypes::Yes, target, new_struct)
1229                    .map_err(|_| SelectionError::Unimplemented)?;
1230                nested.extend(obligations);
1231
1232                // Construct the nested `TailField<T>: Unsize<TailField<U>>` predicate.
1233                let tail_unsize_obligation = obligation.with(
1234                    tcx,
1235                    ty::TraitRef::new(
1236                        tcx,
1237                        obligation.predicate.def_id(),
1238                        [source_tail, target_tail],
1239                    ),
1240                );
1241                nested.push(tail_unsize_obligation);
1242
1243                ImplSource::Builtin(BuiltinImplSource::Misc, nested)
1244            }
1245
1246            _ => ::rustc_middle::util::bug::bug_fmt(format_args!("source: {0}, target: {1}",
        source, target))bug!("source: {source}, target: {target}"),
1247        })
1248    }
1249
1250    /// This trait is indirectly exposed on stable, so do *not* extend the set of types that
1251    /// implement the trait without FCP!
1252    fn confirm_bikeshed_guaranteed_no_drop_candidate(
1253        &mut self,
1254        obligation: &PolyTraitObligation<'tcx>,
1255    ) -> ImplSource<'tcx, PredicateObligation<'tcx>> {
1256        let mut obligations = ::thin_vec::ThinVec::new()thin_vec![];
1257
1258        let tcx = self.tcx();
1259        let self_ty = obligation.predicate.self_ty();
1260        match *self_ty.skip_binder().kind() {
1261            // `&mut T` and `&T` always implement `BikeshedGuaranteedNoDrop`.
1262            ty::Ref(..) => {}
1263            // `ManuallyDrop<T>` always implements `BikeshedGuaranteedNoDrop`.
1264            ty::Adt(def, _) if def.is_manually_drop() => {}
1265            // Arrays and tuples implement `BikeshedGuaranteedNoDrop` only if
1266            // their constituent types implement `BikeshedGuaranteedNoDrop`.
1267            ty::Tuple(tys) => {
1268                obligations.extend(tys.iter().map(|elem_ty| {
1269                    obligation.with(
1270                        tcx,
1271                        self_ty.rebind(ty::TraitRef::new(
1272                            tcx,
1273                            obligation.predicate.def_id(),
1274                            [elem_ty],
1275                        )),
1276                    )
1277                }));
1278            }
1279            ty::Array(elem_ty, _) => {
1280                obligations.push(obligation.with(
1281                    tcx,
1282                    self_ty.rebind(ty::TraitRef::new(
1283                        tcx,
1284                        obligation.predicate.def_id(),
1285                        [elem_ty],
1286                    )),
1287                ));
1288            }
1289
1290            // All other types implement `BikeshedGuaranteedNoDrop` only if
1291            // they implement `Copy`. We could be smart here and short-circuit
1292            // some trivially `Copy`/`!Copy` types, but there's no benefit.
1293            ty::FnDef(..)
1294            | ty::FnPtr(..)
1295            | ty::Error(_)
1296            | ty::Uint(_)
1297            | ty::Int(_)
1298            | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1299            | ty::Bool
1300            | ty::Float(_)
1301            | ty::Char
1302            | ty::RawPtr(..)
1303            | ty::Never
1304            | ty::Pat(..)
1305            | ty::Dynamic(..)
1306            | ty::Str
1307            | ty::Slice(_)
1308            | ty::Foreign(..)
1309            | ty::Adt(..)
1310            | ty::Alias(..)
1311            | ty::Param(_)
1312            | ty::Placeholder(..)
1313            | ty::Closure(..)
1314            | ty::CoroutineClosure(..)
1315            | ty::Coroutine(..)
1316            | ty::UnsafeBinder(_)
1317            | ty::CoroutineWitness(..)
1318            | ty::Bound(..) => {
1319                obligations.push(obligation.with(
1320                    tcx,
1321                    self_ty.map_bound(|ty| {
1322                        ty::TraitRef::new(
1323                            tcx,
1324                            tcx.require_lang_item(LangItem::Copy, obligation.cause.span),
1325                            [ty],
1326                        )
1327                    }),
1328                ));
1329            }
1330
1331            ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1332                {
    ::core::panicking::panic_fmt(format_args!("unexpected type `{0:?}`",
            self_ty));
}panic!("unexpected type `{self_ty:?}`")
1333            }
1334        }
1335
1336        ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1337    }
1338}