Skip to main content

rustc_trait_selection/traits/select/
candidate_assembly.rs

1//! Candidate assembly.
2//!
3//! The selection process begins by examining all in-scope impls,
4//! caller obligations, and so forth and assembling a list of
5//! candidates. See the [rustc dev guide] for more details.
6//!
7//! [rustc dev guide]:https://rustc-dev-guide.rust-lang.org/traits/resolution.html#candidate-assembly
8
9use std::ops::ControlFlow;
10
11use hir::def_id::DefId;
12use rustc_attr_ir::lang_items::LangItem;
13use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
14use rustc_hir::{self as hir, CoroutineDesugaring, CoroutineKind};
15use rustc_infer::traits::{Obligation, PolyTraitObligation, PredicateObligation, SelectionError};
16use rustc_middle::ty::fast_reject::DeepRejectCtxt;
17use rustc_middle::ty::{
18    self, CallerBoundsIterator, ExistentialPredicate, FieldInfo, IncludeSizedImplicitBounds,
19    SizedTraitKind, TraitRef, Ty, TypeVisitableExt, elaborate,
20};
21use rustc_span::{DUMMY_SP, bug, span_bug};
22use tracing::{debug, instrument, trace};
23
24use super::SelectionCandidate::*;
25use super::{SelectionCandidateSet, SelectionContext, TraitObligationStack};
26use crate::traits::query::evaluate_obligation::InferCtxtExt;
27use crate::traits::util;
28
29impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
30    {}
#[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("assemble_candidates",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(30u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::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,
                        &{ meta.fields().value_set_all(&[]) })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return:
                    Result<SelectionCandidateSet<'tcx>, SelectionError<'tcx>> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            let TraitObligationStack { obligation, .. } = *stack;
            let obligation =
                &Obligation {
                        param_env: obligation.param_env,
                        cause: obligation.cause.clone(),
                        recursion_depth: obligation.recursion_depth,
                        predicate: self.infcx.deeply_resolve_ignoring_regions(obligation.predicate),
                    };
            if obligation.predicate.skip_binder().self_ty().is_ty_var() {
                {
                    use ::tracing::__macro_support::Callsite as _;
                    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                        {
                            static META: ::tracing::Metadata<'static> =
                                {
                                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:44",
                                        "rustc_trait_selection::traits::select::candidate_assembly",
                                        ::tracing::Level::DEBUG,
                                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                        ::tracing_core::__macro_support::Option::Some(44u32),
                                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                        ::tracing_core::field::FieldSet::new(&["message",
                                                        {
                                                            const NAME:
                                                                ::tracing::__macro_support::FieldName<{
                                                                    ::tracing::__macro_support::FieldName::len("ty")
                                                                }> =
                                                                ::tracing::__macro_support::FieldName::new("ty");
                                                            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!("ambiguous inference var or opaque type")
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation.predicate.skip_binder().self_ty())
                                                            as &dyn ::tracing::field::Value))])
                            });
                    } else { ; }
                };
                return Ok(SelectionCandidateSet {
                            vec: ::alloc::vec::Vec::new(),
                            ambiguous: true,
                        });
            }
            let mut candidates =
                SelectionCandidateSet { vec: Vec::new(), ambiguous: false };
            if obligation.polarity() == ty::ClausePolarity::Negative {
                self.assemble_candidates_for_trait_alias(obligation,
                    &mut candidates);
                self.assemble_candidates_from_impls(obligation,
                    &mut candidates);
                self.assemble_candidates_from_caller_bounds(stack,
                        &mut candidates)?;
            } else {
                self.assemble_candidates_for_trait_alias(obligation,
                    &mut candidates);
                let def_id = obligation.predicate.def_id();
                let tcx = self.tcx();
                let lang_item = tcx.as_lang_item(def_id);
                match lang_item {
                    Some(LangItem::Copy | LangItem::Clone |
                        LangItem::TrivialClone) => {
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:75",
                                                "rustc_trait_selection::traits::select::candidate_assembly",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                                ::tracing_core::__macro_support::Option::Some(75u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("obligation_self_ty")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("obligation_self_ty");
                                                                    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(&obligation.predicate.skip_binder().self_ty())
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        self.assemble_candidates_from_impls(obligation,
                            &mut candidates);
                        self.assemble_builtin_copy_clone_candidate(obligation.predicate.self_ty().skip_binder(),
                            &mut candidates);
                    }
                    Some(LangItem::DiscriminantKind) => {
                        candidates.vec.push(BuiltinCandidate);
                    }
                    Some(LangItem::PointeeTrait) => {
                        candidates.vec.push(BuiltinCandidate);
                    }
                    Some(LangItem::Sized) => {
                        self.assemble_builtin_sized_candidate(obligation.predicate.self_ty().skip_binder(),
                            &mut candidates, SizedTraitKind::Sized);
                    }
                    Some(LangItem::MetaSized) => {
                        self.assemble_builtin_sized_candidate(obligation.predicate.self_ty().skip_binder(),
                            &mut candidates, SizedTraitKind::MetaSized);
                    }
                    Some(LangItem::PointeeSized) => {
                        ::rustc_span::macros::bug_impl(None,
                            format_args!("`PointeeSized` is removed during lowering"),
                            Location::caller());
                    }
                    Some(LangItem::Unsize) => {
                        self.assemble_candidates_for_unsizing(obligation,
                            &mut candidates);
                    }
                    Some(LangItem::Destruct) => {
                        self.assemble_const_destruct_candidates(obligation,
                            &mut candidates);
                    }
                    Some(LangItem::TransmuteTrait) => {
                        self.assemble_candidates_from_impls(obligation,
                            &mut candidates);
                        self.assemble_candidates_for_transmutability(obligation,
                            &mut candidates);
                    }
                    Some(LangItem::Tuple) => {
                        self.assemble_candidate_for_tuple(obligation,
                            &mut candidates);
                    }
                    Some(LangItem::FnPtrTrait) => {
                        self.assemble_candidates_for_fn_ptr_trait(obligation,
                            &mut candidates);
                    }
                    Some(LangItem::FnAddrTrait) => {
                        self.assemble_candidates_for_fn_addr_trait(obligation,
                            &mut candidates);
                    }
                    Some(LangItem::BikeshedGuaranteedNoDrop) => {
                        self.assemble_candidates_for_bikeshed_guaranteed_no_drop_trait(obligation,
                            &mut candidates);
                    }
                    Some(LangItem::TryAsDyn) => {
                        self.assemble_candidates_for_try_as_dyn(obligation,
                            &mut candidates);
                    }
                    Some(LangItem::Field) => {
                        self.assemble_candidates_for_field_trait(obligation,
                            &mut candidates);
                    }
                    _ => {
                        match lang_item {
                            Some(LangItem::Coroutine) => {
                                self.assemble_coroutine_candidates(obligation,
                                    &mut candidates);
                            }
                            Some(LangItem::Future) => {
                                self.assemble_future_candidates(obligation,
                                    &mut candidates);
                            }
                            Some(LangItem::Iterator) => {
                                self.assemble_iterator_candidates(obligation,
                                    &mut candidates);
                            }
                            Some(LangItem::FusedIterator) => {
                                self.assemble_fused_iterator_candidates(obligation,
                                    &mut candidates);
                            }
                            Some(LangItem::AsyncIterator) => {
                                self.assemble_async_iterator_candidates(obligation,
                                    &mut candidates);
                            }
                            Some(LangItem::AsyncFnKindHelper) => {
                                self.assemble_async_fn_kind_helper_candidates(obligation,
                                    &mut candidates);
                            }
                            Some(LangItem::AsyncFn | LangItem::AsyncFnMut |
                                LangItem::AsyncFnOnce) => {
                                self.assemble_async_closure_candidates(obligation,
                                    &mut candidates);
                            }
                            Some(LangItem::Fn | LangItem::FnMut | LangItem::FnOnce) => {
                                self.assemble_closure_candidates(obligation,
                                    &mut candidates);
                                self.assemble_fn_pointer_candidates(obligation,
                                    &mut candidates);
                            }
                            _ => {}
                        }
                        self.assemble_candidates_from_impls(obligation,
                            &mut candidates);
                        self.assemble_candidates_from_object_ty(obligation,
                            &mut candidates);
                    }
                }
                self.assemble_candidates_from_projected_tys(obligation,
                    &mut candidates);
                self.assemble_candidates_from_caller_bounds(stack,
                        &mut candidates)?;
                self.assemble_candidates_from_auto_impls(obligation,
                    &mut candidates);
            }
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:189",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(189u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::tracing_core::field::FieldSet::new(&["message"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("candidate list size: {0}",
                                                                candidates.vec.len()) as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            Ok(candidates)
        }
    }
}#[instrument(skip(self, stack), level = "debug")]
31    pub(super) fn assemble_candidates<'o>(
32        &mut self,
33        stack: &TraitObligationStack<'o, 'tcx>,
34    ) -> Result<SelectionCandidateSet<'tcx>, SelectionError<'tcx>> {
35        let TraitObligationStack { obligation, .. } = *stack;
36        let obligation = &Obligation {
37            param_env: obligation.param_env,
38            cause: obligation.cause.clone(),
39            recursion_depth: obligation.recursion_depth,
40            predicate: self.infcx.deeply_resolve_ignoring_regions(obligation.predicate),
41        };
42
43        if obligation.predicate.skip_binder().self_ty().is_ty_var() {
44            debug!(ty = ?obligation.predicate.skip_binder().self_ty(), "ambiguous inference var or opaque type");
45            // Self is a type variable (e.g., `_: AsRef<str>`).
46            //
47            // This is somewhat problematic, as the current scheme can't really
48            // handle it turning to be a projection. This does end up as truly
49            // ambiguous in most cases anyway.
50            //
51            // Take the fast path out - this also improves
52            // performance by preventing assemble_candidates_from_impls from
53            // matching every impl for this trait.
54            return Ok(SelectionCandidateSet { vec: vec![], ambiguous: true });
55        }
56
57        let mut candidates = SelectionCandidateSet { vec: Vec::new(), ambiguous: false };
58
59        // Negative trait predicates have different rules than positive trait predicates.
60        if obligation.polarity() == ty::ClausePolarity::Negative {
61            self.assemble_candidates_for_trait_alias(obligation, &mut candidates);
62            self.assemble_candidates_from_impls(obligation, &mut candidates);
63            self.assemble_candidates_from_caller_bounds(stack, &mut candidates)?;
64        } else {
65            self.assemble_candidates_for_trait_alias(obligation, &mut candidates);
66
67            // Other bounds. Consider both in-scope bounds from fn decl
68            // and applicable impls. There is a certain set of precedence rules here.
69            let def_id = obligation.predicate.def_id();
70            let tcx = self.tcx();
71
72            let lang_item = tcx.as_lang_item(def_id);
73            match lang_item {
74                Some(LangItem::Copy | LangItem::Clone | LangItem::TrivialClone) => {
75                    debug!(obligation_self_ty = ?obligation.predicate.skip_binder().self_ty());
76
77                    // User-defined copy impls are permitted, but only for
78                    // structs and enums.
79                    self.assemble_candidates_from_impls(obligation, &mut candidates);
80
81                    // For other types, we'll use the builtin rules.
82                    self.assemble_builtin_copy_clone_candidate(
83                        obligation.predicate.self_ty().skip_binder(),
84                        &mut candidates,
85                    );
86                }
87                Some(LangItem::DiscriminantKind) => {
88                    // `DiscriminantKind` is automatically implemented for every type.
89                    candidates.vec.push(BuiltinCandidate);
90                }
91                Some(LangItem::PointeeTrait) => {
92                    // `Pointee` is automatically implemented for every type.
93                    candidates.vec.push(BuiltinCandidate);
94                }
95                Some(LangItem::Sized) => {
96                    self.assemble_builtin_sized_candidate(
97                        obligation.predicate.self_ty().skip_binder(),
98                        &mut candidates,
99                        SizedTraitKind::Sized,
100                    );
101                }
102                Some(LangItem::MetaSized) => {
103                    self.assemble_builtin_sized_candidate(
104                        obligation.predicate.self_ty().skip_binder(),
105                        &mut candidates,
106                        SizedTraitKind::MetaSized,
107                    );
108                }
109                Some(LangItem::PointeeSized) => {
110                    bug!("`PointeeSized` is removed during lowering");
111                }
112                Some(LangItem::Unsize) => {
113                    self.assemble_candidates_for_unsizing(obligation, &mut candidates);
114                }
115                Some(LangItem::Destruct) => {
116                    self.assemble_const_destruct_candidates(obligation, &mut candidates);
117                }
118                Some(LangItem::TransmuteTrait) => {
119                    // User-defined transmutability impls are permitted.
120                    self.assemble_candidates_from_impls(obligation, &mut candidates);
121                    self.assemble_candidates_for_transmutability(obligation, &mut candidates);
122                }
123                Some(LangItem::Tuple) => {
124                    self.assemble_candidate_for_tuple(obligation, &mut candidates);
125                }
126                Some(LangItem::FnPtrTrait) => {
127                    self.assemble_candidates_for_fn_ptr_trait(obligation, &mut candidates);
128                }
129                Some(LangItem::FnAddrTrait) => {
130                    self.assemble_candidates_for_fn_addr_trait(obligation, &mut candidates);
131                }
132                Some(LangItem::BikeshedGuaranteedNoDrop) => {
133                    self.assemble_candidates_for_bikeshed_guaranteed_no_drop_trait(
134                        obligation,
135                        &mut candidates,
136                    );
137                }
138                Some(LangItem::TryAsDyn) => {
139                    self.assemble_candidates_for_try_as_dyn(obligation, &mut candidates);
140                }
141                Some(LangItem::Field) => {
142                    self.assemble_candidates_for_field_trait(obligation, &mut candidates);
143                }
144                _ => {
145                    // We re-match here for traits that can have both builtin impls and user written impls.
146                    // After the builtin impls we need to also add user written impls, which we do not want to
147                    // do in general because just checking if there are any is expensive.
148                    match lang_item {
149                        Some(LangItem::Coroutine) => {
150                            self.assemble_coroutine_candidates(obligation, &mut candidates);
151                        }
152                        Some(LangItem::Future) => {
153                            self.assemble_future_candidates(obligation, &mut candidates);
154                        }
155                        Some(LangItem::Iterator) => {
156                            self.assemble_iterator_candidates(obligation, &mut candidates);
157                        }
158                        Some(LangItem::FusedIterator) => {
159                            self.assemble_fused_iterator_candidates(obligation, &mut candidates);
160                        }
161                        Some(LangItem::AsyncIterator) => {
162                            self.assemble_async_iterator_candidates(obligation, &mut candidates);
163                        }
164                        Some(LangItem::AsyncFnKindHelper) => {
165                            self.assemble_async_fn_kind_helper_candidates(
166                                obligation,
167                                &mut candidates,
168                            );
169                        }
170                        Some(LangItem::AsyncFn | LangItem::AsyncFnMut | LangItem::AsyncFnOnce) => {
171                            self.assemble_async_closure_candidates(obligation, &mut candidates);
172                        }
173                        Some(LangItem::Fn | LangItem::FnMut | LangItem::FnOnce) => {
174                            self.assemble_closure_candidates(obligation, &mut candidates);
175                            self.assemble_fn_pointer_candidates(obligation, &mut candidates);
176                        }
177                        _ => {}
178                    }
179
180                    self.assemble_candidates_from_impls(obligation, &mut candidates);
181                    self.assemble_candidates_from_object_ty(obligation, &mut candidates);
182                }
183            }
184
185            self.assemble_candidates_from_projected_tys(obligation, &mut candidates);
186            self.assemble_candidates_from_caller_bounds(stack, &mut candidates)?;
187            self.assemble_candidates_from_auto_impls(obligation, &mut candidates);
188        }
189        debug!("candidate list size: {}", candidates.vec.len());
190        Ok(candidates)
191    }
192
193    {}
#[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("assemble_candidates_from_projected_tys",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(193u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            match obligation.predicate.skip_binder().trait_ref.self_ty().kind()
                {
                ty::Alias(_, ty::AliasTy {
                    kind: ty::Projection { .. } | ty::Opaque { .. }, .. }) => {}
                ty::Infer(ty::TyVar(_)) => {
                    ::rustc_span::macros::bug_impl(Some(obligation.cause.span),
                        format_args!("Self=_ should have been handled by assemble_candidates"),
                        Location::caller());
                }
                _ => return,
            }
            self.infcx.probe(|_|
                    {
                        let poly_trait_predicate =
                            self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
                        let placeholder_trait_predicate =
                            self.infcx.enter_forall_and_leak_universe(poly_trait_predicate);
                        let mut distinct_normalized_bounds = FxHashSet::default();
                        let _ =
                            self.for_each_item_bound::<!>(placeholder_trait_predicate.self_ty(),
                                |selcx, bound, idx, alias_bound_kind|
                                    {
                                        let Some(bound) =
                                            bound.as_trait_clause() else {
                                                return ControlFlow::Continue(());
                                            };
                                        if bound.polarity() != placeholder_trait_predicate.polarity
                                            {
                                            return ControlFlow::Continue(());
                                        }
                                        selcx.infcx.probe(|_|
                                                {
                                                    match selcx.match_normalize_trait_ref(obligation,
                                                            placeholder_trait_predicate.trait_ref,
                                                            ty::Unnormalized::new_wip(bound.map_bound(|pred|
                                                                        pred.trait_ref))) {
                                                        Ok(None) => {
                                                            candidates.vec.push(ProjectionCandidate {
                                                                    idx,
                                                                    kind: alias_bound_kind,
                                                                });
                                                        }
                                                        Ok(Some(normalized_trait)) if
                                                            distinct_normalized_bounds.insert(normalized_trait) => {
                                                            candidates.vec.push(ProjectionCandidate {
                                                                    idx,
                                                                    kind: alias_bound_kind,
                                                                });
                                                        }
                                                        _ => {}
                                                    }
                                                });
                                        ControlFlow::Continue(())
                                    }, || candidates.ambiguous = true);
                    });
        }
    }
}#[instrument(level = "debug", skip(self, candidates))]
194    fn assemble_candidates_from_projected_tys(
195        &mut self,
196        obligation: &PolyTraitObligation<'tcx>,
197        candidates: &mut SelectionCandidateSet<'tcx>,
198    ) {
199        // Before we go into the whole placeholder thing, just
200        // quickly check if the self-type is a projection at all.
201        match obligation.predicate.skip_binder().trait_ref.self_ty().kind() {
202            // Excluding IATs and type aliases here as they don't have meaningful item bounds.
203            ty::Alias(_, ty::AliasTy { kind: ty::Projection { .. } | ty::Opaque { .. }, .. }) => {}
204            ty::Infer(ty::TyVar(_)) => {
205                span_bug!(
206                    obligation.cause.span,
207                    "Self=_ should have been handled by assemble_candidates"
208                );
209            }
210            _ => return,
211        }
212
213        self.infcx.probe(|_| {
214            let poly_trait_predicate =
215                self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
216            let placeholder_trait_predicate =
217                self.infcx.enter_forall_and_leak_universe(poly_trait_predicate);
218
219            // The bounds returned by `item_bounds` may contain duplicates after
220            // normalization, so try to deduplicate when possible to avoid
221            // unnecessary ambiguity.
222            let mut distinct_normalized_bounds = FxHashSet::default();
223            let _ = self.for_each_item_bound::<!>(
224                placeholder_trait_predicate.self_ty(),
225                |selcx, bound, idx, alias_bound_kind| {
226                    let Some(bound) = bound.as_trait_clause() else {
227                        return ControlFlow::Continue(());
228                    };
229                    if bound.polarity() != placeholder_trait_predicate.polarity {
230                        return ControlFlow::Continue(());
231                    }
232
233                    selcx.infcx.probe(|_| {
234                        // We checked the polarity already
235                        match selcx.match_normalize_trait_ref(
236                            obligation,
237                            placeholder_trait_predicate.trait_ref,
238                            ty::Unnormalized::new_wip(bound.map_bound(|pred| pred.trait_ref)),
239                        ) {
240                            Ok(None) => {
241                                candidates
242                                    .vec
243                                    .push(ProjectionCandidate { idx, kind: alias_bound_kind });
244                            }
245                            Ok(Some(normalized_trait))
246                                if distinct_normalized_bounds.insert(normalized_trait) =>
247                            {
248                                candidates
249                                    .vec
250                                    .push(ProjectionCandidate { idx, kind: alias_bound_kind });
251                            }
252                            _ => {}
253                        }
254                    });
255
256                    ControlFlow::Continue(())
257                },
258                // On ambiguity.
259                || candidates.ambiguous = true,
260            );
261        });
262    }
263
264    /// Given an obligation like `<SomeTrait for T>`, searches the obligations that the caller
265    /// supplied to find out whether it is listed among them.
266    ///
267    /// Never affects the inference environment.
268    {}
#[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("assemble_candidates_from_caller_bounds",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(268u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::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,
                        &{ meta.fields().value_set_all(&[]) })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: Result<(), SelectionError<'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/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:274",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(274u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("stack.obligation")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("stack.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(&::tracing::field::debug(&stack.obligation)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let bounds =
                stack.obligation.param_env.caller_bounds().trait_clauses(self.tcx()).with_polarity(stack.obligation.predicate.polarity()).iter();
            let drcx = DeepRejectCtxt::relate_rigid_rigid(self.tcx());
            let obligation_args =
                stack.obligation.predicate.skip_binder().trait_ref.args;
            for bound in bounds {
                if bound.def_id() != stack.obligation.predicate.def_id() {
                    continue;
                }
                let bound_trait_ref = bound.map_bound(|t| t.trait_ref);
                if !drcx.args_may_unify(obligation_args,
                            bound_trait_ref.skip_binder().args) {
                    continue;
                }
                let wc = self.where_clause_may_apply(stack, bound_trait_ref)?;
                if wc.may_apply() {
                    candidates.vec.push(ParamCandidate(bound));
                }
            }
            Ok(())
        }
    }
}#[instrument(level = "debug", skip(self, stack, candidates))]
269    fn assemble_candidates_from_caller_bounds<'o>(
270        &mut self,
271        stack: &TraitObligationStack<'o, 'tcx>,
272        candidates: &mut SelectionCandidateSet<'tcx>,
273    ) -> Result<(), SelectionError<'tcx>> {
274        debug!(?stack.obligation);
275
276        let bounds = stack
277            .obligation
278            .param_env
279            .caller_bounds()
280            .trait_clauses(self.tcx())
281            // Micro-optimization: filter out predicates with different polarities.
282            .with_polarity(stack.obligation.predicate.polarity())
283            .iter();
284
285        let drcx = DeepRejectCtxt::relate_rigid_rigid(self.tcx());
286        let obligation_args = stack.obligation.predicate.skip_binder().trait_ref.args;
287        // Keep only those bounds which may apply, and propagate overflow if it occurs.
288        for bound in bounds {
289            // Micro-optimization: filter out predicates relating to different traits.
290            if bound.def_id() != stack.obligation.predicate.def_id() {
291                continue;
292            }
293
294            let bound_trait_ref = bound.map_bound(|t| t.trait_ref);
295            if !drcx.args_may_unify(obligation_args, bound_trait_ref.skip_binder().args) {
296                continue;
297            }
298            let wc = self.where_clause_may_apply(stack, bound_trait_ref)?;
299            if wc.may_apply() {
300                candidates.vec.push(ParamCandidate(bound));
301            }
302        }
303
304        Ok(())
305    }
306
307    fn assemble_coroutine_candidates(
308        &mut self,
309        obligation: &PolyTraitObligation<'tcx>,
310        candidates: &mut SelectionCandidateSet<'tcx>,
311    ) {
312        // Okay to skip binder because the args on coroutine types never
313        // touch bound regions, they just capture the in-scope
314        // type/region parameters.
315        let self_ty = obligation.self_ty().skip_binder();
316        match self_ty.kind() {
317            // `async`/`gen` constructs get lowered to a special kind of coroutine that
318            // should *not* `impl Coroutine`.
319            ty::Coroutine(did, ..) if self.tcx().is_general_coroutine(*did) => {
320                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:320",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(320u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("self_ty")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("self_ty");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("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!("assemble_coroutine_candidates")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?self_ty, ?obligation, "assemble_coroutine_candidates");
321
322                candidates.vec.push(CoroutineCandidate);
323            }
324            ty::Infer(ty::TyVar(_)) => {
325                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:325",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(325u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("assemble_coroutine_candidates: ambiguous self-type")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("assemble_coroutine_candidates: ambiguous self-type");
326                candidates.ambiguous = true;
327            }
328            _ => {}
329        }
330    }
331
332    fn assemble_future_candidates(
333        &mut self,
334        obligation: &PolyTraitObligation<'tcx>,
335        candidates: &mut SelectionCandidateSet<'tcx>,
336    ) {
337        let self_ty = obligation.self_ty().skip_binder();
338        if let ty::Coroutine(did, ..) = self_ty.kind() {
339            // async constructs get lowered to a special kind of coroutine that
340            // should directly `impl Future`.
341            if self.tcx().coroutine_is_async(*did) {
342                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:342",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(342u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("self_ty")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("self_ty");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("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!("assemble_future_candidates")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?self_ty, ?obligation, "assemble_future_candidates");
343
344                candidates.vec.push(FutureCandidate);
345            }
346        }
347    }
348
349    fn assemble_iterator_candidates(
350        &mut self,
351        obligation: &PolyTraitObligation<'tcx>,
352        candidates: &mut SelectionCandidateSet<'tcx>,
353    ) {
354        let self_ty = obligation.self_ty().skip_binder();
355        // gen constructs get lowered to a special kind of coroutine that
356        // should directly `impl Iterator`.
357        if let ty::Coroutine(did, ..) = self_ty.kind()
358            && self.tcx().coroutine_is_gen(*did)
359        {
360            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:360",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(360u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("self_ty")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("self_ty");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("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!("assemble_iterator_candidates")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?self_ty, ?obligation, "assemble_iterator_candidates");
361
362            candidates.vec.push(IteratorCandidate);
363        }
364    }
365
366    fn assemble_fused_iterator_candidates(
367        &mut self,
368        obligation: &PolyTraitObligation<'tcx>,
369        candidates: &mut SelectionCandidateSet<'tcx>,
370    ) {
371        if self.coroutine_is_gen(obligation.self_ty().skip_binder()) {
372            candidates.vec.push(BuiltinCandidate);
373        }
374    }
375
376    fn assemble_async_iterator_candidates(
377        &mut self,
378        obligation: &PolyTraitObligation<'tcx>,
379        candidates: &mut SelectionCandidateSet<'tcx>,
380    ) {
381        let self_ty = obligation.self_ty().skip_binder();
382        if let ty::Coroutine(did, args) = *self_ty.kind() {
383            // gen constructs get lowered to a special kind of coroutine that
384            // should directly `impl AsyncIterator`.
385            if self.tcx().coroutine_is_async_gen(did) {
386                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:386",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(386u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("self_ty")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("self_ty");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("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!("assemble_iterator_candidates")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?self_ty, ?obligation, "assemble_iterator_candidates");
387
388                // Can only confirm this candidate if we have constrained
389                // the `Yield` type to at least `Poll<Option<?0>>`..
390                let ty::Adt(_poll_def, args) = *args.as_coroutine().yield_ty().kind() else {
391                    candidates.ambiguous = true;
392                    return;
393                };
394                let ty::Adt(_option_def, _) = *args.type_at(0).kind() else {
395                    candidates.ambiguous = true;
396                    return;
397                };
398
399                candidates.vec.push(AsyncIteratorCandidate);
400            }
401        }
402    }
403
404    /// Checks for the artificial impl that the compiler will create for an obligation like `X :
405    /// FnMut<..>` where `X` is a closure type.
406    ///
407    /// Note: the type parameters on a closure candidate are modeled as *output* type
408    /// parameters and hence do not affect whether this trait is a match or not. They will be
409    /// unified during the confirmation step.
410    fn assemble_closure_candidates(
411        &mut self,
412        obligation: &PolyTraitObligation<'tcx>,
413        candidates: &mut SelectionCandidateSet<'tcx>,
414    ) {
415        let kind = self.tcx().fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
416
417        // Okay to skip binder because the args on closure types never
418        // touch bound regions, they just capture the in-scope
419        // type/region parameters
420        let self_ty = obligation.self_ty().skip_binder();
421        match *self_ty.kind() {
422            ty::Closure(def_id, _) => {
423                let is_const = self.tcx().is_const_fn(def_id);
424                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:424",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(424u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("kind")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("kind");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("obligation")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("obligation");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::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!("assemble_unboxed_candidates")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&kind)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?kind, ?obligation, "assemble_unboxed_candidates");
425                match self.infcx.closure_kind(self_ty) {
426                    Some(closure_kind) => {
427                        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:427",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(427u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("closure_kind")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("closure_kind");
                                            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!("assemble_unboxed_candidates")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&closure_kind)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?closure_kind, "assemble_unboxed_candidates");
428                        if closure_kind.extends(kind) {
429                            candidates.vec.push(ClosureCandidate { is_const });
430                        }
431                    }
432                    None => {
433                        if kind == ty::ClosureKind::FnOnce {
434                            candidates.vec.push(ClosureCandidate { is_const });
435                        } else {
436                            candidates.ambiguous = true;
437                        }
438                    }
439                }
440            }
441            ty::CoroutineClosure(def_id, args) => {
442                let args = args.as_coroutine_closure();
443                let is_const = self.tcx().is_const_fn(def_id);
444                if let Some(closure_kind) = self.infcx.closure_kind(self_ty)
445                    // Ambiguity if upvars haven't been constrained yet
446                    && !args.tupled_upvars_ty().is_ty_var()
447                {
448                    // A coroutine-closure implements `FnOnce` *always*, since it may
449                    // always be called once. It additionally implements `Fn`/`FnMut`
450                    // only if it has no upvars referencing the closure-env lifetime,
451                    // and if the closure kind permits it.
452                    if closure_kind.extends(kind) && !args.has_self_borrows() {
453                        candidates.vec.push(ClosureCandidate { is_const });
454                    } else if kind == ty::ClosureKind::FnOnce {
455                        candidates.vec.push(ClosureCandidate { is_const });
456                    }
457                } else if kind == ty::ClosureKind::FnOnce {
458                    candidates.vec.push(ClosureCandidate { is_const });
459                } else {
460                    // This stays ambiguous until kind+upvars are determined.
461                    candidates.ambiguous = true;
462                }
463            }
464            ty::Infer(ty::TyVar(_)) => {
465                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:465",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(465u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("assemble_unboxed_closure_candidates: ambiguous self-type")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("assemble_unboxed_closure_candidates: ambiguous self-type");
466                candidates.ambiguous = true;
467            }
468            _ => {}
469        }
470    }
471
472    {}
#[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("assemble_async_closure_candidates",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(472u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let goal_kind =
                self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:481",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(481u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::tracing_core::field::FieldSet::new(&["message"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("self_ty = {0:?}",
                                                                obligation.self_ty().skip_binder().kind()) as
                                                        &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            match *obligation.self_ty().skip_binder().kind() {
                ty::CoroutineClosure(def_id, args) => {
                    if let Some(closure_kind) =
                                args.as_coroutine_closure().kind_ty().to_opt_closure_kind()
                            && !closure_kind.extends(goal_kind) {
                        return;
                    }
                    let Some(coroutine_kind) =
                        self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(def_id)) else {
                            ::rustc_span::macros::bug_impl(None,
                                format_args!("coroutine with no kind"), Location::caller());
                        };
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:498",
                                            "rustc_trait_selection::traits::select::candidate_assembly",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                            ::tracing_core::__macro_support::Option::Some(498u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                            ::tracing_core::field::FieldSet::new(&[{
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("coroutine_kind")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("coroutine_kind");
                                                                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(&coroutine_kind)
                                                                as &dyn ::tracing::field::Value))])
                                });
                        } else { ; }
                    };
                    match coroutine_kind {
                        CoroutineKind::Desugared(CoroutineDesugaring::Async, _) => {
                            candidates.vec.push(AsyncClosureCandidate);
                        }
                        _ => (),
                    }
                }
                ty::Closure(_, args) => {
                    if let Some(closure_kind) =
                                args.as_closure().kind_ty().to_opt_closure_kind() &&
                            !closure_kind.extends(goal_kind) {
                        return;
                    }
                    candidates.vec.push(AsyncClosureCandidate);
                }
                ty::FnPtr(sig_tys, hdr) => {
                    if sig_tys.with(hdr).is_fn_trait_compatible() {
                        candidates.vec.push(AsyncClosureCandidate);
                    }
                }
                ty::FnDef(def_id, _) => {
                    let tcx = self.tcx();
                    if tcx.fn_sig(def_id).skip_binder().is_fn_trait_compatible()
                            && tcx.codegen_fn_attrs(def_id).target_features.is_empty() {
                        candidates.vec.push(AsyncClosureCandidate);
                    }
                }
                _ => {}
            }
        }
    }
}#[instrument(level = "debug", skip(self, candidates))]
473    fn assemble_async_closure_candidates(
474        &mut self,
475        obligation: &PolyTraitObligation<'tcx>,
476        candidates: &mut SelectionCandidateSet<'tcx>,
477    ) {
478        let goal_kind =
479            self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
480
481        debug!("self_ty = {:?}", obligation.self_ty().skip_binder().kind());
482        match *obligation.self_ty().skip_binder().kind() {
483            ty::CoroutineClosure(def_id, args) => {
484                if let Some(closure_kind) =
485                    args.as_coroutine_closure().kind_ty().to_opt_closure_kind()
486                    && !closure_kind.extends(goal_kind)
487                {
488                    return;
489                }
490
491                // Make sure this is actually an async closure.
492                let Some(coroutine_kind) =
493                    self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(def_id))
494                else {
495                    bug!("coroutine with no kind");
496                };
497
498                debug!(?coroutine_kind);
499                match coroutine_kind {
500                    CoroutineKind::Desugared(CoroutineDesugaring::Async, _) => {
501                        candidates.vec.push(AsyncClosureCandidate);
502                    }
503                    _ => (),
504                }
505            }
506            // Closures and fn pointers implement `AsyncFn*` if their return types
507            // implement `Future`, which is checked later.
508            ty::Closure(_, args) => {
509                if let Some(closure_kind) = args.as_closure().kind_ty().to_opt_closure_kind()
510                    && !closure_kind.extends(goal_kind)
511                {
512                    return;
513                }
514                candidates.vec.push(AsyncClosureCandidate);
515            }
516            // Provide an impl, but only for suitable `fn` pointers.
517            ty::FnPtr(sig_tys, hdr) => {
518                if sig_tys.with(hdr).is_fn_trait_compatible() {
519                    candidates.vec.push(AsyncClosureCandidate);
520                }
521            }
522            // Provide an impl for suitable functions, rejecting `#[target_feature]` functions (RFC 2396).
523            ty::FnDef(def_id, _) => {
524                let tcx = self.tcx();
525                if tcx.fn_sig(def_id).skip_binder().is_fn_trait_compatible()
526                    && tcx.codegen_fn_attrs(def_id).target_features.is_empty()
527                {
528                    candidates.vec.push(AsyncClosureCandidate);
529                }
530            }
531            _ => {}
532        }
533    }
534
535    fn assemble_async_fn_kind_helper_candidates(
536        &mut self,
537        obligation: &PolyTraitObligation<'tcx>,
538        candidates: &mut SelectionCandidateSet<'tcx>,
539    ) {
540        let self_ty = obligation.self_ty().skip_binder();
541        let target_kind_ty = obligation.predicate.skip_binder().trait_ref.args.type_at(1);
542
543        // `to_opt_closure_kind` is kind of ICEy when it sees non-int types.
544        if !(self_ty.is_integral() || self_ty.is_ty_var()) {
545            return;
546        }
547        if !(target_kind_ty.is_integral() || self_ty.is_ty_var()) {
548            return;
549        }
550
551        // Check that the self kind extends the goal kind. If it does,
552        // then there's nothing else to check.
553        if let Some(closure_kind) = self_ty.to_opt_closure_kind()
554            && let Some(goal_kind) = target_kind_ty.to_opt_closure_kind()
555            && closure_kind.extends(goal_kind)
556        {
557            candidates.vec.push(AsyncFnKindHelperCandidate);
558        }
559    }
560
561    /// Implements one of the `Fn()` family for a fn pointer.
562    fn assemble_fn_pointer_candidates(
563        &mut self,
564        obligation: &PolyTraitObligation<'tcx>,
565        candidates: &mut SelectionCandidateSet<'tcx>,
566    ) {
567        // Keep this function in sync with extract_tupled_inputs_and_output_from_callable
568        // until the old solver (and thus this function) is removed.
569
570        // Okay to skip binder because what we are inspecting doesn't involve bound regions.
571        let self_ty = obligation.self_ty().skip_binder();
572        match *self_ty.kind() {
573            ty::Infer(ty::TyVar(_)) => {
574                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:574",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(574u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("assemble_fn_pointer_candidates: ambiguous self-type")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("assemble_fn_pointer_candidates: ambiguous self-type");
575                candidates.ambiguous = true; // Could wind up being a fn() type.
576            }
577            // Provide an impl, but only for suitable `fn` pointers.
578            ty::FnPtr(sig_tys, hdr) => {
579                if sig_tys.with(hdr).is_fn_trait_compatible() {
580                    candidates.vec.push(FnPointerCandidate);
581                }
582            }
583            // Provide an impl for suitable functions, rejecting `#[target_feature]` functions (RFC 2396).
584            ty::FnDef(def_id, _) => {
585                let tcx = self.tcx();
586                if tcx.fn_sig(def_id).skip_binder().is_fn_trait_compatible()
587                    && tcx.codegen_fn_attrs(def_id).target_features.is_empty()
588                {
589                    candidates.vec.push(FnPointerCandidate);
590                }
591            }
592            _ => {}
593        }
594    }
595
596    /// Searches for impls that might apply to `obligation`.
597    {}
#[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("assemble_candidates_from_impls",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(597u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::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: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let drcx = DeepRejectCtxt::relate_rigid_infer(self.tcx());
            let obligation_args =
                obligation.predicate.skip_binder().trait_ref.args;
            self.tcx().for_each_relevant_impl(obligation.predicate.def_id(),
                obligation.predicate.skip_binder().trait_ref.self_ty(),
                |impl_def_id|
                    {
                        let impl_trait_header =
                            self.tcx().impl_trait_header(impl_def_id);
                        if !drcx.args_may_unify(obligation_args,
                                    impl_trait_header.trait_ref.skip_binder().args) {
                            return;
                        }
                        if self.tcx().defaultness(impl_def_id).is_default() {
                            return;
                        }
                        if self.reject_fn_ptr_impls(impl_def_id, obligation,
                                impl_trait_header.trait_ref.skip_binder().self_ty()) {
                            return;
                        }
                        self.infcx.probe(|_|
                                {
                                    if let Ok(_args) =
                                            self.match_impl(impl_def_id, impl_trait_header, obligation)
                                        {
                                        candidates.vec.push(ImplCandidate(impl_def_id));
                                    }
                                });
                    });
        }
    }
}#[instrument(level = "debug", skip(self, candidates))]
598    fn assemble_candidates_from_impls(
599        &mut self,
600        obligation: &PolyTraitObligation<'tcx>,
601        candidates: &mut SelectionCandidateSet<'tcx>,
602    ) {
603        let drcx = DeepRejectCtxt::relate_rigid_infer(self.tcx());
604        let obligation_args = obligation.predicate.skip_binder().trait_ref.args;
605        self.tcx().for_each_relevant_impl(
606            obligation.predicate.def_id(),
607            obligation.predicate.skip_binder().trait_ref.self_ty(),
608            |impl_def_id| {
609                // Before we create the generic parameters and everything, first
610                // consider a "quick reject". This avoids creating more types
611                // and so forth that we need to.
612                let impl_trait_header = self.tcx().impl_trait_header(impl_def_id);
613                if !drcx
614                    .args_may_unify(obligation_args, impl_trait_header.trait_ref.skip_binder().args)
615                {
616                    return;
617                }
618
619                // For every `default impl`, there's always a non-default `impl`
620                // that will *also* apply. There's no reason to register a candidate
621                // for this impl, since it is *not* proof that the trait goal holds.
622                if self.tcx().defaultness(impl_def_id).is_default() {
623                    return;
624                }
625
626                if self.reject_fn_ptr_impls(
627                    impl_def_id,
628                    obligation,
629                    impl_trait_header.trait_ref.skip_binder().self_ty(),
630                ) {
631                    return;
632                }
633
634                self.infcx.probe(|_| {
635                    if let Ok(_args) = self.match_impl(impl_def_id, impl_trait_header, obligation) {
636                        candidates.vec.push(ImplCandidate(impl_def_id));
637                    }
638                });
639            },
640        );
641    }
642
643    /// The various `impl<T: FnPtr> Trait for T` in libcore are more like builtin impls for all function items
644    /// and function pointers and less like blanket impls. Rejecting them when they can't possibly apply (because
645    /// the obligation's self-type does not implement `FnPtr`) avoids reporting that the self type does not implement
646    /// `FnPtr`, when we wanted to report that it doesn't implement `Trait`.
647    {}
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("reject_fn_ptr_impls",
                                "rustc_trait_selection::traits::select::candidate_assembly",
                                ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                ::tracing_core::__macro_support::Option::Some(647u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("impl_def_id")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("impl_def_id");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("obligation")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("obligation");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("impl_self_ty")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("impl_self_ty");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::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(&impl_def_id)
                                                        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_self_ty)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: bool = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if !#[allow(non_exhaustive_omitted_patterns)] match impl_self_ty.kind()
                                    {
                                    ty::Param(..) => true,
                                    _ => false,
                                } {
                            return false;
                        }
                        let Some(fn_ptr_trait) =
                            self.tcx().lang_items().fn_ptr_trait() else {
                                return false;
                            };
                        for &(clause, _) in
                            self.tcx().clauses_of(impl_def_id).clauses {
                            let ty::ClauseKind::Trait(pred) =
                                clause.kind().skip_binder() else { continue };
                            if fn_ptr_trait != pred.trait_ref.def_id { continue; }
                            {
                                use ::tracing::__macro_support::Callsite as _;
                                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                    {
                                        static META: ::tracing::Metadata<'static> =
                                            {
                                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:667",
                                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                                    ::tracing::Level::TRACE,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(667u32),
                                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                                    ::tracing_core::field::FieldSet::new(&[{
                                                                        const NAME:
                                                                            ::tracing::__macro_support::FieldName<{
                                                                                ::tracing::__macro_support::FieldName::len("pred")
                                                                            }> =
                                                                            ::tracing::__macro_support::FieldName::new("pred");
                                                                        NAME.as_str()
                                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                    ::tracing::metadata::Kind::EVENT)
                                            };
                                        ::tracing::callsite::DefaultCallsite::new(&META)
                                    };
                                let enabled =
                                    ::tracing::Level::TRACE <=
                                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                            ::tracing::Level::TRACE <=
                                                ::tracing::level_filters::LevelFilter::current() &&
                                        {
                                            let interest = __CALLSITE.interest();
                                            !interest.is_never() &&
                                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                    interest)
                                        };
                                if enabled {
                                    (|value_set: ::tracing::field::ValueSet|
                                                {
                                                    let meta = __CALLSITE.metadata();
                                                    ::tracing::Event::dispatch(meta, &value_set);
                                                    ;
                                                })({
                                            #[allow(unused_imports)]
                                            use ::tracing::field::{debug, display, Value};
                                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&pred)
                                                                        as &dyn ::tracing::field::Value))])
                                        });
                                } else { ; }
                            };
                            if pred.self_ty() != impl_self_ty { continue; }
                            let self_ty = obligation.self_ty().skip_binder();
                            match self_ty.kind() {
                                ty::FnPtr(..) => return false,
                                ty::Placeholder(..) | ty::Dynamic(_, _) | ty::Alias(_, _) |
                                    ty::Infer(_) | ty::Param(..) | ty::Bound(_, _) => {}
                                ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) |
                                    ty::Float(_) | ty::Adt(_, _) | ty::Foreign(_) | ty::Str |
                                    ty::Array(_, _) | ty::Pat(_, _) | ty::Slice(_) |
                                    ty::RawPtr(_, _) | ty::Ref(_, _, _) | ty::Closure(..) |
                                    ty::CoroutineClosure(..) | ty::Coroutine(_, _) |
                                    ty::CoroutineWitness(..) | ty::UnsafeBinder(_) | ty::Never |
                                    ty::Tuple(_) | ty::Error(_) => return true,
                                ty::FnDef(_, _) => return true,
                                ty::View(..) =>
                                    ::core::panicking::unimplemented_default_msg(),
                            }
                            let obligation =
                                Obligation::new(self.tcx(), obligation.cause.clone(),
                                    obligation.param_env,
                                    self.tcx().mk_predicate(obligation.predicate.map_bound(|mut pred|
                                                {
                                                    pred.trait_ref =
                                                        ty::TraitRef::new(self.tcx(), fn_ptr_trait,
                                                            [pred.trait_ref.self_ty()]);
                                                    ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred))
                                                })));
                            if let Ok(r) = self.evaluate_root_obligation(&obligation) {
                                if !r.may_apply() { return true; }
                            }
                        }
                        false
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:647",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(647u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "trace", skip(self), ret)]
648    fn reject_fn_ptr_impls(
649        &mut self,
650        impl_def_id: DefId,
651        obligation: &PolyTraitObligation<'tcx>,
652        impl_self_ty: Ty<'tcx>,
653    ) -> bool {
654        // Let `impl<T: FnPtr> Trait for Vec<T>` go through the normal rejection path.
655        if !matches!(impl_self_ty.kind(), ty::Param(..)) {
656            return false;
657        }
658        let Some(fn_ptr_trait) = self.tcx().lang_items().fn_ptr_trait() else {
659            return false;
660        };
661
662        for &(clause, _) in self.tcx().clauses_of(impl_def_id).clauses {
663            let ty::ClauseKind::Trait(pred) = clause.kind().skip_binder() else { continue };
664            if fn_ptr_trait != pred.trait_ref.def_id {
665                continue;
666            }
667            trace!(?pred);
668            // Not the bound we're looking for
669            if pred.self_ty() != impl_self_ty {
670                continue;
671            }
672
673            let self_ty = obligation.self_ty().skip_binder();
674            match self_ty.kind() {
675                // Fast path to avoid evaluating an obligation that trivially holds.
676                // There may be more bounds, but these are checked by the regular path.
677                ty::FnPtr(..) => return false,
678
679                // These may potentially implement `FnPtr`
680                ty::Placeholder(..)
681                | ty::Dynamic(_, _)
682                | ty::Alias(_, _)
683                | ty::Infer(_)
684                | ty::Param(..)
685                | ty::Bound(_, _) => {}
686
687                // These can't possibly implement `FnPtr` as they are concrete types
688                // and not `FnPtr`
689                ty::Bool
690                | ty::Char
691                | ty::Int(_)
692                | ty::Uint(_)
693                | ty::Float(_)
694                | ty::Adt(_, _)
695                | ty::Foreign(_)
696                | ty::Str
697                | ty::Array(_, _)
698                | ty::Pat(_, _)
699                | ty::Slice(_)
700                | ty::RawPtr(_, _)
701                | ty::Ref(_, _, _)
702                | ty::Closure(..)
703                | ty::CoroutineClosure(..)
704                | ty::Coroutine(_, _)
705                | ty::CoroutineWitness(..)
706                | ty::UnsafeBinder(_)
707                | ty::Never
708                | ty::Tuple(_)
709                | ty::Error(_) => return true,
710                // FIXME: Function definitions could actually implement `FnPtr` by
711                // casting the ZST function def to a function pointer.
712                ty::FnDef(_, _) => return true,
713
714                // FIXME(scrabsha)
715                ty::View(..) => unimplemented!(),
716            }
717
718            // Generic params can implement `FnPtr` if the predicate
719            // holds within its own environment.
720            let obligation = Obligation::new(
721                self.tcx(),
722                obligation.cause.clone(),
723                obligation.param_env,
724                self.tcx().mk_predicate(obligation.predicate.map_bound(|mut pred| {
725                    pred.trait_ref =
726                        ty::TraitRef::new(self.tcx(), fn_ptr_trait, [pred.trait_ref.self_ty()]);
727                    ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred))
728                })),
729            );
730            if let Ok(r) = self.evaluate_root_obligation(&obligation) {
731                if !r.may_apply() {
732                    return true;
733                }
734            }
735        }
736        false
737    }
738
739    fn assemble_candidates_from_auto_impls(
740        &mut self,
741        obligation: &PolyTraitObligation<'tcx>,
742        candidates: &mut SelectionCandidateSet<'tcx>,
743    ) {
744        // Okay to skip binder here because the tests we do below do not involve bound regions.
745        let self_ty = obligation.self_ty().skip_binder();
746        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:746",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(746u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("self_ty")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("self_ty");
                                            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!("assemble_candidates_from_auto_impls")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?self_ty, "assemble_candidates_from_auto_impls");
