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_attr_ir::lang_items::LangItem;
13use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk};
14use rustc_infer::traits::ObligationCauseCode;
15use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData};
16use rustc_middle::ty::{self, GenericArgsRef, SizedTraitKind, Ty, Unnormalized, Upcast};
17use rustc_next_trait_solver::solve::flatten_answer_tree;
18use rustc_span::def_id::DefId;
19use rustc_span::{bug, span_bug};
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("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/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(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("obligation");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("candidate")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("candidate");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    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)
                    }
                    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)
                    }
                    TryAsDynCandidate =>
                        self.confirm_try_as_dyn_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            TraitAliasCandidate => {
119                let data = self.confirm_trait_alias_candidate(obligation);
120                ImplSource::Builtin(BuiltinImplSource::Misc, data)
121            }
122
123            BuiltinObjectCandidate => {
124                // This indicates something like `Trait + Send: Send`. In this case, we know that
125                // this holds because that's what the object type is telling us, and there's really
126                // no additional obligations to prove and no types in particular to unify, etc.
127                ImplSource::Builtin(BuiltinImplSource::Misc, PredicateObligations::new())
128            }
129
130            BuiltinUnsizeCandidate => self.confirm_builtin_unsize_candidate(obligation)?,
131
132            TraitUpcastingUnsizeCandidate(idx) => {
133                self.confirm_trait_upcasting_unsize_candidate(obligation, idx)?
134            }
135
136            BikeshedGuaranteedNoDropCandidate => {
137                self.confirm_bikeshed_guaranteed_no_drop_candidate(obligation)
138            }
139
140            TryAsDynCandidate => self.confirm_try_as_dyn_candidate(obligation),
141        })
142    }
143
144    fn confirm_projection_candidate(
145        &mut self,
146        obligation: &PolyTraitObligation<'tcx>,
147        idx: usize,
148    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
149        let placeholder_trait_predicate =
150            self.infcx.enter_forall_and_leak_universe(obligation.predicate).trait_ref;
151        let placeholder_self_ty = self.infcx.shallow_resolve(placeholder_trait_predicate.self_ty());
152        let candidate_predicate = self
153            .for_each_item_bound(
154                placeholder_self_ty,
155                |_, clause, clause_idx, _| {
156                    if clause_idx == idx {
157                        ControlFlow::Break(clause)
158                    } else {
159                        ControlFlow::Continue(())
160                    }
161                },
162                || ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
163            )
164            .break_value()
165            .expect("expected to index into clause that exists");
166        let candidate_predicate = candidate_predicate
167            .as_trait_clause()
168            .expect("projection candidate is not a trait predicate");
169        let candidate_predicate =
170            util::lazily_elaborate_sizedness_candidate(self.infcx, obligation, candidate_predicate);
171
172        let candidate = candidate_predicate.map_bound(|t| t.trait_ref);
173
174        let candidate = self.infcx.instantiate_binder_with_fresh_vars(
175            obligation.cause.span,
176            BoundRegionConversionTime::HigherRankedType,
177            candidate,
178        );
179        let mut obligations = PredicateObligations::new();
180        let candidate = normalize_with_depth_to(
181            self,
182            obligation.param_env,
183            obligation.cause.clone(),
184            obligation.recursion_depth + 1,
185            ty::Unnormalized::new_wip(candidate),
186            &mut obligations,
187        );
188
189        obligations.extend(
190            self.infcx
191                .at(&obligation.cause, obligation.param_env)
192                .eq(DefineOpaqueTypes::No, placeholder_trait_predicate, candidate)
193                .map(|InferOk { obligations, .. }| obligations)
194                .map_err(|_| SelectionError::Unimplemented)?,
195        );
196
197        Ok(obligations)
198    }
199
200    fn confirm_param_candidate(
201        &mut self,
202        obligation: &PolyTraitObligation<'tcx>,
203        param: ty::PolyTraitRef<'tcx>,
204    ) -> PredicateObligations<'tcx> {
205        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:205",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(205u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("param")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("param");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_param_candidate")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&param)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?obligation, ?param, "confirm_param_candidate");
206
207        let param = util::lazily_elaborate_sizedness_candidate(
208            self.infcx,
209            obligation,
210            param.upcast(self.infcx.tcx),
211        )
212        .map_bound(|p| p.trait_ref);
213
214        // During evaluation, we already checked that this
215        // where-clause trait-ref could be unified with the obligation
216        // trait-ref. Repeat that unification now without any
217        // transactional boundary; it should not fail.
218        match self.match_where_clause_trait_ref(obligation, param) {
219            Ok(obligations) => obligations,
220            Err(()) => {
221                ::rustc_span::macros::bug_impl(None,
    format_args!("Where clause `{0:?}` was applicable to `{1:?}` but now is not",
        param, obligation), Location::caller());bug!(
222                    "Where clause `{:?}` was applicable to `{:?}` but now is not",
223                    param,
224                    obligation
225                );
226            }
227        }
228    }
229
230    {}
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_builtin_candidate",
                                "rustc_trait_selection::traits::select::confirmation",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                ::tracing_core::__macro_support::Option::Some(230u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("obligation")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("obligation");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: PredicateObligations<'tcx> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:235",
                                                "rustc_trait_selection::traits::select::confirmation",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                                ::tracing_core::__macro_support::Option::Some(235u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                                ::tracing_core::field::FieldSet::new(&["message",
                                                                {
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("obligation")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("obligation");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_builtin_candidate")
                                                                    as &dyn ::tracing::field::Value)),
                                                        (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let tcx = self.tcx();
                        let trait_def = obligation.predicate.def_id();
                        let self_ty =
                            self.infcx.shallow_resolve(self.infcx.enter_forall_and_leak_universe(obligation.predicate.self_ty()));
                        let types =
                            match tcx.as_lang_item(trait_def) {
                                Some(LangItem::Sized) =>
                                    self.sizedness_conditions(self_ty, SizedTraitKind::Sized),
                                Some(LangItem::MetaSized) => {
                                    self.sizedness_conditions(self_ty,
                                        SizedTraitKind::MetaSized)
                                }
                                Some(LangItem::PointeeSized) => {
                                    ::rustc_span::macros::bug_impl(None,
                                        format_args!("`PointeeSized` is removing during lowering"),
                                        Location::caller());
                                }
                                Some(LangItem::Copy | LangItem::Clone |
                                    LangItem::TrivialClone) => {
                                    self.copy_clone_conditions(self_ty)
                                }
                                Some(LangItem::FusedIterator) => {
                                    if self.coroutine_is_gen(self_ty) {
                                        ty::Binder::dummy(::alloc::vec::Vec::new())
                                    } else {
                                        {
                                            ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
                                                    format_args!("tried to assemble `FusedIterator` for non-gen coroutine")));
                                        };
                                    }
                                }
                                Some(LangItem::Destruct | LangItem::DiscriminantKind |
                                    LangItem::Field | LangItem::FnPtrTrait |
                                    LangItem::PointeeTrait | LangItem::Tuple | LangItem::Unpin)
                                    => ty::Binder::dummy(::alloc::vec::Vec::new()),
                                other =>
                                    ::rustc_span::macros::bug_impl(None,
                                        format_args!("unexpected builtin trait {0:?} ({1:?})",
                                            trait_def, other), Location::caller()),
                            };
                        let types =
                            self.infcx.enter_forall_and_leak_universe(types);
                        let cause =
                            obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
                        self.collect_predicates_for_types(obligation.param_env,
                            cause, obligation.recursion_depth + 1, trait_def, types)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:230",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(230u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
231    fn confirm_builtin_candidate(
232        &mut self,
233        obligation: &PolyTraitObligation<'tcx>,
234    ) -> PredicateObligations<'tcx> {
235        debug!(?obligation, "confirm_builtin_candidate");
236        let tcx = self.tcx();
237        let trait_def = obligation.predicate.def_id();
238        let self_ty = self.infcx.shallow_resolve(
239            self.infcx.enter_forall_and_leak_universe(obligation.predicate.self_ty()),
240        );
241        let types = match tcx.as_lang_item(trait_def) {
242            Some(LangItem::Sized) => self.sizedness_conditions(self_ty, SizedTraitKind::Sized),
243            Some(LangItem::MetaSized) => {
244                self.sizedness_conditions(self_ty, SizedTraitKind::MetaSized)
245            }
246            Some(LangItem::PointeeSized) => {
247                bug!("`PointeeSized` is removing during lowering");
248            }
249            Some(LangItem::Copy | LangItem::Clone | LangItem::TrivialClone) => {
250                self.copy_clone_conditions(self_ty)
251            }
252            Some(LangItem::FusedIterator) => {
253                if self.coroutine_is_gen(self_ty) {
254                    ty::Binder::dummy(vec![])
255                } else {
256                    unreachable!("tried to assemble `FusedIterator` for non-gen coroutine");
257                }
258            }
259            Some(
260                LangItem::Destruct
261                | LangItem::DiscriminantKind
262                | LangItem::Field
263                | LangItem::FnPtrTrait
264                | LangItem::PointeeTrait
265                | LangItem::Tuple
266                | LangItem::Unpin,
267            ) => ty::Binder::dummy(vec![]),
268            other => bug!("unexpected builtin trait {trait_def:?} ({other:?})"),
269        };
270        let types = self.infcx.enter_forall_and_leak_universe(types);
271
272        let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
273        self.collect_predicates_for_types(
274            obligation.param_env,
275            cause,
276            obligation.recursion_depth + 1,
277            trait_def,
278            types,
279        )
280    }
281
282    {}
#[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("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(282u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("obligation");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    Result<PredicateObligations<'tcx>, SelectionError<'tcx>> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            use rustc_middle::ty::transmute::Answer;
            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 /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:302",
                                    "rustc_trait_selection::traits::select::confirmation",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(302u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("src")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("src");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("dst")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("dst");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&src)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dst)
                                                        as &dyn ::tracing::field::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(_) => return Err(SelectionError::Unimplemented),
                    Answer::Yes => PredicateObligations::new(),
                    Answer::If(cond) => {
                        flatten_answer_tree(self.tcx(),
                                        obligation.predicate.skip_binder(),
                                        cond).into_iter().map(|predicate|
                                    {
                                        Obligation::new(self.infcx.tcx, obligation.cause.clone(),
                                            obligation.param_env, predicate)
                                    }).collect()
                    }
                };
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:324",
                                    "rustc_trait_selection::traits::select::confirmation",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(324u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("fully_flattened")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("fully_flattened");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fully_flattened)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            Ok(fully_flattened)
        }
    }
}#[instrument(level = "debug", skip(self))]
283    fn confirm_transmutability_candidate(
284        &mut self,
285        obligation: &PolyTraitObligation<'tcx>,
286    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
287        use rustc_middle::ty::transmute::Answer;
288
289        let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
290
291        let mut assume = predicate.trait_ref.args.const_at(2);
292        if self.tcx().features().generic_const_exprs() {
293            assume = crate::traits::evaluate_const(self.infcx, assume, obligation.param_env)
294        }
295        let Some(assume) = rustc_transmute::Assume::from_const(self.infcx.tcx, assume) else {
296            return Err(SelectionError::Unimplemented);
297        };
298
299        let dst = predicate.trait_ref.args.type_at(0);
300        let src = predicate.trait_ref.args.type_at(1);
301
302        debug!(?src, ?dst);
303        let mut transmute_env = rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx);
304        let maybe_transmutable = transmute_env.is_transmutable(src, dst, assume);
305
306        let fully_flattened = match maybe_transmutable {
307            Answer::No(_) => return Err(SelectionError::Unimplemented),
308            Answer::Yes => PredicateObligations::new(),
309            Answer::If(cond) => {
310                flatten_answer_tree(self.tcx(), obligation.predicate.skip_binder(), cond)
311                    .into_iter()
312                    .map(|predicate| {
313                        Obligation::new(
314                            self.infcx.tcx,
315                            obligation.cause.clone(),
316                            obligation.param_env,
317                            predicate,
318                        )
319                    })
320                    .collect()
321            }
322        };
323
324        debug!(?fully_flattened);
325        Ok(fully_flattened)
326    }
327
328    /// This handles the case where an `auto trait Foo` impl is being used.
329    /// The idea is that the impl applies to `X : Foo` if the following conditions are met:
330    ///
331    /// 1. For each constituent type `Y` in `X`, `Y : Foo` holds
332    /// 2. For each where-clause `C` declared on `Foo`, `[Self => X] C` holds.
333    fn confirm_auto_impl_candidate(
334        &mut self,
335        obligation: &PolyTraitObligation<'tcx>,
336    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
337        {
    match (&obligation.predicate.polarity(), &ty::ClausePolarity::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::ClausePolarity::Positive);
338
339        let self_ty = obligation.predicate.self_ty().map_bound(|ty| self.infcx.shallow_resolve(ty));
340        let self_ty = self.infcx.enter_forall_and_leak_universe(self_ty);
341
342        let constituents = self.constituent_types_for_auto_trait(self_ty)?;
343        let constituents = self.infcx.enter_forall_and_leak_universe(constituents);
344
345        let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
346        let mut obligations = self.collect_predicates_for_types(
347            obligation.param_env,
348            cause.clone(),
349            obligation.recursion_depth + 1,
350            obligation.predicate.def_id(),
351            constituents.types,
352        );
353
354        // Only normalize these goals if `-Zhigher-ranked-assumptions` is enabled, since
355        // we don't want to cause ourselves to do extra work if we're not even able to
356        // take advantage of these assumption clauses.
357        if self.tcx().sess.opts.unstable_opts.higher_ranked_assumptions {
358            // FIXME(coroutine_clone): We could uplift this into `collect_predicates_for_types`
359            // and do this for `Copy`/`Clone` too, but that's feature-gated so it doesn't really
360            // matter yet.
361            for assumption in constituents.assumptions {
362                let assumption = normalize_with_depth_to(
363                    self,
364                    obligation.param_env,
365                    cause.clone(),
366                    obligation.recursion_depth + 1,
367                    Unnormalized::new_wip(assumption),
368                    &mut obligations,
369                );
370                self.infcx.register_region_assumption(assumption);
371            }
372        }
373
374        Ok(obligations)
375    }
376
377    fn confirm_impl_candidate(
378        &mut self,
379        obligation: &PolyTraitObligation<'tcx>,
380        impl_def_id: DefId,
381    ) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>> {
382        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:382",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(382u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("impl_def_id")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("impl_def_id");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_impl_candidate")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_def_id)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?obligation, ?impl_def_id, "confirm_impl_candidate");
383
384        // First, create the generic parameters by matching the impl again,
385        // this time not in a probe.
386        let args = self.rematch_impl(impl_def_id, obligation);
387        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:387",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(387u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("args")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("args");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("impl args")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?args, "impl args");
388
389        self.vtable_impl(
390            impl_def_id,
391            args,
392            &obligation.cause,
393            obligation.recursion_depth + 1,
394            obligation.param_env,
395            obligation.predicate,
396        )
397    }
398
399    fn vtable_impl(
400        &mut self,
401        impl_def_id: DefId,
402        args: Normalized<'tcx, GenericArgsRef<'tcx>>,
403        cause: &ObligationCause<'tcx>,
404        recursion_depth: usize,
405        param_env: ty::ParamEnv<'tcx>,
406        parent_trait_pred: ty::Binder<'tcx, ty::TraitClause<'tcx>>,
407    ) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>> {
408        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:408",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(408u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("impl_def_id")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("impl_def_id");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("args")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("args");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("recursion_depth")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("recursion_depth");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("vtable_impl")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_def_id)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&recursion_depth)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?impl_def_id, ?args, ?recursion_depth, "vtable_impl");
409
410        let mut impl_obligations = self.impl_or_trait_obligations(
411            cause,
412            recursion_depth,
413            param_env,
414            impl_def_id,
415            args.value,
416            parent_trait_pred,
417        );
418
419        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:419",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(419u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("impl_obligations")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("impl_obligations");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("vtable_impl")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_obligations)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?impl_obligations, "vtable_impl");
420
421        // Because of RFC447, the impl-trait-ref and obligations
422        // are sufficient to determine the impl args, without
423        // relying on projections in the impl-trait-ref.
424        //
425        // e.g., `impl<U: Tr, V: Iterator<Item=U>> Foo<<U as Tr>::T> for V`
426        impl_obligations.extend(args.obligations);
427
428        ImplSourceUserDefinedData { impl_def_id, args: args.value, nested: impl_obligations }
429    }
430
431    fn confirm_object_candidate(
432        &mut self,
433        obligation: &PolyTraitObligation<'tcx>,
434        index: usize,
435    ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
436        let tcx = self.tcx();
437        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:437",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(437u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("index")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("index");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_object_candidate")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&index)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?obligation, ?index, "confirm_object_candidate");
438
439        let trait_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
440        let self_ty = self.infcx.shallow_resolve(trait_predicate.self_ty());
441        let ty::Dynamic(data, ..) = *self_ty.kind() else {
442            ::rustc_span::macros::bug_impl(Some(obligation.cause.span),
    format_args!("object candidate with non-object"), Location::caller());span_bug!(obligation.cause.span, "object candidate with non-object");
443        };
444
445        let object_trait_ref = data.principal().unwrap_or_else(|| {
446            ::rustc_span::macros::bug_impl(Some(obligation.cause.span),
    format_args!("object candidate with no principal"), Location::caller())span_bug!(obligation.cause.span, "object candidate with no principal")
447        });
448        let object_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
449            obligation.cause.span,
450            BoundRegionConversionTime::HigherRankedType,
451            object_trait_ref,
452        );
453        let object_trait_ref = object_trait_ref.with_self_ty(self.tcx(), self_ty);
454
455        let mut nested = PredicateObligations::new();
456
457        let mut supertraits = util::supertraits(tcx, ty::Binder::dummy(object_trait_ref));
458        let unnormalized_upcast_trait_ref =
459            supertraits.nth(index).expect("supertraits iterator no longer has as many elements");
460
461        let upcast_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
462            obligation.cause.span,
463            BoundRegionConversionTime::HigherRankedType,
464            unnormalized_upcast_trait_ref,
465        );
466        let upcast_trait_ref = normalize_with_depth_to(
467            self,
468            obligation.param_env,
469            obligation.cause.clone(),
470            obligation.recursion_depth + 1,
471            ty::Unnormalized::new_wip(upcast_trait_ref),
472            &mut nested,
473        );
474
475        nested.extend(
476            self.infcx
477                .at(&obligation.cause, obligation.param_env)
478                .eq(DefineOpaqueTypes::No, trait_predicate.trait_ref, upcast_trait_ref)
479                .map(|InferOk { obligations, .. }| obligations)
480                .map_err(|_| SelectionError::Unimplemented)?,
481        );
482
483        // Check supertraits hold. This is so that their associated type bounds
484        // will be checked in the code below.
485        for supertrait in tcx
486            .explicit_super_clauses_of(trait_predicate.def_id())
487            .iter_instantiated_copied(tcx, trait_predicate.trait_ref.args)
488            .map(|clause| clause.unzip().0)
489        {
490            let normalized_supertrait = normalize_with_depth_to(
491                self,
492                obligation.param_env,
493                obligation.cause.clone(),
494                obligation.recursion_depth + 1,
495                supertrait,
496                &mut nested,
497            );
498            nested.push(obligation.with(tcx, normalized_supertrait));
499        }
500
501        let assoc_types: Vec<_> = tcx
502            .associated_items(trait_predicate.def_id())
503            .in_definition_order()
504            // Associated types that require `Self: Sized` do not show up in the built-in
505            // implementation of `Trait for dyn Trait`, and can be dropped here.
506            .filter(|item| !tcx.generics_require_sized_self(item.def_id))
507            .filter_map(|item| if item.is_type() { Some(item.def_id) } else { None })
508            .collect();
509
510        for assoc_type in assoc_types {
511            let defs: &ty::Generics = tcx.generics_of(assoc_type);
512
513            if !defs.own_params.is_empty() {
514                tcx.dcx().span_delayed_bug(
515                    obligation.cause.span,
516                    "GATs in trait object shouldn't have been considered",
517                );
518                return Err(SelectionError::TraitDynIncompatible(trait_predicate.trait_ref.def_id));
519            }
520
521            // This maybe belongs in wf, but that can't (doesn't) handle
522            // higher-ranked things.
523            // Prevent, e.g., `dyn Iterator<Item = str>`.
524            for bound in self.tcx().item_bounds(assoc_type).transpose_iter() {
525                let normalized_bound = normalize_with_depth_to(
526                    self,
527                    obligation.param_env,
528                    obligation.cause.clone(),
529                    obligation.recursion_depth + 1,
530                    bound.instantiate(tcx, trait_predicate.trait_ref.args),
531                    &mut nested,
532                );
533                nested.push(obligation.with(tcx, normalized_bound));
534            }
535        }
536
537        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:537",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(537u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("nested")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("nested");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("object nested obligations")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&nested)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?nested, "object nested obligations");
538
539        Ok(ImplSource::Builtin(BuiltinImplSource::Object(index), nested))
540    }
541
542    fn confirm_fn_pointer_candidate(
543        &mut self,
544        obligation: &PolyTraitObligation<'tcx>,
545    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
546        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:546",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(546u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_fn_pointer_candidate")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?obligation, "confirm_fn_pointer_candidate");
547        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
548        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
549
550        let tcx = self.tcx();
551        let sig = self_ty.unnormalized_fn_sig(tcx);
552        let output_ty = sig.map(|sig| self.infcx.enter_forall_and_leak_universe(sig.output()));
553        let sig = sig.skip_norm_wip();
554        let trait_ref = closure_trait_ref_and_return_type(
555            tcx,
556            obligation.predicate.def_id(),
557            self_ty,
558            sig,
559            util::TupleArgumentsFlag::Yes,
560        )
561        .map_bound(|(trait_ref, _)| trait_ref);
562
563        let mut nested =
564            self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?;
565        let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
566
567        // Confirm the `type Output: Sized;` bound that is present on `FnOnce`
568        let output_ty = normalize_with_depth_to(
569            self,
570            obligation.param_env,
571            cause.clone(),
572            obligation.recursion_depth,
573            output_ty,
574            &mut nested,
575        );
576        let tr = ty::TraitRef::new(
577            self.tcx(),
578            self.tcx().require_lang_item(LangItem::Sized, cause.span),
579            [output_ty],
580        );
581        nested.push(Obligation::new(self.infcx.tcx, cause, obligation.param_env, tr));
582
583        Ok(nested)
584    }
585
586    fn confirm_trait_alias_candidate(
587        &mut self,
588        obligation: &PolyTraitObligation<'tcx>,
589    ) -> PredicateObligations<'tcx> {
590        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:590",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(590u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_trait_alias_candidate")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?obligation, "confirm_trait_alias_candidate");
591
592        let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
593        let trait_ref = predicate.trait_ref;
594        let trait_def_id = trait_ref.def_id;
595        let args = trait_ref.args;
596
597        let trait_obligations = self.impl_or_trait_obligations(
598            &obligation.cause,
599            obligation.recursion_depth,
600            obligation.param_env,
601            trait_def_id,
602            args,
603            obligation.predicate,
604        );
605
606        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:606",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(606u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("trait_def_id")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("trait_def_id");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("trait_obligations")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("trait_obligations");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("trait alias obligations")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_def_id)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_obligations)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?trait_def_id, ?trait_obligations, "trait alias obligations");
607
608        trait_obligations
609    }
610
611    fn confirm_coroutine_candidate(
612        &mut self,
613        obligation: &PolyTraitObligation<'tcx>,
614    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
615        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
616        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
617        let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
618            ::rustc_span::macros::bug_impl(None,
    format_args!("closure candidate for non-closure {0:?}", obligation),
    Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
619        };
620
621        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:621",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(621u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("coroutine_def_id")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("coroutine_def_id");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("args")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("args");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_coroutine_candidate")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coroutine_def_id)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_coroutine_candidate");
622
623        let coroutine_sig = args.as_coroutine().sig();
624
625        let (trait_ref, _, _) = super::util::coroutine_trait_ref_and_outputs(
626            self.tcx(),
627            obligation.predicate.def_id(),
628            self_ty,
629            coroutine_sig,
630        );
631
632        let nested = self.equate_trait_refs(
633            obligation.with(self.tcx(), placeholder_predicate),
634            ty::Binder::dummy(trait_ref),
635        )?;
636        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:636",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(636u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("trait_ref")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("trait_ref");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("nested")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("nested");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("coroutine candidate obligations")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&nested)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?trait_ref, ?nested, "coroutine candidate obligations");
637
638        Ok(nested)
639    }
640
641    fn confirm_future_candidate(
642        &mut self,
643        obligation: &PolyTraitObligation<'tcx>,
644    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
645        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
646        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
647        let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
648            ::rustc_span::macros::bug_impl(None,
    format_args!("closure candidate for non-closure {0:?}", obligation),
    Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
649        };
650
651        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:651",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(651u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("coroutine_def_id")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("coroutine_def_id");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("args")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("args");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_future_candidate")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coroutine_def_id)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_future_candidate");
652
653        let coroutine_sig = args.as_coroutine().sig();
654
655        let (trait_ref, _) = super::util::future_trait_ref_and_outputs(
656            self.tcx(),
657            obligation.predicate.def_id(),
658            self_ty,
659            coroutine_sig,
660        );
661
662        let nested = self.equate_trait_refs(
663            obligation.with(self.tcx(), placeholder_predicate),
664            ty::Binder::dummy(trait_ref),
665        )?;
666        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:666",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(666u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("trait_ref")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("trait_ref");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("nested")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("nested");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("future candidate obligations")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&nested)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?trait_ref, ?nested, "future candidate obligations");
667
668        Ok(nested)
669    }
670
671    fn confirm_iterator_candidate(
672        &mut self,
673        obligation: &PolyTraitObligation<'tcx>,
674    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
675        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
676        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
677        let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
678            ::rustc_span::macros::bug_impl(None,
    format_args!("closure candidate for non-closure {0:?}", obligation),
    Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
679        };
680
681        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:681",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(681u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("coroutine_def_id")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("coroutine_def_id");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("args")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("args");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_iterator_candidate")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coroutine_def_id)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_iterator_candidate");
682
683        let gen_sig = args.as_coroutine().sig();
684
685        let (trait_ref, _) = super::util::iterator_trait_ref_and_outputs(
686            self.tcx(),
687            obligation.predicate.def_id(),
688            self_ty,
689            gen_sig,
690        );
691
692        let nested = self.equate_trait_refs(
693            obligation.with(self.tcx(), placeholder_predicate),
694            ty::Binder::dummy(trait_ref),
695        )?;
696        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:696",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(696u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("trait_ref")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("trait_ref");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("nested")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("nested");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("iterator candidate obligations")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&nested)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?trait_ref, ?nested, "iterator candidate obligations");
697
698        Ok(nested)
699    }
700
701    fn confirm_async_iterator_candidate(
702        &mut self,
703        obligation: &PolyTraitObligation<'tcx>,
704    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
705        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
706        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
707        let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
708            ::rustc_span::macros::bug_impl(None,
    format_args!("closure candidate for non-closure {0:?}", obligation),
    Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
709        };
710
711        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:711",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(711u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("coroutine_def_id")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("coroutine_def_id");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("args")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("args");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_async_iterator_candidate")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coroutine_def_id)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_async_iterator_candidate");
712
713        let gen_sig = args.as_coroutine().sig();
714
715        let (trait_ref, _) = super::util::async_iterator_trait_ref_and_outputs(
716            self.tcx(),
717            obligation.predicate.def_id(),
718            self_ty,
719            gen_sig,
720        );
721
722        let nested = self.equate_trait_refs(
723            obligation.with(self.tcx(), placeholder_predicate),
724            ty::Binder::dummy(trait_ref),
725        )?;
726        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:726",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(726u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("trait_ref")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("trait_ref");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("nested")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("nested");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("iterator candidate obligations")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&nested)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?trait_ref, ?nested, "iterator candidate obligations");
727
728        Ok(nested)
729    }
730
731    {}
#[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("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(731u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("obligation");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    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_span::macros::bug_impl(None,
                            format_args!("closure candidate for non-closure {0:?}",
                                obligation), Location::caller());
                    }
                };
            self.equate_trait_refs(obligation.with(self.tcx(),
                    placeholder_predicate), trait_ref)
        }
    }
}#[instrument(skip(self), level = "debug")]
732    fn confirm_closure_candidate(
733        &mut self,
734        obligation: &PolyTraitObligation<'tcx>,
735    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
736        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
737        let self_ty: Ty<'_> = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
738
739        let trait_ref = match *self_ty.kind() {
740            ty::Closure(..) => {
741                self.closure_trait_ref_unnormalized(self_ty, obligation.predicate.def_id())
742            }
743            ty::CoroutineClosure(_, args) => {
744                args.as_coroutine_closure().coroutine_closure_sig().map_bound(|sig| {
745                    ty::TraitRef::new(
746                        self.tcx(),
747                        obligation.predicate.def_id(),
748                        [self_ty, sig.tupled_inputs_ty],
749                    )
750                })
751            }
752            _ => {
753                bug!("closure candidate for non-closure {:?}", obligation);
754            }
755        };
756
757        self.equate_trait_refs(obligation.with(self.tcx(), placeholder_predicate), trait_ref)
758    }
759
760    {}
#[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("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(760u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("obligation");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    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_span::macros::bug_impl(None,
                            format_args!("expected callable type for AsyncFn candidate"),
                            Location::caller()),
                };
            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")]