747
748        let def_id = obligation.predicate.def_id();
749
750        let mut check_impls = || {
751            // Only consider auto impls if there are no manual impls for the root of `self_ty`.
752            //
753            // For example, we only consider auto candidates for `&i32: Auto` if no explicit impl
754            // for `&SomeType: Auto` exists. Due to E0321 the only crate where impls
755            // for `&SomeType: Auto` can be defined is the crate where `Auto` has been defined.
756            //
757            // Generally, we have to guarantee that for all `SimplifiedType`s the only crate
758            // which may define impls for that type is either the crate defining the type
759            // or the trait. This should be guaranteed by the orphan check.
760            let mut has_impl = false;
761            self.tcx().for_each_relevant_impl(def_id, self_ty, |_| has_impl = true);
762            if !has_impl {
763                candidates.vec.push(AutoImplCandidate)
764            }
765        };
766
767        if self.tcx().trait_is_auto(def_id) {
768            match *self_ty.kind() {
769                ty::Dynamic(..) => {
770                    // For object types, we don't know what the closed
771                    // over types are. This means we conservatively
772                    // say nothing; a candidate may be added by
773                    // `assemble_candidates_from_object_ty`.
774                }
775                ty::Foreign(..) => {
776                    // Since the contents of foreign types is unknown,
777                    // we don't add any `..` impl. Default traits could
778                    // still be provided by a manual implementation for
779                    // this trait and type.
780
781                    // Backward compatibility for default auto traits.
782                    // Test: ui/traits/default_auto_traits/extern-types.rs
783                    if self.tcx().is_implicit_trait(def_id, IncludeSizedImplicitBounds::No) {
784                        check_impls()
785                    }
786                }
787                ty::Param(..)
788                | ty::Alias(
789                    _,
790                    ty::AliasTy {
791                        kind: ty::Projection { .. } | ty::Inherent { .. } | ty::Free { .. },
792                        ..
793                    },
794                )
795                | ty::Placeholder(..)
796                | ty::Bound(..) => {
797                    // In these cases, we don't know what the actual
798                    // type is. Therefore, we cannot break it down
799                    // into its constituent types. So we don't
800                    // consider the `..` impl but instead just add no
801                    // candidates: this means that typeck will only
802                    // succeed if there is another reason to believe
803                    // that this obligation holds. That could be a
804                    // where-clause or, in the case of an object type,
805                    // it could be that the object type lists the
806                    // trait (e.g., `Foo+Send : Send`). See
807                    // `ui/typeck/typeck-default-trait-impl-send-param.rs`
808                    // for an example of a test case that exercises
809                    // this path.
810                }
811                ty::Infer(ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_)) => {
812                    // The auto impl might apply; we don't know.
813                    candidates.ambiguous = true;
814                }
815                ty::Coroutine(coroutine_def_id, _) => {
816                    if self.tcx().is_lang_item(def_id, LangItem::Unpin) {
817                        match self.tcx().coroutine_movability(coroutine_def_id) {
818                            hir::Movability::Static => {
819                                // Immovable coroutines are never `Unpin`, so
820                                // suppress the normal auto-impl candidate for it.
821                            }
822                            hir::Movability::Movable => {
823                                // Movable coroutines are always `Unpin`, so add an
824                                // unconditional builtin candidate with no sub-obligations.
825                                candidates.vec.push(BuiltinCandidate);
826                            }
827                        }
828                    } else {
829                        if self.should_stall_coroutine(coroutine_def_id) {
830                            candidates.ambiguous = true;
831                        } else {
832                            // Coroutines implement all other auto traits normally.
833                            candidates.vec.push(AutoImplCandidate);
834                        }
835                    }
836                }
837
838                ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
839                    ::rustc_span::macros::bug_impl(None,
    format_args!("asked to assemble auto trait candidates of unexpected type: {0:?}",
        self_ty), Location::caller());bug!(
840                        "asked to assemble auto trait candidates of unexpected type: {:?}",
841                        self_ty
842                    );
843                }
844
845                ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, .. }) => {
846                    if true {
    if !!self.typing_mode().is_coherence() {
        {
            ::core::panicking::panic_fmt(format_args!("old solver coherence"));
        }
    };
};debug_assert!(!self.typing_mode().is_coherence(), "old solver coherence");
847
848                    if candidates.vec.iter().any(|c| #[allow(non_exhaustive_omitted_patterns)] match c {
    ProjectionCandidate { .. } => true,
    _ => false,
}matches!(c, ProjectionCandidate { .. })) {
849                        // We do not generate an auto impl candidate for `impl Trait`s which already
850                        // reference our auto trait.
851                        //
852                        // For example during candidate assembly for `impl Send: Send`, we don't have
853                        // to look at the constituent types for this opaque types to figure out that this
854                        // trivially holds.
855                        //
856                        // Note that this is only sound as projection candidates of opaque types
857                        // are always applicable for auto traits.
858                    } else if self.infcx.can_define_opaque_ty(def_id) {
859                        // We do not emit auto trait candidates for opaque types in their defining scope, as
860                        // we need to know the hidden type first, which we can't reliably know within the defining
861                        // scope.
862                        candidates.ambiguous = true;
863                    } else {
864                        candidates.vec.push(AutoImplCandidate)
865                    }
866                }
867
868                ty::CoroutineWitness(..) => {
869                    candidates.vec.push(AutoImplCandidate);
870                }
871
872                ty::Bool
873                | ty::Char
874                | ty::Int(_)
875                | ty::Uint(_)
876                | ty::Float(_)
877                | ty::Str
878                | ty::Array(_, _)
879                | ty::Pat(_, _)
880                | ty::Slice(_)
881                | ty::Adt(..)
882                | ty::RawPtr(_, _)
883                | ty::Ref(..)
884                | ty::FnDef(..)
885                | ty::FnPtr(..)
886                | ty::Closure(..)
887                | ty::CoroutineClosure(..)
888                | ty::Never
889                | ty::Tuple(_)
890                | ty::UnsafeBinder(_) => {
891                    // Only consider auto impls of unsafe traits when there are
892                    // no unsafe fields.
893                    if self.tcx().trait_def(def_id).safety.is_unsafe()
894                        && self_ty.has_unsafe_fields()
895                    {
896                        return;
897                    }
898
899                    check_impls();
900                }
901                ty::Error(_) => {
902                    candidates.vec.push(AutoImplCandidate);
903                }
904
905                // FIXME(scrabsha)
906                ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
907            }
908        }
909    }
910
911    /// Searches for impls that might apply to `obligation`.
912    fn assemble_candidates_from_object_ty(
913        &mut self,
914        obligation: &PolyTraitObligation<'tcx>,
915        candidates: &mut SelectionCandidateSet<'tcx>,
916    ) {
917        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:917",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(917u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("self_ty")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("self_ty");
                                            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!("assemble_candidates_from_object_ty")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation.self_ty().skip_binder())
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(
918            self_ty = ?obligation.self_ty().skip_binder(),
919            "assemble_candidates_from_object_ty",
920        );
921
922        if self.tcx().is_sizedness_trait(obligation.predicate.def_id()) {
923            // `dyn MetaSized` is valid, but should get its `MetaSized` impl from
924            // being `dyn` (SizedCandidate), not from the object candidate.
925            return;
926        }
927
928        self.infcx.probe(|_snapshot| {
929            let poly_trait_predicate =
930                self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
931            self.infcx.enter_forall(poly_trait_predicate, |placeholder_trait_predicate| {
932                let self_ty = placeholder_trait_predicate.self_ty();
933                let principal_trait_ref = match self_ty.kind() {
934                    ty::Dynamic(data, ..) => {
935                        if data.auto_traits().any(|did| did == obligation.predicate.def_id()) {
936                            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:936",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(936u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("assemble_candidates_from_object_ty: matched builtin bound, pushing candidate")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(
937                                "assemble_candidates_from_object_ty: matched builtin bound, \
938                             pushing candidate"
939                            );
940                            candidates.vec.push(BuiltinObjectCandidate);
941                            return;
942                        }
943
944                        if let Some(principal) = data.principal() {
945                            principal.with_self_ty(self.tcx(), self_ty)
946                        } else {
947                            // Only auto trait bounds exist.
948                            return;
949                        }
950                    }
951                    ty::Infer(ty::TyVar(_)) => {
952                        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:952",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(952u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("assemble_candidates_from_object_ty: ambiguous")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("assemble_candidates_from_object_ty: ambiguous");
953                        candidates.ambiguous = true; // could wind up being an object type
954                        return;
955                    }
956                    _ => return,
957                };
958
959                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:959",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(959u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message",
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("principal_trait_ref")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("principal_trait_ref");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("assemble_candidates_from_object_ty")
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&principal_trait_ref)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?principal_trait_ref, "assemble_candidates_from_object_ty");
960
961                // Count only those upcast versions that match the trait-ref
962                // we are looking for. Specifically, do not only check for the
963                // correct trait, but also the correct type parameters.
964                // For example, we may be trying to upcast `Foo` to `Bar<i32>`,
965                // but `Foo` is declared as `trait Foo: Bar<u32>`.
966                let candidate_supertraits = util::supertraits(self.tcx(), principal_trait_ref)
967                    .enumerate()
968                    .filter(|&(_, upcast_trait_ref)| {
969                        self.infcx.probe(|_| {
970                            self.match_normalize_trait_ref(
971                                obligation,
972                                placeholder_trait_predicate.trait_ref,
973                                upcast_trait_ref,
974                            )
975                            .is_ok()
976                        })
977                    })
978                    .map(|(idx, _)| ObjectCandidate(idx));
979
980                candidates.vec.extend(candidate_supertraits);
981            })
982        })
983    }
984
985    /// Searches for unsizing that might apply to `obligation`.
986    fn assemble_candidates_for_unsizing(
987        &mut self,
988        obligation: &PolyTraitObligation<'tcx>,
989        candidates: &mut SelectionCandidateSet<'tcx>,
990    ) {
991        // We currently never consider higher-ranked obligations e.g.
992        // `for<'a> &'a T: Unsize<Trait+'a>` to be implemented. This is not
993        // because they are a priori invalid, and we could potentially add support
994        // for them later, it's just that there isn't really a strong need for it.
995        // A `T: Unsize<U>` obligation is always used as part of a `T: CoerceUnsize<U>`
996        // impl, and those are generally applied to concrete types.
997        //
998        // That said, one might try to write a fn with a where clause like
999        //     for<'a> Foo<'a, T>: Unsize<Foo<'a, Trait>>
1000        // where the `'a` is kind of orthogonal to the relevant part of the `Unsize`.
1001        // Still, you'd be more likely to write that where clause as
1002        //     T: Trait
1003        // so it seems ok if we (conservatively) fail to accept that `Unsize`
1004        // obligation above. Should be possible to extend this in the future.
1005        let Some(trait_pred) = obligation.predicate.no_bound_vars() else {
1006            // Don't add any candidates if there are bound regions.
1007            return;
1008        };
1009        let source = trait_pred.self_ty();
1010        let target = trait_pred.trait_ref.args.type_at(1);
1011
1012        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:1012",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(1012u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::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!("assemble_candidates_for_unsizing")
                                            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, "assemble_candidates_for_unsizing");
1013
1014        match (source.kind(), target.kind()) {
1015            // Trait+Kx+'a -> Trait+Ky+'b (upcasts).
1016            (&ty::Dynamic(a_data, a_region), &ty::Dynamic(b_data, b_region)) => {
1017                // Upcast coercions permit several things:
1018                //
1019                // 1. Dropping auto traits, e.g., `Foo + Send` to `Foo`
1020                // 2. Tightening the region bound, e.g., `Foo + 'a` to `Foo + 'b` if `'a: 'b`
1021                // 3. Tightening trait to its super traits, eg. `Foo` to `Bar` if `Foo: Bar`
1022                //
1023                // Note that neither of the first two of these changes requires any
1024                // change at runtime. The third needs to change pointer metadata at runtime.
1025                //
1026                // We always perform upcasting coercions when we can because of reason
1027                // #2 (region bounds).
1028                let principal_def_id_a = a_data.principal_def_id();
1029                let principal_def_id_b = b_data.principal_def_id();
1030                if principal_def_id_a == principal_def_id_b || principal_def_id_b.is_none() {
1031                    // We may upcast to auto traits that are either explicitly listed in
1032                    // the object type's bounds, or implied by the principal trait ref's
1033                    // supertraits.
1034                    let a_auto_traits: FxIndexSet<DefId> = a_data
1035                        .auto_traits()
1036                        .chain(
1037                            principal_def_id_a
1038                                .map(|principal_def_id| {
1039                                    elaborate::supertrait_def_ids(self.tcx(), principal_def_id)
1040                                        .filter(|def_id| self.tcx().trait_is_auto(*def_id))
1041                                })
1042                                .into_flat_iter(),
1043                        )
1044                        .collect();
1045                    let auto_traits_compatible = b_data
1046                        .auto_traits()
1047                        // All of a's auto traits need to be in b's auto traits.
1048                        .all(|b| a_auto_traits.contains(&b));
1049                    if auto_traits_compatible {
1050                        candidates.vec.push(BuiltinUnsizeCandidate);
1051                    }
1052                } else if principal_def_id_a.is_some() && principal_def_id_b.is_some() {
1053                    // not casual unsizing, now check whether this is trait upcasting coercion.
1054                    let principal_a = a_data.principal().unwrap();
1055                    let target_trait_did = principal_def_id_b.unwrap();
1056                    let source_trait_ref = principal_a.with_self_ty(self.tcx(), source);
1057
1058                    for (idx, upcast_trait_ref) in
1059                        util::supertraits(self.tcx(), source_trait_ref).enumerate()
1060                    {
1061                        self.infcx.probe(|_| {
1062                            if upcast_trait_ref.def_id() == target_trait_did
1063                                && let Ok(nested) = self.match_upcast_principal(
1064                                    obligation,
1065                                    upcast_trait_ref,
1066                                    a_data,
1067                                    b_data,
1068                                    a_region,
1069                                    b_region,
1070                                )
1071                            {
1072                                if nested.is_none() {
1073                                    candidates.ambiguous = true;
1074                                }
1075                                candidates.vec.push(TraitUpcastingUnsizeCandidate(idx));
1076                            }
1077                        })
1078                    }
1079                }
1080            }
1081
1082            // `T` -> `Trait`
1083            (_, &ty::Dynamic(_, _)) => {
1084                candidates.vec.push(BuiltinUnsizeCandidate);
1085            }
1086
1087            // Ambiguous handling is below `T` -> `Trait`, because inference
1088            // variables can still implement `Unsize<Trait>` and nested
1089            // obligations will have the final say (likely deferred).
1090            (&ty::Infer(ty::TyVar(_)), _) | (_, &ty::Infer(ty::TyVar(_))) => {
1091                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:1091",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(1091u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                        ::tracing_core::field::FieldSet::new(&["message"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("assemble_candidates_for_unsizing: ambiguous")
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("assemble_candidates_for_unsizing: ambiguous");
1092                candidates.ambiguous = true;
1093            }
1094
1095            // `[T; n]` -> `[T]`
1096            (&ty::Array(..), &ty::Slice(_)) => {
1097                candidates.vec.push(BuiltinUnsizeCandidate);
1098            }
1099
1100            // `Struct<T>` -> `Struct<U>`
1101            (&ty::Adt(def_id_a, _), &ty::Adt(def_id_b, _)) if def_id_a.is_struct() => {
1102                if def_id_a == def_id_b {
1103                    candidates.vec.push(BuiltinUnsizeCandidate);
1104                }
1105            }
1106
1107            _ => {}
1108        };
1109    }
1110
1111    {}
#[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("assemble_candidates_for_transmutability",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1111u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::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,
                        &{ meta.fields().value_set_all(&[]) })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            if obligation.predicate.has_non_region_param() { return; }
            if obligation.has_non_region_infer() {
                candidates.ambiguous = true;
                return;
            }
            candidates.vec.push(TransmutabilityCandidate);
        }
    }
}#[instrument(level = "debug", skip(self, obligation, candidates))]
1112    fn assemble_candidates_for_transmutability(
1113        &mut self,
1114        obligation: &PolyTraitObligation<'tcx>,
1115        candidates: &mut SelectionCandidateSet<'tcx>,
1116    ) {
1117        if obligation.predicate.has_non_region_param() {
1118            return;
1119        }
1120
1121        if obligation.has_non_region_infer() {
1122            candidates.ambiguous = true;
1123            return;
1124        }
1125
1126        candidates.vec.push(TransmutabilityCandidate);
1127    }
1128
1129    {}
#[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("assemble_candidates_for_trait_alias",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1129u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::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,
                        &{ meta.fields().value_set_all(&[]) })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let self_ty = obligation.self_ty().skip_binder();
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:1137",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1137u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("self_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("self_ty");
                                                        NAME.as_str()
                                                    }], ::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(&self_ty)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let def_id = obligation.predicate.def_id();
            if self.tcx().is_trait_alias(def_id) {
                candidates.vec.push(TraitAliasCandidate);
            }
        }
    }
}#[instrument(level = "debug", skip(self, obligation, candidates))]
1130    fn assemble_candidates_for_trait_alias(
1131        &mut self,
1132        obligation: &PolyTraitObligation<'tcx>,
1133        candidates: &mut SelectionCandidateSet<'tcx>,
1134    ) {
1135        // Okay to skip binder here because the tests we do below do not involve bound regions.
1136        let self_ty = obligation.self_ty().skip_binder();
1137        debug!(?self_ty);
1138
1139        let def_id = obligation.predicate.def_id();
1140
1141        if self.tcx().is_trait_alias(def_id) {
1142            candidates.vec.push(TraitAliasCandidate);
1143        }
1144    }
1145
1146    /// Assembles `Copy` and `Clone` candidates for built-in types with no libcore-defined
1147    /// `Copy` or `Clone` impls.
1148    {}
#[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("assemble_builtin_copy_clone_candidate",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1148u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("self_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("self_ty");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            match *self_ty.kind() {
                ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) | ty::Tuple(..) |
                    ty::Pat(..) => {
                    candidates.vec.push(BuiltinCandidate);
                }
                ty::Uint(_) | ty::Int(_) |
                    ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) | ty::Bool |
                    ty::Float(_) | ty::Char | ty::RawPtr(..) | ty::Never |
                    ty::Ref(_, _, hir::Mutability::Not) | ty::Array(..) => {}
                ty::UnsafeBinder(_) => {}
                ty::Dynamic(..) | ty::Str | ty::Slice(..) | ty::Foreign(..) =>
                    {}
                ty::Ref(_, _, hir::Mutability::Mut) => {}
                ty::Coroutine(coroutine_def_id, args) => {
                    if self.should_stall_coroutine(coroutine_def_id) {
                        candidates.ambiguous = true;
                        return;
                    }
                    match self.tcx().coroutine_movability(coroutine_def_id) {
                        hir::Movability::Static => {}
                        hir::Movability::Movable => {
                            if self.tcx().features().coroutine_clone() {
                                let resolved_upvars =
                                    self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
                                if resolved_upvars.is_ty_var() {
                                    candidates.ambiguous = true;
                                } else { candidates.vec.push(BuiltinCandidate); }
                            }
                        }
                    }
                }
                ty::Closure(_, args) => {
                    let resolved_upvars =
                        self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
                    if resolved_upvars.is_ty_var() {
                        candidates.ambiguous = true;
                    } else { candidates.vec.push(BuiltinCandidate); }
                }
                ty::CoroutineClosure(_, args) => {
                    let resolved_upvars =
                        self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
                    if resolved_upvars.is_ty_var() {
                        candidates.ambiguous = true;
                    } else { candidates.vec.push(BuiltinCandidate); }
                }
                ty::CoroutineWitness(..) => {
                    candidates.vec.push(SizedCandidate);
                }
                ty::Adt(..) | ty::Alias(..) | ty::Param(..) |
                    ty::Placeholder(..) => {}
                ty::Infer(ty::TyVar(_)) => { candidates.ambiguous = true; }
                ty::Bound(..) => {}
                ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) |
                    ty::FreshFloatTy(_)) => {
                    ::rustc_span::macros::bug_impl(None,
                        format_args!("asked to assemble builtin bounds of unexpected type: {0:?}",
                            self_ty), Location::caller());
                }
                ty::View(..) =>
                    ::core::panicking::unimplemented_default_msg(),
            }
        }
    }
}#[instrument(level = "debug", skip(self, candidates))]
1149    fn assemble_builtin_copy_clone_candidate(
1150        &mut self,
1151        self_ty: Ty<'tcx>,
1152        candidates: &mut SelectionCandidateSet<'tcx>,
1153    ) {
1154        match *self_ty.kind() {
1155            // These impls are built-in because we cannot express sufficiently
1156            // generic impls in libcore.
1157            ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) | ty::Tuple(..) | ty::Pat(..) => {
1158                candidates.vec.push(BuiltinCandidate);
1159            }
1160
1161            // Implementations provided in libcore.
1162            ty::Uint(_)
1163            | ty::Int(_)
1164            | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1165            | ty::Bool
1166            | ty::Float(_)
1167            | ty::Char
1168            | ty::RawPtr(..)
1169            | ty::Never
1170            | ty::Ref(_, _, hir::Mutability::Not)
1171            | ty::Array(..) => {}
1172
1173            // FIXME(unsafe_binder): Should we conditionally
1174            // (i.e. universally) implement copy/clone?
1175            ty::UnsafeBinder(_) => {}
1176
1177            // Not `Sized`, which is a supertrait of `Copy`/`Clone`.
1178            ty::Dynamic(..) | ty::Str | ty::Slice(..) | ty::Foreign(..) => {}
1179
1180            // Not `Copy` or `Clone` by design.
1181            ty::Ref(_, _, hir::Mutability::Mut) => {}
1182
1183            ty::Coroutine(coroutine_def_id, args) => {
1184                if self.should_stall_coroutine(coroutine_def_id) {
1185                    candidates.ambiguous = true;
1186                    return;
1187                }
1188
1189                match self.tcx().coroutine_movability(coroutine_def_id) {
1190                    hir::Movability::Static => {}
1191                    hir::Movability::Movable => {
1192                        if self.tcx().features().coroutine_clone() {
1193                            let resolved_upvars =
1194                                self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
1195                            if resolved_upvars.is_ty_var() {
1196                                // Not yet resolved.
1197                                candidates.ambiguous = true;
1198                            } else {
1199                                candidates.vec.push(BuiltinCandidate);
1200                            }
1201                        }
1202                    }
1203                }
1204            }
1205
1206            ty::Closure(_, args) => {
1207                let resolved_upvars =
1208                    self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
1209                if resolved_upvars.is_ty_var() {
1210                    // Not yet resolved.
1211                    candidates.ambiguous = true;
1212                } else {
1213                    candidates.vec.push(BuiltinCandidate);
1214                }
1215            }
1216
1217            ty::CoroutineClosure(_, args) => {
1218                let resolved_upvars =
1219                    self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
1220                if resolved_upvars.is_ty_var() {
1221                    // Not yet resolved.
1222                    candidates.ambiguous = true;
1223                } else {
1224                    candidates.vec.push(BuiltinCandidate);
1225                }
1226            }
1227
1228            ty::CoroutineWitness(..) => {
1229                candidates.vec.push(SizedCandidate);
1230            }
1231
1232            // Fallback to whatever user-defined impls or param-env clauses exist in this case.
1233            ty::Adt(..) | ty::Alias(..) | ty::Param(..) | ty::Placeholder(..) => {}
1234
1235            ty::Infer(ty::TyVar(_)) => {
1236                candidates.ambiguous = true;
1237            }
1238
1239            // Only appears when assembling higher-ranked `for<T> T: Clone`.
1240            ty::Bound(..) => {}
1241
1242            ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1243                bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
1244            }
1245
1246            // FIXME(scrabsha)
1247            ty::View(..) => unimplemented!(),
1248        }
1249    }
1250
1251    /// Assembles the `Sized` and `MetaSized` traits which are built-in to the language itself.
1252    {}
#[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("assemble_builtin_sized_candidate",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1252u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("self_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("self_ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("sizedness")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("sizedness");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&sizedness)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            match *self_ty.kind() {
                ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) | ty::Uint(_) |
                    ty::Int(_) | ty::Bool | ty::Float(_) | ty::FnDef(..) |
                    ty::FnPtr(..) | ty::RawPtr(..) | ty::Char | ty::Ref(..) |
                    ty::Array(..) | ty::Closure(..) | ty::CoroutineClosure(..) |
                    ty::Never | ty::Error(_) => {
                    candidates.vec.push(SizedCandidate);
                }
                ty::Coroutine(coroutine_def_id, _) => {
                    if self.should_stall_coroutine(coroutine_def_id) {
                        candidates.ambiguous = true;
                    } else { candidates.vec.push(SizedCandidate); }
                }
                ty::CoroutineWitness(..) => {
                    candidates.vec.push(SizedCandidate);
                }
                ty::Tuple(..) | ty::Pat(..) | ty::Adt(..) |
                    ty::UnsafeBinder(_) => {
                    candidates.vec.push(SizedCandidate);
                }
                ty::Str | ty::Slice(_) | ty::Dynamic(..) =>
                    match sizedness {
                        SizedTraitKind::Sized => {}
                        SizedTraitKind::MetaSized => {
                            candidates.vec.push(SizedCandidate);
                        }
                    },
                ty::Foreign(..) | ty::View(..) => {}
                ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => {}
                ty::Infer(ty::TyVar(_)) => { candidates.ambiguous = true; }
                ty::Bound(..) => {}
                ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) |
                    ty::FreshFloatTy(_)) => {
                    ::rustc_span::macros::bug_impl(None,
                        format_args!("asked to assemble builtin bounds of unexpected type: {0:?}",
                            self_ty), Location::caller());
                }
            }
        }
    }
}#[instrument(level = "debug", skip(self, candidates))]
1253    fn assemble_builtin_sized_candidate(
1254        &mut self,
1255        self_ty: Ty<'tcx>,
1256        candidates: &mut SelectionCandidateSet<'tcx>,
1257        sizedness: SizedTraitKind,
1258    ) {
1259        match *self_ty.kind() {
1260            // Always sized.
1261            ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1262            | ty::Uint(_)
1263            | ty::Int(_)
1264            | ty::Bool
1265            | ty::Float(_)
1266            | ty::FnDef(..)
1267            | ty::FnPtr(..)
1268            | ty::RawPtr(..)
1269            | ty::Char
1270            | ty::Ref(..)
1271            | ty::Array(..)
1272            | ty::Closure(..)
1273            | ty::CoroutineClosure(..)
1274            | ty::Never
1275            | ty::Error(_) => {
1276                candidates.vec.push(SizedCandidate);
1277            }
1278
1279            ty::Coroutine(coroutine_def_id, _) => {
1280                if self.should_stall_coroutine(coroutine_def_id) {
1281                    candidates.ambiguous = true;
1282                } else {
1283                    candidates.vec.push(SizedCandidate);
1284                }
1285            }
1286
1287            ty::CoroutineWitness(..) => {
1288                candidates.vec.push(SizedCandidate);
1289            }
1290
1291            // Conditionally `Sized`.
1292            ty::Tuple(..) | ty::Pat(..) | ty::Adt(..) | ty::UnsafeBinder(_) => {
1293                candidates.vec.push(SizedCandidate);
1294            }
1295
1296            // `MetaSized` but not `Sized`.
1297            ty::Str | ty::Slice(_) | ty::Dynamic(..) => match sizedness {
1298                SizedTraitKind::Sized => {}
1299                SizedTraitKind::MetaSized => {
1300                    candidates.vec.push(SizedCandidate);
1301                }
1302            },
1303
1304            // Not `MetaSized` or `Sized`.
1305            ty::Foreign(..) | ty::View(..) => {}
1306
1307            ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => {}
1308
1309            ty::Infer(ty::TyVar(_)) => {
1310                candidates.ambiguous = true;
1311            }
1312
1313            // Only appears when assembling higher-ranked `for<T> T: Sized`.
1314            ty::Bound(..) => {}
1315
1316            ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1317                bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
1318            }
1319        }
1320    }
1321
1322    fn assemble_const_destruct_candidates(
1323        &mut self,
1324        _obligation: &PolyTraitObligation<'tcx>,
1325        candidates: &mut SelectionCandidateSet<'tcx>,
1326    ) {
1327        candidates.vec.push(BuiltinCandidate);
1328    }
1329
1330    fn assemble_candidate_for_tuple(
1331        &mut self,
1332        obligation: &PolyTraitObligation<'tcx>,
1333        candidates: &mut SelectionCandidateSet<'tcx>,
1334    ) {
1335        let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
1336        match self_ty.kind() {
1337            ty::Tuple(_) => {
1338                candidates.vec.push(BuiltinCandidate);
1339            }
1340            ty::Infer(ty::TyVar(_)) => {
1341                candidates.ambiguous = true;
1342            }
1343            ty::Bool
1344            | ty::Char
1345            | ty::Int(_)
1346            | ty::Uint(_)
1347            | ty::Float(_)
1348            | ty::Adt(_, _)
1349            | ty::Foreign(_)
1350            | ty::Str
1351            | ty::Array(_, _)
1352            | ty::Slice(_)
1353            | ty::RawPtr(_, _)
1354            | ty::Ref(_, _, _)
1355            | ty::FnDef(_, _)
1356            | ty::Pat(_, _)
1357            | ty::FnPtr(..)
1358            | ty::UnsafeBinder(_)
1359            | ty::Dynamic(_, _)
1360            | ty::Closure(..)
1361            | ty::CoroutineClosure(..)
1362            | ty::Coroutine(_, _)
1363            | ty::CoroutineWitness(..)
1364            | ty::Never
1365            | ty::Alias(..)
1366            | ty::Param(_)
1367            | ty::Bound(_, _)
1368            | ty::Error(_)
1369            | ty::Infer(_)
1370            | ty::Placeholder(_) => {}
1371
1372            // FIXME(scrabsha)
1373            ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
1374        }
1375    }
1376
1377    fn assemble_candidates_for_fn_ptr_trait(
1378        &mut self,
1379        obligation: &PolyTraitObligation<'tcx>,
1380        candidates: &mut SelectionCandidateSet<'tcx>,
1381    ) {
1382        let self_ty = self.infcx.deeply_resolve_ignoring_regions(obligation.self_ty());
1383
1384        match self_ty.skip_binder().kind() {
1385            ty::FnPtr(..) => candidates.vec.push(BuiltinCandidate),
1386            ty::Bool
1387            | ty::Char
1388            | ty::Int(_)
1389            | ty::Uint(_)
1390            | ty::Float(_)
1391            | ty::Adt(..)
1392            | ty::Foreign(..)
1393            | ty::Str
1394            | ty::Array(..)
1395            | ty::Pat(..)
1396            | ty::Slice(_)
1397            | ty::RawPtr(_, _)
1398            | ty::Ref(..)
1399            | ty::FnDef(..)
1400            | ty::Placeholder(..)
1401            | ty::Dynamic(..)
1402            | ty::Closure(..)
1403            | ty::CoroutineClosure(..)
1404            | ty::Coroutine(..)
1405            | ty::CoroutineWitness(..)
1406            | ty::UnsafeBinder(_)
1407            | ty::Never
1408            | ty::Tuple(..)
1409            | ty::Alias(..)
1410            | ty::Param(..)
1411            | ty::Bound(..)
1412            | ty::Error(_)
1413            | ty::Infer(
1414                ty::InferTy::IntVar(_)
1415                | ty::InferTy::FloatVar(_)
1416                | ty::InferTy::FreshIntTy(_)
1417                | ty::InferTy::FreshFloatTy(_),
1418            ) => {}
1419            ty::Infer(ty::InferTy::TyVar(_) | ty::InferTy::FreshTy(_)) => {
1420                candidates.ambiguous = true;
1421            }
1422
1423            // FIXME(scrabsha)
1424            ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
1425        }
1426    }
1427
1428    fn assemble_candidates_for_fn_addr_trait(
1429        &mut self,
1430        obligation: &PolyTraitObligation<'tcx>,
1431        candidates: &mut SelectionCandidateSet<'tcx>,
1432    ) {
1433        let self_ty = self.infcx.deeply_resolve_ignoring_regions(obligation.self_ty());
1434
1435        match *self_ty.skip_binder().kind() {
1436            ty::FnDef(_, _) | ty::FnPtr(_, _) => candidates.vec.push(BuiltinCandidate),
1437            ty::Bool
1438            | ty::Char
1439            | ty::Int(_)
1440            | ty::Uint(_)
1441            | ty::Float(_)
1442            | ty::Adt(..)
1443            | ty::Foreign(..)
1444            | ty::Str
1445            | ty::Array(..)
1446            | ty::Pat(..)
1447            | ty::Slice(_)
1448            | ty::RawPtr(_, _)
1449            | ty::Ref(..)
1450            | ty::Placeholder(..)
1451            | ty::Dynamic(..)
1452            | ty::Closure(..)
1453            | ty::CoroutineClosure(..)
1454            | ty::Coroutine(..)
1455            | ty::CoroutineWitness(..)
1456            | ty::UnsafeBinder(_)
1457            | ty::Never
1458            | ty::Tuple(..)
1459            | ty::Alias(..)
1460            | ty::Param(..)
1461            | ty::Bound(..)
1462            | ty::View(..)
1463            | ty::Error(_)
1464            | ty::Infer(
1465                ty::InferTy::IntVar(_)
1466                | ty::InferTy::FloatVar(_)
1467                | ty::InferTy::FreshIntTy(_)
1468                | ty::InferTy::FreshFloatTy(_),
1469            ) => {}
1470
1471            ty::Infer(ty::InferTy::TyVar(_) | ty::InferTy::FreshTy(_)) => {
1472                candidates.ambiguous = true;
1473            }
1474        }
1475    }
1476
1477    fn assemble_candidates_for_bikeshed_guaranteed_no_drop_trait(
1478        &mut self,
1479        obligation: &PolyTraitObligation<'tcx>,
1480        candidates: &mut SelectionCandidateSet<'tcx>,
1481    ) {
1482        match obligation.predicate.self_ty().skip_binder().kind() {
1483            ty::Ref(..)
1484            | ty::Adt(..)
1485            | ty::Tuple(_)
1486            | ty::Array(..)
1487            | ty::FnDef(..)
1488            | ty::FnPtr(..)
1489            | ty::Error(_)
1490            | ty::Uint(_)
1491            | ty::Int(_)
1492            | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1493            | ty::Bool
1494            | ty::Float(_)
1495            | ty::Char
1496            | ty::RawPtr(..)
1497            | ty::Never
1498            | ty::Pat(..)
1499            | ty::Dynamic(..)
1500            | ty::Str
1501            | ty::Slice(_)
1502            | ty::Foreign(..)
1503            | ty::Alias(..)
1504            | ty::Param(_)
1505            | ty::Placeholder(..)
1506            | ty::Closure(..)
1507            | ty::CoroutineClosure(..)
1508            | ty::Coroutine(..)
1509            | ty::UnsafeBinder(_)
1510            | ty::CoroutineWitness(..)
1511            | ty::Bound(..) => {
1512                candidates.vec.push(BikeshedGuaranteedNoDropCandidate);
1513            }
1514
1515            ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1516                candidates.ambiguous = true;
1517            }
1518
1519            // FIXME(scrabsha)
1520            ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
1521        }
1522    }
1523
1524    fn assemble_candidates_for_try_as_dyn(
1525        &mut self,
1526        obligation: &PolyTraitObligation<'tcx>,
1527        candidates: &mut SelectionCandidateSet<'tcx>,
1528    ) {
1529        match *obligation.predicate.self_ty().skip_binder().kind() {
1530            ty::Dynamic(bounds, _lifetime) => {
1531                for bound in bounds {
1532                    match bound.skip_binder() {
1533                        ExistentialPredicate::Trait(_) => {}
1534                        // FIXME(try_as_dyn): check what kind of projections we can allow
1535                        ExistentialPredicate::Projection(_) => return,
1536                        // Auto traits do not affect lifetimes outside of specialization,
1537                        // which is disabled in reflection.
1538                        ExistentialPredicate::AutoTrait(_) => {}
1539                    }
1540                }
1541                candidates.vec.push(TryAsDynCandidate);
1542            }
1543
1544            ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1545                candidates.ambiguous = true;
1546            }
1547
1548            _ => {}
1549        }
1550    }
1551
1552    fn assemble_candidates_for_field_trait(
1553        &mut self,
1554        obligation: &PolyTraitObligation<'tcx>,
1555        candidates: &mut SelectionCandidateSet<'tcx>,
1556    ) {
1557        // FIXME(field_projections): We should not use `evaluate_obligation` in
1558        // the trait solver. Doing so means we don't track overflow and cycles properly
1559        // encountering query cycles instead.
1560        if let ty::Adt(def, args) = obligation.predicate.self_ty().skip_binder().kind()
1561            && let Some(FieldInfo { base, ty, .. }) =
1562                def.field_representing_type_info(self.tcx(), *args)
1563            // NOTE: these bounds have to be kept in sync with the definition of the `Field` trait
1564            // in `library/core/src/field.rs` as well as the new trait solver `fn
1565            // consider_builtin_field_candidate` in
1566            // `compiler/rustc_next_trait_solver/src/solve/trait_goals.rs`.
1567            && match self.infcx.evaluate_obligation(&PredicateObligation::new(
1568                self.tcx(),
1569                obligation.cause.clone(),
1570                obligation.param_env,
1571                TraitRef::new(
1572                    self.tcx(),
1573                    self.tcx().require_lang_item(LangItem::Sized, DUMMY_SP),
1574                    [base],
1575                ),
1576            )) {
1577                Ok(res) if res.must_apply_modulo_regions() => true,
1578                _ => false,
1579            }
1580            && match self.infcx.evaluate_obligation(&PredicateObligation::new(
1581                self.tcx(),
1582                obligation.cause.clone(),
1583                obligation.param_env,
1584                TraitRef::new(
1585                    self.tcx(),
1586                    self.tcx().require_lang_item(LangItem::Sized, DUMMY_SP),
1587                    [ty],
1588                ),
1589            )) {
1590                Ok(res) if res.must_apply_modulo_regions() => true,
1591                _ => false,
1592            }
1593            && match base.kind() {
1594                ty::Adt(def, _) => def.is_struct() && !def.repr().packed(),
1595                ty::Tuple(..) => true,
1596                _ => false,
1597            }
1598        {
1599            candidates.vec.push(BuiltinCandidate);
1600        }
1601    }
1602}