761    fn confirm_async_closure_candidate(
762        &mut self,
763        obligation: &PolyTraitObligation<'tcx>,
764    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
765        let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
766        let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
767
768        let tcx = self.tcx();
769
770        let mut nested = PredicateObligations::new();
771        let (trait_ref, kind_ty) = match *self_ty.kind() {
772            ty::CoroutineClosure(_, args) => {
773                let args = args.as_coroutine_closure();
774                let trait_ref = args.coroutine_closure_sig().map_bound(|sig| {
775                    ty::TraitRef::new(
776                        self.tcx(),
777                        obligation.predicate.def_id(),
778                        [self_ty, sig.tupled_inputs_ty],
779                    )
780                });
781
782                // Note that unlike below, we don't need to check `Future + Sized` for
783                // the output coroutine because they are `Future + Sized` by construction.
784
785                (trait_ref, args.kind_ty())
786            }
787            ty::FnDef(..) | ty::FnPtr(..) => {
788                let sig = self_ty.fn_sig(tcx);
789                let trait_ref = sig.map_bound(|sig| {
790                    ty::TraitRef::new(
791                        self.tcx(),
792                        obligation.predicate.def_id(),
793                        [self_ty, Ty::new_tup(tcx, sig.inputs())],
794                    )
795                });
796
797                // We must additionally check that the return type impls `Future + Sized`.
798                let future_trait_def_id =
799                    tcx.require_lang_item(LangItem::Future, obligation.cause.span);
800                nested.push(obligation.with(
801                    tcx,
802                    sig.output().map_bound(|output_ty| {
803                        ty::TraitRef::new(tcx, future_trait_def_id, [output_ty])
804                    }),
805                ));
806                let sized_trait_def_id =
807                    tcx.require_lang_item(LangItem::Sized, obligation.cause.span);
808                nested.push(obligation.with(
809                    tcx,
810                    sig.output().map_bound(|output_ty| {
811                        ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
812                    }),
813                ));
814
815                (trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn))
816            }
817            ty::Closure(_, args) => {
818                let args = args.as_closure();
819                let sig = args.sig();
820                let trait_ref = sig.map_bound(|sig| {
821                    ty::TraitRef::new(
822                        self.tcx(),
823                        obligation.predicate.def_id(),
824                        [self_ty, sig.inputs()[0]],
825                    )
826                });
827
828                // We must additionally check that the return type impls `Future + Sized`.
829                let future_trait_def_id =
830                    tcx.require_lang_item(LangItem::Future, obligation.cause.span);
831                let placeholder_output_ty = self.infcx.enter_forall_and_leak_universe(sig.output());
832                nested.push(obligation.with(
833                    tcx,
834                    ty::TraitRef::new(tcx, future_trait_def_id, [placeholder_output_ty]),
835                ));
836                let sized_trait_def_id =
837                    tcx.require_lang_item(LangItem::Sized, obligation.cause.span);
838                nested.push(obligation.with(
839                    tcx,
840                    sig.output().map_bound(|output_ty| {
841                        ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
842                    }),
843                ));
844
845                (trait_ref, args.kind_ty())
846            }
847            _ => bug!("expected callable type for AsyncFn candidate"),
848        };
849
850        nested.extend(
851            self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?,
852        );
853
854        let goal_kind =
855            self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
856
857        // If we have not yet determined the `ClosureKind` of the closure or coroutine-closure,
858        // then additionally register an `AsyncFnKindHelper` goal which will fail if the kind
859        // is constrained to an insufficient type later on.
860        if let Some(closure_kind) = self.infcx.shallow_resolve(kind_ty).to_opt_closure_kind() {
861            if !closure_kind.extends(goal_kind) {
862                return Err(SelectionError::Unimplemented);
863            }
864        } else {
865            nested.push(Obligation::new(
866                self.tcx(),
867                obligation.derived_cause(ObligationCauseCode::BuiltinDerived),
868                obligation.param_env,
869                ty::TraitRef::new(
870                    self.tcx(),
871                    self.tcx()
872                        .require_lang_item(LangItem::AsyncFnKindHelper, obligation.cause.span),
873                    [kind_ty, Ty::from_closure_kind(self.tcx(), goal_kind)],
874                ),
875            ));
876        }
877
878        Ok(nested)
879    }
880
881    /// In the case of closure types and fn pointers,
882    /// we currently treat the input type parameters on the trait as
883    /// outputs. This means that when we have a match we have only
884    /// considered the self type, so we have to go back and make sure
885    /// to relate the argument types too. This is kind of wrong, but
886    /// since we control the full set of impls, also not that wrong,
887    /// and it DOES yield better error messages (since we don't report
888    /// errors as if there is no applicable impl, but rather report
889    /// errors are about mismatched argument types.
890    ///
891    /// Here is an example. Imagine we have a closure expression
892    /// and we desugared it so that the type of the expression is
893    /// `Closure`, and `Closure` expects `i32` as argument. Then it
894    /// is "as if" the compiler generated this impl:
895    /// ```ignore (illustrative)
896    /// impl Fn(i32) for Closure { ... }
897    /// ```
898    /// Now imagine our obligation is `Closure: Fn(usize)`. So far
899    /// we have matched the self type `Closure`. At this point we'll
900    /// compare the `i32` to `usize` and generate an error.
901    ///
902    /// Note that this checking occurs *after* the impl has selected,
903    /// because these output type parameters should not affect the
904    /// selection of the impl. Therefore, if there is a mismatch, we
905    /// report an error to the user.
906    {}
#[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("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                                    ::tracing_core::__macro_support::Option::Some(906u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("obligation");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("found_trait_ref")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("found_trait_ref");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&found_trait_ref)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    Result<PredicateObligations<'tcx>, 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) } =
                normalize_with_depth(self, obligation.param_env,
                    obligation.cause.clone(), obligation.recursion_depth + 1,
                    Unnormalized::new_wip((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")]
907    fn equate_trait_refs(
908        &mut self,
909        obligation: TraitObligation<'tcx>,
910        found_trait_ref: ty::PolyTraitRef<'tcx>,
911    ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
912        let found_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
913            obligation.cause.span,
914            BoundRegionConversionTime::HigherRankedType,
915            found_trait_ref,
916        );
917        // Normalize the obligation and expected trait refs together, because why not
918        let Normalized { obligations: nested, value: (obligation_trait_ref, found_trait_ref) } =
919            normalize_with_depth(
920                self,
921                obligation.param_env,
922                obligation.cause.clone(),
923                obligation.recursion_depth + 1,
924                Unnormalized::new_wip((obligation.predicate.trait_ref, found_trait_ref)),
925            );
926
927        // needed to define opaque types for tests/ui/type-alias-impl-trait/assoc-projection-ice.rs
928        self.infcx
929            .at(&obligation.cause, obligation.param_env)
930            .eq(DefineOpaqueTypes::Yes, obligation_trait_ref, found_trait_ref)
931            .map(|InferOk { mut obligations, .. }| {
932                obligations.extend(nested);
933                obligations
934            })
935            .map_err(|terr| {
936                SelectionError::SignatureMismatch(Box::new(SignatureMismatchData {
937                    expected_trait_ref: obligation_trait_ref,
938                    found_trait_ref,
939                    terr,
940                }))
941            })
942    }
943
944    fn confirm_trait_upcasting_unsize_candidate(
945        &mut self,
946        obligation: &PolyTraitObligation<'tcx>,
947        idx: usize,
948    ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
949        let tcx = self.tcx();
950
951        // `assemble_candidates_for_unsizing` should ensure there are no late-bound
952        // regions here. See the comment there for more details.
953        let predicate = obligation.predicate.no_bound_vars().unwrap();
954        let a_ty = self.infcx.shallow_resolve(predicate.self_ty());
955        let b_ty = self.infcx.shallow_resolve(predicate.trait_ref.args.type_at(1));
956
957        let ty::Dynamic(a_data, a_region) = *a_ty.kind() else {
958            ::rustc_span::macros::bug_impl(None,
    format_args!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`"),
    Location::caller())bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
959        };
960        let ty::Dynamic(b_data, b_region) = *b_ty.kind() else {
961            ::rustc_span::macros::bug_impl(None,
    format_args!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`"),
    Location::caller())bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
962        };
963
964        let source_principal = a_data.principal().unwrap().with_self_ty(tcx, a_ty);
965        let unnormalized_upcast_principal =
966            ty::Unnormalized::new_wip(util::supertraits(tcx, source_principal).nth(idx).unwrap());
967
968        let nested = self
969            .match_upcast_principal(
970                obligation,
971                unnormalized_upcast_principal,
972                a_data,
973                b_data,
974                a_region,
975                b_region,
976            )?
977            .expect("did not expect ambiguity during confirmation");
978
979        Ok(ImplSource::Builtin(BuiltinImplSource::TraitUpcasting(idx), nested))
980    }
981
982    fn confirm_builtin_unsize_candidate(
983        &mut self,
984        obligation: &PolyTraitObligation<'tcx>,
985    ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
986        let tcx = self.tcx();
987
988        // `assemble_candidates_for_unsizing` should ensure there are no late-bound
989        // regions here. See the comment there for more details.
990        let source = self.infcx.shallow_resolve(obligation.self_ty().no_bound_vars().unwrap());
991        let target = obligation.predicate.skip_binder().trait_ref.args.type_at(1);
992        let target = self.infcx.shallow_resolve(target);
993        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:993",
                        "rustc_trait_selection::traits::select::confirmation",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
                        ::tracing_core::__macro_support::Option::Some(993u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("source")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("source");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("target")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("target");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_builtin_unsize_candidate")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&target)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?source, ?target, "confirm_builtin_unsize_candidate");
994
995        Ok(match (source.kind(), target.kind()) {
996            // `dyn Trait + Kx + 'a` -> `dyn Trait + Ky + 'b` (auto traits and lifetime subtyping).
997            (&ty::Dynamic(data_a, r_a), &ty::Dynamic(data_b, r_b)) => {
998                // See `assemble_candidates_for_unsizing` for more info.
999                // We already checked the compatibility of auto traits within `assemble_candidates_for_unsizing`.
1000                let existential_predicates = if data_b.principal().is_some() {
1001                    tcx.mk_poly_existential_predicates_from_iter(
1002                        data_a
1003                            .principal()
1004                            .map(|b| b.map_bound(ty::ExistentialPredicate::Trait))
1005                            .into_iter()
1006                            .chain(
1007                                data_a
1008                                    .projection_bounds()
1009                                    .map(|b| b.map_bound(ty::ExistentialPredicate::Projection)),
1010                            )
1011                            .chain(
1012                                data_b
1013                                    .auto_traits()
1014                                    .map(ty::ExistentialPredicate::AutoTrait)
1015                                    .map(ty::Binder::dummy),
1016                            ),
1017                    )
1018                } else {
1019                    // If we're unsizing to a dyn type that has no principal, then drop
1020                    // the principal and projections from the type. We use the auto traits
1021                    // from the RHS type since as we noted that we've checked for auto
1022                    // trait compatibility during unsizing.
1023                    tcx.mk_poly_existential_predicates_from_iter(
1024                        data_b
1025                            .auto_traits()
1026                            .map(ty::ExistentialPredicate::AutoTrait)
1027                            .map(ty::Binder::dummy),
1028                    )
1029                };
1030                let source_trait = Ty::new_dynamic(tcx, existential_predicates, r_b);
1031
1032                // Require that the traits involved in this upcast are **equal**;
1033                // only the **lifetime bound** is changed.
1034                let InferOk { mut obligations, .. } = self
1035                    .infcx
1036                    .sup_raw(
1037                        &obligation.cause,
1038                        obligation.param_env,
1039                        DefineOpaqueTypes::Yes,
1040                        target,
1041                        source_trait,
1042                    )
1043                    .map_err(|_| SelectionError::Unimplemented)?;
1044
1045                // Register one obligation for 'a: 'b.
1046                let outlives = ty::OutlivesClause(r_a, r_b);
1047                obligations.push(Obligation::with_depth(
1048                    tcx,
1049                    obligation.cause.clone(),
1050                    obligation.recursion_depth + 1,
1051                    obligation.param_env,
1052                    obligation.predicate.rebind(outlives),
1053                ));
1054
1055                ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1056            }
1057
1058            // `T` -> `dyn Trait`
1059            (_, &ty::Dynamic(data, r)) => {
1060                let mut object_dids = data.auto_traits().chain(data.principal_def_id());
1061                if let Some(did) = object_dids.find(|did| !tcx.is_dyn_compatible(*did)) {
1062                    return Err(SelectionError::TraitDynIncompatible(did));
1063                }
1064
1065                let predicate_to_obligation = |predicate| {
1066                    Obligation::with_depth(
1067                        tcx,
1068                        obligation.cause.clone(),
1069                        obligation.recursion_depth + 1,
1070                        obligation.param_env,
1071                        predicate,
1072                    )
1073                };
1074
1075                // Create obligations:
1076                //  - Casting `T` to `Trait`
1077                //  - For all the various builtin bounds attached to the object cast. (In other
1078                //  words, if the object type is `Foo + Send`, this would create an obligation for
1079                //  the `Send` check.)
1080                //  - Projection predicates
1081                let mut nested: PredicateObligations<'_> = data
1082                    .iter()
1083                    .map(|predicate| predicate_to_obligation(predicate.with_self_ty(tcx, source)))
1084                    .collect();
1085
1086                // We can only make objects from sized types.
1087                let tr = ty::TraitRef::new(
1088                    tcx,
1089                    tcx.require_lang_item(LangItem::Sized, obligation.cause.span),
1090                    [source],
1091                );
1092                nested.push(predicate_to_obligation(tr.upcast(tcx)));
1093
1094                // If the type is `Foo + 'a`, ensure that the type
1095                // being cast to `Foo + 'a` outlives `'a`:
1096                let outlives = ty::OutlivesClause(source, r);
1097                nested.push(predicate_to_obligation(
1098                    ty::ClauseKind::TypeOutlives(outlives).upcast(tcx),
1099                ));
1100
1101                ImplSource::Builtin(BuiltinImplSource::Misc, nested)
1102            }
1103
1104            // `[T; n]` -> `[T]`
1105            (&ty::Array(a, _), &ty::Slice(b)) => {
1106                let InferOk { obligations, .. } = self
1107                    .infcx
1108                    .at(&obligation.cause, obligation.param_env)
1109                    .eq(DefineOpaqueTypes::Yes, b, a)
1110                    .map_err(|_| SelectionError::Unimplemented)?;
1111
1112                ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1113            }
1114
1115            // `Struct<T>` -> `Struct<U>`
1116            (&ty::Adt(def, args_a), &ty::Adt(_, args_b)) => {
1117                let unsizing_params = tcx.unsizing_params_for_adt(def.did());
1118                if unsizing_params.is_empty() {
1119                    return Err(SelectionError::Unimplemented);
1120                }
1121
1122                let tail_field = def.non_enum_variant().tail();
1123                let tail_field_ty = tcx.type_of(tail_field.did);
1124
1125                let mut nested = PredicateObligations::new();
1126
1127                // Extract `TailField<T>` and `TailField<U>` from `Struct<T>` and `Struct<U>`,
1128                // normalizing in the process, since `type_of` returns something directly from
1129                // HIR ty lowering (which means it's un-normalized).
1130                let source_tail = normalize_with_depth_to(
1131                    self,
1132                    obligation.param_env,
1133                    obligation.cause.clone(),
1134                    obligation.recursion_depth + 1,
1135                    tail_field_ty.instantiate(tcx, args_a),
1136                    &mut nested,
1137                );
1138                let target_tail = normalize_with_depth_to(
1139                    self,
1140                    obligation.param_env,
1141                    obligation.cause.clone(),
1142                    obligation.recursion_depth + 1,
1143                    tail_field_ty.instantiate(tcx, args_b),
1144                    &mut nested,
1145                );
1146
1147                // Check that the source struct with the target's
1148                // unsizing parameters is equal to the target.
1149                let args =
1150                    tcx.mk_args_from_iter(args_a.iter().enumerate().map(|(i, k)| {
1151                        if unsizing_params.contains(i as u32) { args_b[i] } else { k }
1152                    }));
1153                let new_struct = Ty::new_adt(tcx, def, args);
1154                let InferOk { obligations, .. } = self
1155                    .infcx
1156                    .at(&obligation.cause, obligation.param_env)
1157                    .eq(DefineOpaqueTypes::Yes, target, new_struct)
1158                    .map_err(|_| SelectionError::Unimplemented)?;
1159                nested.extend(obligations);
1160
1161                // Construct the nested `TailField<T>: Unsize<TailField<U>>` predicate.
1162                let tail_unsize_obligation = obligation.with(
1163                    tcx,
1164                    ty::TraitRef::new(
1165                        tcx,
1166                        obligation.predicate.def_id(),
1167                        [source_tail, target_tail],
1168                    ),
1169                );
1170                nested.push(tail_unsize_obligation);
1171
1172                ImplSource::Builtin(BuiltinImplSource::Misc, nested)
1173            }
1174
1175            _ => ::rustc_span::macros::bug_impl(None,
    format_args!("source: {0}, target: {1}", source, target),
    Location::caller())bug!("source: {source}, target: {target}"),
1176        })
1177    }
1178
1179    /// This trait is indirectly exposed on stable, so do *not* extend the set of types that
1180    /// implement the trait without FCP!
1181    fn confirm_bikeshed_guaranteed_no_drop_candidate(
1182        &mut self,
1183        obligation: &PolyTraitObligation<'tcx>,
1184    ) -> ImplSource<'tcx, PredicateObligation<'tcx>> {
1185        let mut obligations = ::thin_vec::ThinVec::new()thin_vec![];
1186
1187        let tcx = self.tcx();
1188        let self_ty = obligation.predicate.self_ty();
1189        match *self_ty.skip_binder().kind() {
1190            // `&mut T` and `&T` always implement `BikeshedGuaranteedNoDrop`.
1191            ty::Ref(..) => {}
1192            // `ManuallyDrop<T>` always implements `BikeshedGuaranteedNoDrop`.
1193            ty::Adt(def, _) if def.is_manually_drop() => {}
1194            // Arrays and tuples implement `BikeshedGuaranteedNoDrop` only if
1195            // their constituent types implement `BikeshedGuaranteedNoDrop`.
1196            ty::Tuple(tys) => {
1197                obligations.extend(tys.iter().map(|elem_ty| {
1198                    obligation.with(
1199                        tcx,
1200                        self_ty.rebind(ty::TraitRef::new(
1201                            tcx,
1202                            obligation.predicate.def_id(),
1203                            [elem_ty],
1204                        )),
1205                    )
1206                }));
1207            }
1208            ty::Array(elem_ty, _) => {
1209                obligations.push(obligation.with(
1210                    tcx,
1211                    self_ty.rebind(ty::TraitRef::new(
1212                        tcx,
1213                        obligation.predicate.def_id(),
1214                        [elem_ty],
1215                    )),
1216                ));
1217            }
1218
1219            // All other types implement `BikeshedGuaranteedNoDrop` only if
1220            // they implement `Copy`. We could be smart here and short-circuit
1221            // some trivially `Copy`/`!Copy` types, but there's no benefit.
1222            ty::FnDef(..)
1223            | ty::FnPtr(..)
1224            | ty::Error(_)
1225            | ty::Uint(_)
1226            | ty::Int(_)
1227            | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1228            | ty::Bool
1229            | ty::Float(_)
1230            | ty::Char
1231            | ty::RawPtr(..)
1232            | ty::Never
1233            | ty::Pat(..)
1234            | ty::Dynamic(..)
1235            | ty::Str
1236            | ty::Slice(_)
1237            | ty::Foreign(..)
1238            | ty::Adt(..)
1239            | ty::Alias(..)
1240            | ty::Param(_)
1241            | ty::Placeholder(..)
1242            | ty::Closure(..)
1243            | ty::CoroutineClosure(..)
1244            | ty::Coroutine(..)
1245            | ty::UnsafeBinder(_)
1246            | ty::CoroutineWitness(..)
1247            | ty::Bound(..) => {
1248                obligations.push(obligation.with(
1249                    tcx,
1250                    self_ty.map_bound(|ty| {
1251                        ty::TraitRef::new(
1252                            tcx,
1253                            tcx.require_lang_item(LangItem::Copy, obligation.cause.span),
1254                            [ty],
1255                        )
1256                    }),
1257                ));
1258            }
1259
1260            ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1261                {
    ::core::panicking::panic_fmt(format_args!("unexpected type `{0:?}`",
            self_ty));
}panic!("unexpected type `{self_ty:?}`")
1262            }
1263        }
1264
1265        ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1266    }
1267
1268    fn confirm_try_as_dyn_candidate(
1269        &mut self,
1270        obligation: &PolyTraitObligation<'tcx>,
1271    ) -> ImplSource<'tcx, PredicateObligation<'tcx>> {
1272        let tcx = self.tcx();
1273
1274        let mut obligations = PredicateObligations::new();
1275
1276        let self_ty = obligation.predicate.self_ty();
1277        let ty_lifetime = obligation.predicate.map_bound(|p| p.trait_ref.args.region_at(1));
1278
1279        match *self_ty.skip_binder().kind() {
1280            ty::Dynamic(_bounds, lifetime) => {
1281                obligations.push(obligation.with(
1282                    tcx,
1283                    ty_lifetime.map_bound(|ty_lifetime| ty::OutlivesClause(ty_lifetime, lifetime)),
1284                ));
1285            }
1286
1287            ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1288                {
    ::core::panicking::panic_fmt(format_args!("unexpected type `{0:?}`",
            self_ty));
}panic!("unexpected type `{self_ty:?}`")
1289            }
1290
1291            _ => {}
1292        }
1293        ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1294    }
1295}