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/5f4effd579500175af844241eb179e756190f1e7/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/5f4effd579500175af844241eb179e756190f1e7/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/5f4effd579500175af844241eb179e756190f1e7/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/5f4effd579500175af844241eb179e756190f1e7/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/5f4effd579500175af844241eb179e756190f1e7/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_ptr_trait(obligation,
                            &mut candidates);
                        self.assemble_candidates_for_fn_static_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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:190",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(190u32),
                                    ::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_ptr_trait(obligation, &mut candidates);
131                    self.assemble_candidates_for_fn_static_trait(obligation, &mut candidates);
132                }
133                Some(LangItem::BikeshedGuaranteedNoDrop) => {
134                    self.assemble_candidates_for_bikeshed_guaranteed_no_drop_trait(
135                        obligation,
136                        &mut candidates,
137                    );
138                }
139                Some(LangItem::TryAsDyn) => {
140                    self.assemble_candidates_for_try_as_dyn(obligation, &mut candidates);
141                }
142                Some(LangItem::Field) => {
143                    self.assemble_candidates_for_field_trait(obligation, &mut candidates);
144                }
145                _ => {
146                    // We re-match here for traits that can have both builtin impls and user written impls.
147                    // After the builtin impls we need to also add user written impls, which we do not want to
148                    // do in general because just checking if there are any is expensive.
149                    match lang_item {
150                        Some(LangItem::Coroutine) => {
151                            self.assemble_coroutine_candidates(obligation, &mut candidates);
152                        }
153                        Some(LangItem::Future) => {
154                            self.assemble_future_candidates(obligation, &mut candidates);
155                        }
156                        Some(LangItem::Iterator) => {
157                            self.assemble_iterator_candidates(obligation, &mut candidates);
158                        }
159                        Some(LangItem::FusedIterator) => {
160                            self.assemble_fused_iterator_candidates(obligation, &mut candidates);
161                        }
162                        Some(LangItem::AsyncIterator) => {
163                            self.assemble_async_iterator_candidates(obligation, &mut candidates);
164                        }
165                        Some(LangItem::AsyncFnKindHelper) => {
166                            self.assemble_async_fn_kind_helper_candidates(
167                                obligation,
168                                &mut candidates,
169                            );
170                        }
171                        Some(LangItem::AsyncFn | LangItem::AsyncFnMut | LangItem::AsyncFnOnce) => {
172                            self.assemble_async_closure_candidates(obligation, &mut candidates);
173                        }
174                        Some(LangItem::Fn | LangItem::FnMut | LangItem::FnOnce) => {
175                            self.assemble_closure_candidates(obligation, &mut candidates);
176                            self.assemble_fn_pointer_candidates(obligation, &mut candidates);
177                        }
178                        _ => {}
179                    }
180
181                    self.assemble_candidates_from_impls(obligation, &mut candidates);
182                    self.assemble_candidates_from_object_ty(obligation, &mut candidates);
183                }
184            }
185
186            self.assemble_candidates_from_projected_tys(obligation, &mut candidates);
187            self.assemble_candidates_from_caller_bounds(stack, &mut candidates)?;
188            self.assemble_candidates_from_auto_impls(obligation, &mut candidates);
189        }
190        debug!("candidate list size: {}", candidates.vec.len());
191        Ok(candidates)
192    }
193
194    {}
#[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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(194u32),
                                    ::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(|_|
                                                {
                                                    let bound =
                                                        util::lazily_elaborate_sizedness_candidate(selcx.infcx,
                                                            obligation, bound);
                                                    match selcx.match_normalize_trait_ref(obligation,
                                                            placeholder_trait_predicate.trait_ref,
                                                            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))]
195    fn assemble_candidates_from_projected_tys(
196        &mut self,
197        obligation: &PolyTraitObligation<'tcx>,
198        candidates: &mut SelectionCandidateSet<'tcx>,
199    ) {
200        // Before we go into the whole placeholder thing, just
201        // quickly check if the self-type is a projection at all.
202        match obligation.predicate.skip_binder().trait_ref.self_ty().kind() {
203            // Excluding IATs and type aliases here as they don't have meaningful item bounds.
204            ty::Alias(_, ty::AliasTy { kind: ty::Projection { .. } | ty::Opaque { .. }, .. }) => {}
205            ty::Infer(ty::TyVar(_)) => {
206                span_bug!(
207                    obligation.cause.span,
208                    "Self=_ should have been handled by assemble_candidates"
209                );
210            }
211            _ => return,
212        }
213
214        self.infcx.probe(|_| {
215            let poly_trait_predicate =
216                self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
217            let placeholder_trait_predicate =
218                self.infcx.enter_forall_and_leak_universe(poly_trait_predicate);
219
220            // The bounds returned by `item_bounds` may contain duplicates after
221            // normalization, so try to deduplicate when possible to avoid
222            // unnecessary ambiguity.
223            let mut distinct_normalized_bounds = FxHashSet::default();
224            let _ = self.for_each_item_bound::<!>(
225                placeholder_trait_predicate.self_ty(),
226                |selcx, bound, idx, alias_bound_kind| {
227                    let Some(bound) = bound.as_trait_clause() else {
228                        return ControlFlow::Continue(());
229                    };
230                    if bound.polarity() != placeholder_trait_predicate.polarity {
231                        return ControlFlow::Continue(());
232                    }
233
234                    selcx.infcx.probe(|_| {
235                        let bound = util::lazily_elaborate_sizedness_candidate(
236                            selcx.infcx,
237                            obligation,
238                            bound,
239                        );
240
241                        // We checked the polarity already
242                        match selcx.match_normalize_trait_ref(
243                            obligation,
244                            placeholder_trait_predicate.trait_ref,
245                            bound.map_bound(|pred| pred.trait_ref),
246                        ) {
247                            Ok(None) => {
248                                candidates
249                                    .vec
250                                    .push(ProjectionCandidate { idx, kind: alias_bound_kind });
251                            }
252                            Ok(Some(normalized_trait))
253                                if distinct_normalized_bounds.insert(normalized_trait) =>
254                            {
255                                candidates
256                                    .vec
257                                    .push(ProjectionCandidate { idx, kind: alias_bound_kind });
258                            }
259                            _ => {}
260                        }
261                    });
262
263                    ControlFlow::Continue(())
264                },
265                // On ambiguity.
266                || candidates.ambiguous = true,
267            );
268        });
269    }
270
271    /// Given an obligation like `<SomeTrait for T>`, searches the obligations that the caller
272    /// supplied to find out whether it is listed among them.
273    ///
274    /// Never affects the inference environment.
275    {}
#[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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(275u32),
                                    ::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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:281",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(281u32),
                                    ::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 {
                let bound =
                    util::lazily_elaborate_sizedness_candidate(self.infcx,
                        stack.obligation, bound);
                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))]
276    fn assemble_candidates_from_caller_bounds<'o>(
277        &mut self,
278        stack: &TraitObligationStack<'o, 'tcx>,
279        candidates: &mut SelectionCandidateSet<'tcx>,
280    ) -> Result<(), SelectionError<'tcx>> {
281        debug!(?stack.obligation);
282
283        let bounds = stack
284            .obligation
285            .param_env
286            .caller_bounds()
287            .trait_clauses(self.tcx())
288            // Micro-optimization: filter out predicates with different polarities.
289            .with_polarity(stack.obligation.predicate.polarity())
290            .iter();
291
292        let drcx = DeepRejectCtxt::relate_rigid_rigid(self.tcx());
293        let obligation_args = stack.obligation.predicate.skip_binder().trait_ref.args;
294        // Keep only those bounds which may apply, and propagate overflow if it occurs.
295        for bound in bounds {
296            let bound =
297                util::lazily_elaborate_sizedness_candidate(self.infcx, stack.obligation, bound);
298
299            // Micro-optimization: filter out predicates relating to different traits.
300            if bound.def_id() != stack.obligation.predicate.def_id() {
301                continue;
302            }
303
304            let bound_trait_ref = bound.map_bound(|t| t.trait_ref);
305            if !drcx.args_may_unify(obligation_args, bound_trait_ref.skip_binder().args) {
306                continue;
307            }
308            let wc = self.where_clause_may_apply(stack, bound_trait_ref)?;
309            if wc.may_apply() {
310                candidates.vec.push(ParamCandidate(bound));
311            }
312        }
313
314        Ok(())
315    }
316
317    fn assemble_coroutine_candidates(
318        &mut self,
319        obligation: &PolyTraitObligation<'tcx>,
320        candidates: &mut SelectionCandidateSet<'tcx>,
321    ) {
322        // Okay to skip binder because the args on coroutine types never
323        // touch bound regions, they just capture the in-scope
324        // type/region parameters.
325        let self_ty = obligation.self_ty().skip_binder();
326        match self_ty.kind() {
327            // `async`/`gen` constructs get lowered to a special kind of coroutine that
328            // should *not* `impl Coroutine`.
329            ty::Coroutine(did, ..) if self.tcx().is_general_coroutine(*did) => {
330                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:330",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(330u32),
                        ::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");
331
332                candidates.vec.push(CoroutineCandidate);
333            }
334            ty::Infer(ty::TyVar(_)) => {
335                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:335",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(335u32),
                        ::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");
336                candidates.ambiguous = true;
337            }
338            _ => {}
339        }
340    }
341
342    fn assemble_future_candidates(
343        &mut self,
344        obligation: &PolyTraitObligation<'tcx>,
345        candidates: &mut SelectionCandidateSet<'tcx>,
346    ) {
347        let self_ty = obligation.self_ty().skip_binder();
348        if let ty::Coroutine(did, ..) = self_ty.kind() {
349            // async constructs get lowered to a special kind of coroutine that
350            // should directly `impl Future`.
351            if self.tcx().coroutine_is_async(*did) {
352                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:352",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(352u32),
                        ::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");
353
354                candidates.vec.push(FutureCandidate);
355            }
356        }
357    }
358
359    fn assemble_iterator_candidates(
360        &mut self,
361        obligation: &PolyTraitObligation<'tcx>,
362        candidates: &mut SelectionCandidateSet<'tcx>,
363    ) {
364        let self_ty = obligation.self_ty().skip_binder();
365        // gen constructs get lowered to a special kind of coroutine that
366        // should directly `impl Iterator`.
367        if let ty::Coroutine(did, ..) = self_ty.kind()
368            && self.tcx().coroutine_is_gen(*did)
369        {
370            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:370",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(370u32),
                        ::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");
371
372            candidates.vec.push(IteratorCandidate);
373        }
374    }
375
376    fn assemble_fused_iterator_candidates(
377        &mut self,
378        obligation: &PolyTraitObligation<'tcx>,
379        candidates: &mut SelectionCandidateSet<'tcx>,
380    ) {
381        if self.coroutine_is_gen(obligation.self_ty().skip_binder()) {
382            candidates.vec.push(BuiltinCandidate);
383        }
384    }
385
386    fn assemble_async_iterator_candidates(
387        &mut self,
388        obligation: &PolyTraitObligation<'tcx>,
389        candidates: &mut SelectionCandidateSet<'tcx>,
390    ) {
391        let self_ty = obligation.self_ty().skip_binder();
392        if let ty::Coroutine(did, args) = *self_ty.kind() {
393            // gen constructs get lowered to a special kind of coroutine that
394            // should directly `impl AsyncIterator`.
395            if self.tcx().coroutine_is_async_gen(did) {
396                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:396",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(396u32),
                        ::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");
397
398                // Can only confirm this candidate if we have constrained
399                // the `Yield` type to at least `Poll<Option<?0>>`..
400                let ty::Adt(_poll_def, args) = *args.as_coroutine().yield_ty().kind() else {
401                    candidates.ambiguous = true;
402                    return;
403                };
404                let ty::Adt(_option_def, _) = *args.type_at(0).kind() else {
405                    candidates.ambiguous = true;
406                    return;
407                };
408
409                candidates.vec.push(AsyncIteratorCandidate);
410            }
411        }
412    }
413
414    /// Checks for the artificial impl that the compiler will create for an obligation like `X :
415    /// FnMut<..>` where `X` is a closure type.
416    ///
417    /// Note: the type parameters on a closure candidate are modeled as *output* type
418    /// parameters and hence do not affect whether this trait is a match or not. They will be
419    /// unified during the confirmation step.
420    fn assemble_closure_candidates(
421        &mut self,
422        obligation: &PolyTraitObligation<'tcx>,
423        candidates: &mut SelectionCandidateSet<'tcx>,
424    ) {
425        let kind = self.tcx().fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
426
427        // Okay to skip binder because the args on closure types never
428        // touch bound regions, they just capture the in-scope
429        // type/region parameters
430        let self_ty = obligation.self_ty().skip_binder();
431        match *self_ty.kind() {
432            ty::Closure(def_id, _) => {
433                let is_const = self.tcx().is_const_fn(def_id);
434                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:434",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(434u32),
                        ::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");
435                match self.infcx.closure_kind(self_ty) {
436                    Some(closure_kind) => {
437                        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:437",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(437u32),
                        ::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");
438                        if closure_kind.extends(kind) {
439                            candidates.vec.push(ClosureCandidate { is_const });
440                        }
441                    }
442                    None => {
443                        if kind == ty::ClosureKind::FnOnce {
444                            candidates.vec.push(ClosureCandidate { is_const });
445                        } else {
446                            candidates.ambiguous = true;
447                        }
448                    }
449                }
450            }
451            ty::CoroutineClosure(def_id, args) => {
452                let args = args.as_coroutine_closure();
453                let is_const = self.tcx().is_const_fn(def_id);
454                if let Some(closure_kind) = self.infcx.closure_kind(self_ty)
455                    // Ambiguity if upvars haven't been constrained yet
456                    && !args.tupled_upvars_ty().is_ty_var()
457                {
458                    // A coroutine-closure implements `FnOnce` *always*, since it may
459                    // always be called once. It additionally implements `Fn`/`FnMut`
460                    // only if it has no upvars referencing the closure-env lifetime,
461                    // and if the closure kind permits it.
462                    if closure_kind.extends(kind) && !args.has_self_borrows() {
463                        candidates.vec.push(ClosureCandidate { is_const });
464                    } else if kind == ty::ClosureKind::FnOnce {
465                        candidates.vec.push(ClosureCandidate { is_const });
466                    }
467                } else if kind == ty::ClosureKind::FnOnce {
468                    candidates.vec.push(ClosureCandidate { is_const });
469                } else {
470                    // This stays ambiguous until kind+upvars are determined.
471                    candidates.ambiguous = true;
472                }
473            }
474            ty::Infer(ty::TyVar(_)) => {
475                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:475",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(475u32),
                        ::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");
476                candidates.ambiguous = true;
477            }
478            _ => {}
479        }
480    }
481
482    {}
#[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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(482u32),
                                    ::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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:491",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(491u32),
                                    ::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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:508",
                                            "rustc_trait_selection::traits::select::candidate_assembly",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                            ::tracing_core::__macro_support::Option::Some(508u32),
                                            ::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))]
483    fn assemble_async_closure_candidates(
484        &mut self,
485        obligation: &PolyTraitObligation<'tcx>,
486        candidates: &mut SelectionCandidateSet<'tcx>,
487    ) {
488        let goal_kind =
489            self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
490
491        debug!("self_ty = {:?}", obligation.self_ty().skip_binder().kind());
492        match *obligation.self_ty().skip_binder().kind() {
493            ty::CoroutineClosure(def_id, args) => {
494                if let Some(closure_kind) =
495                    args.as_coroutine_closure().kind_ty().to_opt_closure_kind()
496                    && !closure_kind.extends(goal_kind)
497                {
498                    return;
499                }
500
501                // Make sure this is actually an async closure.
502                let Some(coroutine_kind) =
503                    self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(def_id))
504                else {
505                    bug!("coroutine with no kind");
506                };
507
508                debug!(?coroutine_kind);
509                match coroutine_kind {
510                    CoroutineKind::Desugared(CoroutineDesugaring::Async, _) => {
511                        candidates.vec.push(AsyncClosureCandidate);
512                    }
513                    _ => (),
514                }
515            }
516            // Closures and fn pointers implement `AsyncFn*` if their return types
517            // implement `Future`, which is checked later.
518            ty::Closure(_, args) => {
519                if let Some(closure_kind) = args.as_closure().kind_ty().to_opt_closure_kind()
520                    && !closure_kind.extends(goal_kind)
521                {
522                    return;
523                }
524                candidates.vec.push(AsyncClosureCandidate);
525            }
526            // Provide an impl, but only for suitable `fn` pointers.
527            ty::FnPtr(sig_tys, hdr) => {
528                if sig_tys.with(hdr).is_fn_trait_compatible() {
529                    candidates.vec.push(AsyncClosureCandidate);
530                }
531            }
532            // Provide an impl for suitable functions, rejecting `#[target_feature]` functions (RFC 2396).
533            ty::FnDef(def_id, _) => {
534                let tcx = self.tcx();
535                if tcx.fn_sig(def_id).skip_binder().is_fn_trait_compatible()
536                    && tcx.codegen_fn_attrs(def_id).target_features.is_empty()
537                {
538                    candidates.vec.push(AsyncClosureCandidate);
539                }
540            }
541            _ => {}
542        }
543    }
544
545    fn assemble_async_fn_kind_helper_candidates(
546        &mut self,
547        obligation: &PolyTraitObligation<'tcx>,
548        candidates: &mut SelectionCandidateSet<'tcx>,
549    ) {
550        let self_ty = obligation.self_ty().skip_binder();
551        let target_kind_ty = obligation.predicate.skip_binder().trait_ref.args.type_at(1);
552
553        // `to_opt_closure_kind` is kind of ICEy when it sees non-int types.
554        if !(self_ty.is_integral() || self_ty.is_ty_var()) {
555            return;
556        }
557        if !(target_kind_ty.is_integral() || self_ty.is_ty_var()) {
558            return;
559        }
560
561        // Check that the self kind extends the goal kind. If it does,
562        // then there's nothing else to check.
563        if let Some(closure_kind) = self_ty.to_opt_closure_kind()
564            && let Some(goal_kind) = target_kind_ty.to_opt_closure_kind()
565            && closure_kind.extends(goal_kind)
566        {
567            candidates.vec.push(AsyncFnKindHelperCandidate);
568        }
569    }
570
571    /// Implements one of the `Fn()` family for a fn pointer.
572    fn assemble_fn_pointer_candidates(
573        &mut self,
574        obligation: &PolyTraitObligation<'tcx>,
575        candidates: &mut SelectionCandidateSet<'tcx>,
576    ) {
577        // Keep this function in sync with extract_tupled_inputs_and_output_from_callable
578        // until the old solver (and thus this function) is removed.
579
580        // Okay to skip binder because what we are inspecting doesn't involve bound regions.
581        let self_ty = obligation.self_ty().skip_binder();
582        match *self_ty.kind() {
583            ty::Infer(ty::TyVar(_)) => {
584                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:584",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(584u32),
                        ::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");
585                candidates.ambiguous = true; // Could wind up being a fn() type.
586            }
587            // Provide an impl, but only for suitable `fn` pointers.
588            ty::FnPtr(sig_tys, hdr) => {
589                if sig_tys.with(hdr).is_fn_trait_compatible() {
590                    candidates.vec.push(FnPointerCandidate);
591                }
592            }
593            // Provide an impl for suitable functions, rejecting `#[target_feature]` functions (RFC 2396).
594            ty::FnDef(def_id, _) => {
595                let tcx = self.tcx();
596                if tcx.fn_sig(def_id).skip_binder().is_fn_trait_compatible()
597                    && tcx.codegen_fn_attrs(def_id).target_features.is_empty()
598                {
599                    candidates.vec.push(FnPointerCandidate);
600                }
601            }
602            _ => {}
603        }
604    }
605
606    /// Searches for impls that might apply to `obligation`.
607    {}
#[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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(607u32),
                                    ::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))]
608    fn assemble_candidates_from_impls(
609        &mut self,
610        obligation: &PolyTraitObligation<'tcx>,
611        candidates: &mut SelectionCandidateSet<'tcx>,
612    ) {
613        let drcx = DeepRejectCtxt::relate_rigid_infer(self.tcx());
614        let obligation_args = obligation.predicate.skip_binder().trait_ref.args;
615        self.tcx().for_each_relevant_impl(
616            obligation.predicate.def_id(),
617            obligation.predicate.skip_binder().trait_ref.self_ty(),
618            |impl_def_id| {
619                // Before we create the generic parameters and everything, first
620                // consider a "quick reject". This avoids creating more types
621                // and so forth that we need to.
622                let impl_trait_header = self.tcx().impl_trait_header(impl_def_id);
623                if !drcx
624                    .args_may_unify(obligation_args, impl_trait_header.trait_ref.skip_binder().args)
625                {
626                    return;
627                }
628
629                // For every `default impl`, there's always a non-default `impl`
630                // that will *also* apply. There's no reason to register a candidate
631                // for this impl, since it is *not* proof that the trait goal holds.
632                if self.tcx().defaultness(impl_def_id).is_default() {
633                    return;
634                }
635
636                if self.reject_fn_ptr_impls(
637                    impl_def_id,
638                    obligation,
639                    impl_trait_header.trait_ref.skip_binder().self_ty(),
640                ) {
641                    return;
642                }
643
644                self.infcx.probe(|_| {
645                    if let Ok(_args) = self.match_impl(impl_def_id, impl_trait_header, obligation) {
646                        candidates.vec.push(ImplCandidate(impl_def_id));
647                    }
648                });
649            },
650        );
651    }
652
653    /// The various `impl<T: FnPtr> Trait for T` in libcore are more like builtin impls for all function items
654    /// and function pointers and less like blanket impls. Rejecting them when they can't possibly apply (because
655    /// the obligation's self-type does not implement `FnPtr`) avoids reporting that the self type does not implement
656    /// `FnPtr`, when we wanted to report that it doesn't implement `Trait`.
657    {}
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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                ::tracing_core::__macro_support::Option::Some(657u32),
                                ::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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:677",
                                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                                    ::tracing::Level::TRACE,
                                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                                    ::tracing_core::__macro_support::Option::Some(677u32),
                                                    ::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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:657",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(657u32),
                        ::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)]
658    fn reject_fn_ptr_impls(
659        &mut self,
660        impl_def_id: DefId,
661        obligation: &PolyTraitObligation<'tcx>,
662        impl_self_ty: Ty<'tcx>,
663    ) -> bool {
664        // Let `impl<T: FnPtr> Trait for Vec<T>` go through the normal rejection path.
665        if !matches!(impl_self_ty.kind(), ty::Param(..)) {
666            return false;
667        }
668        let Some(fn_ptr_trait) = self.tcx().lang_items().fn_ptr_trait() else {
669            return false;
670        };
671
672        for &(clause, _) in self.tcx().clauses_of(impl_def_id).clauses {
673            let ty::ClauseKind::Trait(pred) = clause.kind().skip_binder() else { continue };
674            if fn_ptr_trait != pred.trait_ref.def_id {
675                continue;
676            }
677            trace!(?pred);
678            // Not the bound we're looking for
679            if pred.self_ty() != impl_self_ty {
680                continue;
681            }
682
683            let self_ty = obligation.self_ty().skip_binder();
684            match self_ty.kind() {
685                // Fast path to avoid evaluating an obligation that trivially holds.
686                // There may be more bounds, but these are checked by the regular path.
687                ty::FnPtr(..) => return false,
688
689                // These may potentially implement `FnPtr`
690                ty::Placeholder(..)
691                | ty::Dynamic(_, _)
692                | ty::Alias(_, _)
693                | ty::Infer(_)
694                | ty::Param(..)
695                | ty::Bound(_, _) => {}
696
697                // These can't possibly implement `FnPtr` as they are concrete types
698                // and not `FnPtr`
699                ty::Bool
700                | ty::Char
701                | ty::Int(_)
702                | ty::Uint(_)
703                | ty::Float(_)
704                | ty::Adt(_, _)
705                | ty::Foreign(_)
706                | ty::Str
707                | ty::Array(_, _)
708                | ty::Pat(_, _)
709                | ty::Slice(_)
710                | ty::RawPtr(_, _)
711                | ty::Ref(_, _, _)
712                | ty::Closure(..)
713                | ty::CoroutineClosure(..)
714                | ty::Coroutine(_, _)
715                | ty::CoroutineWitness(..)
716                | ty::UnsafeBinder(_)
717                | ty::Never
718                | ty::Tuple(_)
719                | ty::Error(_) => return true,
720                // FIXME: Function definitions could actually implement `FnPtr` by
721                // casting the ZST function def to a function pointer.
722                ty::FnDef(_, _) => return true,
723
724                // FIXME(scrabsha)
725                ty::View(..) => unimplemented!(),
726            }
727
728            // Generic params can implement `FnPtr` if the predicate
729            // holds within its own environment.
730            let obligation = Obligation::new(
731                self.tcx(),
732                obligation.cause.clone(),
733                obligation.param_env,
734                self.tcx().mk_predicate(obligation.predicate.map_bound(|mut pred| {
735                    pred.trait_ref =
736                        ty::TraitRef::new(self.tcx(), fn_ptr_trait, [pred.trait_ref.self_ty()]);
737                    ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred))
738                })),
739            );
740            if let Ok(r) = self.evaluate_root_obligation(&obligation) {
741                if !r.may_apply() {
742                    return true;
743                }
744            }
745        }
746        false
747    }
748
749    fn assemble_candidates_from_auto_impls(
750        &mut self,
751        obligation: &PolyTraitObligation<'tcx>,
752        candidates: &mut SelectionCandidateSet<'tcx>,
753    ) {
754        // Okay to skip binder here because the tests we do below do not involve bound regions.
755        let self_ty = obligation.self_ty().skip_binder();
756        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:756",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(756u32),
                        ::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");
757
758        let def_id = obligation.predicate.def_id();
759
760        let mut check_impls = || {
761            // Only consider auto impls if there are no manual impls for the root of `self_ty`.
762            //
763            // For example, we only consider auto candidates for `&i32: Auto` if no explicit impl
764            // for `&SomeType: Auto` exists. Due to E0321 the only crate where impls
765            // for `&SomeType: Auto` can be defined is the crate where `Auto` has been defined.
766            //
767            // Generally, we have to guarantee that for all `SimplifiedType`s the only crate
768            // which may define impls for that type is either the crate defining the type
769            // or the trait. This should be guaranteed by the orphan check.
770            let mut has_impl = false;
771            self.tcx().for_each_relevant_impl(def_id, self_ty, |_| has_impl = true);
772            if !has_impl {
773                candidates.vec.push(AutoImplCandidate)
774            }
775        };
776
777        if self.tcx().trait_is_auto(def_id) {
778            match *self_ty.kind() {
779                ty::Dynamic(..) => {
780                    // For object types, we don't know what the closed
781                    // over types are. This means we conservatively
782                    // say nothing; a candidate may be added by
783                    // `assemble_candidates_from_object_ty`.
784                }
785                ty::Foreign(..) => {
786                    // Since the contents of foreign types is unknown,
787                    // we don't add any `..` impl. Default traits could
788                    // still be provided by a manual implementation for
789                    // this trait and type.
790
791                    // Backward compatibility for default auto traits.
792                    // Test: ui/traits/default_auto_traits/extern-types.rs
793                    if self.tcx().is_implicit_trait(def_id, IncludeSizedImplicitBounds::No) {
794                        check_impls()
795                    }
796                }
797                ty::Param(..)
798                | ty::Alias(
799                    _,
800                    ty::AliasTy {
801                        kind: ty::Projection { .. } | ty::Inherent { .. } | ty::Free { .. },
802                        ..
803                    },
804                )
805                | ty::Placeholder(..)
806                | ty::Bound(..) => {
807                    // In these cases, we don't know what the actual
808                    // type is. Therefore, we cannot break it down
809                    // into its constituent types. So we don't
810                    // consider the `..` impl but instead just add no
811                    // candidates: this means that typeck will only
812                    // succeed if there is another reason to believe
813                    // that this obligation holds. That could be a
814                    // where-clause or, in the case of an object type,
815                    // it could be that the object type lists the
816                    // trait (e.g., `Foo+Send : Send`). See
817                    // `ui/typeck/typeck-default-trait-impl-send-param.rs`
818                    // for an example of a test case that exercises
819                    // this path.
820                }
821                ty::Infer(ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_)) => {
822                    // The auto impl might apply; we don't know.
823                    candidates.ambiguous = true;
824                }
825                ty::Coroutine(coroutine_def_id, _) => {
826                    if self.tcx().is_lang_item(def_id, LangItem::Unpin) {
827                        match self.tcx().coroutine_movability(coroutine_def_id) {
828                            hir::Movability::Static => {
829                                // Immovable coroutines are never `Unpin`, so
830                                // suppress the normal auto-impl candidate for it.
831                            }
832                            hir::Movability::Movable => {
833                                // Movable coroutines are always `Unpin`, so add an
834                                // unconditional builtin candidate with no sub-obligations.
835                                candidates.vec.push(BuiltinCandidate);
836                            }
837                        }
838                    } else {
839                        if self.should_stall_coroutine(coroutine_def_id) {
840                            candidates.ambiguous = true;
841                        } else {
842                            // Coroutines implement all other auto traits normally.
843                            candidates.vec.push(AutoImplCandidate);
844                        }
845                    }
846                }
847
848                ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
849                    ::rustc_span::macros::bug_impl(None,
    format_args!("asked to assemble auto trait candidates of unexpected type: {0:?}",
        self_ty), Location::caller());bug!(
850                        "asked to assemble auto trait candidates of unexpected type: {:?}",
851                        self_ty
852                    );
853                }
854
855                ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, .. }) => {
856                    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");
857
858                    if candidates.vec.iter().any(|c| #[allow(non_exhaustive_omitted_patterns)] match c {
    ProjectionCandidate { .. } => true,
    _ => false,
}matches!(c, ProjectionCandidate { .. })) {
859                        // We do not generate an auto impl candidate for `impl Trait`s which already
860                        // reference our auto trait.
861                        //
862                        // For example during candidate assembly for `impl Send: Send`, we don't have
863                        // to look at the constituent types for this opaque types to figure out that this
864                        // trivially holds.
865                        //
866                        // Note that this is only sound as projection candidates of opaque types
867                        // are always applicable for auto traits.
868                    } else if self.infcx.can_define_opaque_ty(def_id) {
869                        // We do not emit auto trait candidates for opaque types in their defining scope, as
870                        // we need to know the hidden type first, which we can't reliably know within the defining
871                        // scope.
872                        candidates.ambiguous = true;
873                    } else {
874                        candidates.vec.push(AutoImplCandidate)
875                    }
876                }
877
878                ty::CoroutineWitness(..) => {
879                    candidates.vec.push(AutoImplCandidate);
880                }
881
882                ty::Bool
883                | ty::Char
884                | ty::Int(_)
885                | ty::Uint(_)
886                | ty::Float(_)
887                | ty::Str
888                | ty::Array(_, _)
889                | ty::Pat(_, _)
890                | ty::Slice(_)
891                | ty::Adt(..)
892                | ty::RawPtr(_, _)
893                | ty::Ref(..)
894                | ty::FnDef(..)
895                | ty::FnPtr(..)
896                | ty::Closure(..)
897                | ty::CoroutineClosure(..)
898                | ty::Never
899                | ty::Tuple(_)
900                | ty::UnsafeBinder(_) => {
901                    // Only consider auto impls of unsafe traits when there are
902                    // no unsafe fields.
903                    if self.tcx().trait_def(def_id).safety.is_unsafe()
904                        && self_ty.has_unsafe_fields()
905                    {
906                        return;
907                    }
908
909                    check_impls();
910                }
911                ty::Error(_) => {
912                    candidates.vec.push(AutoImplCandidate);
913                }
914
915                // FIXME(scrabsha)
916                ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
917            }
918        }
919    }
920
921    /// Searches for impls that might apply to `obligation`.
922    fn assemble_candidates_from_object_ty(
923        &mut self,
924        obligation: &PolyTraitObligation<'tcx>,
925        candidates: &mut SelectionCandidateSet<'tcx>,
926    ) {
927        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:927",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(927u32),
                        ::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!(
928            self_ty = ?obligation.self_ty().skip_binder(),
929            "assemble_candidates_from_object_ty",
930        );
931
932        if self.tcx().is_sizedness_trait(obligation.predicate.def_id()) {
933            // `dyn MetaSized` is valid, but should get its `MetaSized` impl from
934            // being `dyn` (SizedCandidate), not from the object candidate.
935            return;
936        }
937
938        self.infcx.probe(|_snapshot| {
939            let poly_trait_predicate =
940                self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
941            self.infcx.enter_forall(poly_trait_predicate, |placeholder_trait_predicate| {
942                let self_ty = placeholder_trait_predicate.self_ty();
943                let principal_trait_ref = match self_ty.kind() {
944                    ty::Dynamic(data, ..) => {
945                        if data.auto_traits().any(|did| did == obligation.predicate.def_id()) {
946                            {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:946",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(946u32),
                        ::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!(
947                                "assemble_candidates_from_object_ty: matched builtin bound, \
948                             pushing candidate"
949                            );
950                            candidates.vec.push(BuiltinObjectCandidate);
951                            return;
952                        }
953
954                        if let Some(principal) = data.principal() {
955                            principal.with_self_ty(self.tcx(), self_ty)
956                        } else {
957                            // Only auto trait bounds exist.
958                            return;
959                        }
960                    }
961                    ty::Infer(ty::TyVar(_)) => {
962                        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:962",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(962u32),
                        ::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");
963                        candidates.ambiguous = true; // could wind up being an object type
964                        return;
965                    }
966                    _ => return,
967                };
968
969                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:969",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(969u32),
                        ::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");
970
971                // Count only those upcast versions that match the trait-ref
972                // we are looking for. Specifically, do not only check for the
973                // correct trait, but also the correct type parameters.
974                // For example, we may be trying to upcast `Foo` to `Bar<i32>`,
975                // but `Foo` is declared as `trait Foo: Bar<u32>`.
976                let candidate_supertraits = util::supertraits(self.tcx(), principal_trait_ref)
977                    .enumerate()
978                    .filter(|&(_, upcast_trait_ref)| {
979                        self.infcx.probe(|_| {
980                            self.match_normalize_trait_ref(
981                                obligation,
982                                placeholder_trait_predicate.trait_ref,
983                                upcast_trait_ref,
984                            )
985                            .is_ok()
986                        })
987                    })
988                    .map(|(idx, _)| ObjectCandidate(idx));
989
990                candidates.vec.extend(candidate_supertraits);
991            })
992        })
993    }
994
995    /// Searches for unsizing that might apply to `obligation`.
996    fn assemble_candidates_for_unsizing(
997        &mut self,
998        obligation: &PolyTraitObligation<'tcx>,
999        candidates: &mut SelectionCandidateSet<'tcx>,
1000    ) {
1001        // We currently never consider higher-ranked obligations e.g.
1002        // `for<'a> &'a T: Unsize<Trait+'a>` to be implemented. This is not
1003        // because they are a priori invalid, and we could potentially add support
1004        // for them later, it's just that there isn't really a strong need for it.
1005        // A `T: Unsize<U>` obligation is always used as part of a `T: CoerceUnsize<U>`
1006        // impl, and those are generally applied to concrete types.
1007        //
1008        // That said, one might try to write a fn with a where clause like
1009        //     for<'a> Foo<'a, T>: Unsize<Foo<'a, Trait>>
1010        // where the `'a` is kind of orthogonal to the relevant part of the `Unsize`.
1011        // Still, you'd be more likely to write that where clause as
1012        //     T: Trait
1013        // so it seems ok if we (conservatively) fail to accept that `Unsize`
1014        // obligation above. Should be possible to extend this in the future.
1015        let Some(trait_pred) = obligation.predicate.no_bound_vars() else {
1016            // Don't add any candidates if there are bound regions.
1017            return;
1018        };
1019        let source = trait_pred.self_ty();
1020        let target = trait_pred.trait_ref.args.type_at(1);
1021
1022        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:1022",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(1022u32),
                        ::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");
1023
1024        match (source.kind(), target.kind()) {
1025            // Trait+Kx+'a -> Trait+Ky+'b (upcasts).
1026            (&ty::Dynamic(a_data, a_region), &ty::Dynamic(b_data, b_region)) => {
1027                // Upcast coercions permit several things:
1028                //
1029                // 1. Dropping auto traits, e.g., `Foo + Send` to `Foo`
1030                // 2. Tightening the region bound, e.g., `Foo + 'a` to `Foo + 'b` if `'a: 'b`
1031                // 3. Tightening trait to its super traits, eg. `Foo` to `Bar` if `Foo: Bar`
1032                //
1033                // Note that neither of the first two of these changes requires any
1034                // change at runtime. The third needs to change pointer metadata at runtime.
1035                //
1036                // We always perform upcasting coercions when we can because of reason
1037                // #2 (region bounds).
1038                let principal_def_id_a = a_data.principal_def_id();
1039                let principal_def_id_b = b_data.principal_def_id();
1040                if principal_def_id_a == principal_def_id_b || principal_def_id_b.is_none() {
1041                    // We may upcast to auto traits that are either explicitly listed in
1042                    // the object type's bounds, or implied by the principal trait ref's
1043                    // supertraits.
1044                    let a_auto_traits: FxIndexSet<DefId> = a_data
1045                        .auto_traits()
1046                        .chain(
1047                            principal_def_id_a
1048                                .map(|principal_def_id| {
1049                                    elaborate::supertrait_def_ids(self.tcx(), principal_def_id)
1050                                        .filter(|def_id| self.tcx().trait_is_auto(*def_id))
1051                                })
1052                                .into_flat_iter(),
1053                        )
1054                        .collect();
1055                    let auto_traits_compatible = b_data
1056                        .auto_traits()
1057                        // All of a's auto traits need to be in b's auto traits.
1058                        .all(|b| a_auto_traits.contains(&b));
1059                    if auto_traits_compatible {
1060                        candidates.vec.push(BuiltinUnsizeCandidate);
1061                    }
1062                } else if principal_def_id_a.is_some() && principal_def_id_b.is_some() {
1063                    // not casual unsizing, now check whether this is trait upcasting coercion.
1064                    let principal_a = a_data.principal().unwrap();
1065                    let target_trait_did = principal_def_id_b.unwrap();
1066                    let source_trait_ref = principal_a.with_self_ty(self.tcx(), source);
1067
1068                    for (idx, upcast_trait_ref) in
1069                        util::supertraits(self.tcx(), source_trait_ref).enumerate()
1070                    {
1071                        self.infcx.probe(|_| {
1072                            if upcast_trait_ref.def_id() == target_trait_did
1073                                && let Ok(nested) = self.match_upcast_principal(
1074                                    obligation,
1075                                    ty::Unnormalized::new_wip(upcast_trait_ref),
1076                                    a_data,
1077                                    b_data,
1078                                    a_region,
1079                                    b_region,
1080                                )
1081                            {
1082                                if nested.is_none() {
1083                                    candidates.ambiguous = true;
1084                                }
1085                                candidates.vec.push(TraitUpcastingUnsizeCandidate(idx));
1086                            }
1087                        })
1088                    }
1089                }
1090            }
1091
1092            // `T` -> `Trait`
1093            (_, &ty::Dynamic(_, _)) => {
1094                candidates.vec.push(BuiltinUnsizeCandidate);
1095            }
1096
1097            // Ambiguous handling is below `T` -> `Trait`, because inference
1098            // variables can still implement `Unsize<Trait>` and nested
1099            // obligations will have the final say (likely deferred).
1100            (&ty::Infer(ty::TyVar(_)), _) | (_, &ty::Infer(ty::TyVar(_))) => {
1101                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:1101",
                        "rustc_trait_selection::traits::select::candidate_assembly",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                        ::tracing_core::__macro_support::Option::Some(1101u32),
                        ::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");
1102                candidates.ambiguous = true;
1103            }
1104
1105            // `[T; n]` -> `[T]`
1106            (&ty::Array(..), &ty::Slice(_)) => {
1107                candidates.vec.push(BuiltinUnsizeCandidate);
1108            }
1109
1110            // `Struct<T>` -> `Struct<U>`
1111            (&ty::Adt(def_id_a, _), &ty::Adt(def_id_b, _)) if def_id_a.is_struct() => {
1112                if def_id_a == def_id_b {
1113                    candidates.vec.push(BuiltinUnsizeCandidate);
1114                }
1115            }
1116
1117            _ => {}
1118        };
1119    }
1120
1121    {}
#[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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1121u32),
                                    ::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))]
1122    fn assemble_candidates_for_transmutability(
1123        &mut self,
1124        obligation: &PolyTraitObligation<'tcx>,
1125        candidates: &mut SelectionCandidateSet<'tcx>,
1126    ) {
1127        if obligation.predicate.has_non_region_param() {
1128            return;
1129        }
1130
1131        if obligation.has_non_region_infer() {
1132            candidates.ambiguous = true;
1133            return;
1134        }
1135
1136        candidates.vec.push(TransmutabilityCandidate);
1137    }
1138
1139    {}
#[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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1139u32),
                                    ::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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:1147",
                                    "rustc_trait_selection::traits::select::candidate_assembly",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1147u32),
                                    ::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))]
1140    fn assemble_candidates_for_trait_alias(
1141        &mut self,
1142        obligation: &PolyTraitObligation<'tcx>,
1143        candidates: &mut SelectionCandidateSet<'tcx>,
1144    ) {
1145        // Okay to skip binder here because the tests we do below do not involve bound regions.
1146        let self_ty = obligation.self_ty().skip_binder();
1147        debug!(?self_ty);
1148
1149        let def_id = obligation.predicate.def_id();
1150
1151        if self.tcx().is_trait_alias(def_id) {
1152            candidates.vec.push(TraitAliasCandidate);
1153        }
1154    }
1155
1156    /// Assembles `Copy` and `Clone` candidates for built-in types with no libcore-defined
1157    /// `Copy` or `Clone` impls.
1158    {}
#[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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1158u32),
                                    ::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))]
1159    fn assemble_builtin_copy_clone_candidate(
1160        &mut self,
1161        self_ty: Ty<'tcx>,
1162        candidates: &mut SelectionCandidateSet<'tcx>,
1163    ) {
1164        match *self_ty.kind() {
1165            // These impls are built-in because we cannot express sufficiently
1166            // generic impls in libcore.
1167            ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) | ty::Tuple(..) | ty::Pat(..) => {
1168                candidates.vec.push(BuiltinCandidate);
1169            }
1170
1171            // Implementations provided in libcore.
1172            ty::Uint(_)
1173            | ty::Int(_)
1174            | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1175            | ty::Bool
1176            | ty::Float(_)
1177            | ty::Char
1178            | ty::RawPtr(..)
1179            | ty::Never
1180            | ty::Ref(_, _, hir::Mutability::Not)
1181            | ty::Array(..) => {}
1182
1183            // FIXME(unsafe_binder): Should we conditionally
1184            // (i.e. universally) implement copy/clone?
1185            ty::UnsafeBinder(_) => {}
1186
1187            // Not `Sized`, which is a supertrait of `Copy`/`Clone`.
1188            ty::Dynamic(..) | ty::Str | ty::Slice(..) | ty::Foreign(..) => {}
1189
1190            // Not `Copy` or `Clone` by design.
1191            ty::Ref(_, _, hir::Mutability::Mut) => {}
1192
1193            ty::Coroutine(coroutine_def_id, args) => {
1194                if self.should_stall_coroutine(coroutine_def_id) {
1195                    candidates.ambiguous = true;
1196                    return;
1197                }
1198
1199                match self.tcx().coroutine_movability(coroutine_def_id) {
1200                    hir::Movability::Static => {}
1201                    hir::Movability::Movable => {
1202                        if self.tcx().features().coroutine_clone() {
1203                            let resolved_upvars =
1204                                self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
1205                            if resolved_upvars.is_ty_var() {
1206                                // Not yet resolved.
1207                                candidates.ambiguous = true;
1208                            } else {
1209                                candidates.vec.push(BuiltinCandidate);
1210                            }
1211                        }
1212                    }
1213                }
1214            }
1215
1216            ty::Closure(_, args) => {
1217                let resolved_upvars =
1218                    self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
1219                if resolved_upvars.is_ty_var() {
1220                    // Not yet resolved.
1221                    candidates.ambiguous = true;
1222                } else {
1223                    candidates.vec.push(BuiltinCandidate);
1224                }
1225            }
1226
1227            ty::CoroutineClosure(_, args) => {
1228                let resolved_upvars =
1229                    self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
1230                if resolved_upvars.is_ty_var() {
1231                    // Not yet resolved.
1232                    candidates.ambiguous = true;
1233                } else {
1234                    candidates.vec.push(BuiltinCandidate);
1235                }
1236            }
1237
1238            ty::CoroutineWitness(..) => {
1239                candidates.vec.push(SizedCandidate);
1240            }
1241
1242            // Fallback to whatever user-defined impls or param-env clauses exist in this case.
1243            ty::Adt(..) | ty::Alias(..) | ty::Param(..) | ty::Placeholder(..) => {}
1244
1245            ty::Infer(ty::TyVar(_)) => {
1246                candidates.ambiguous = true;
1247            }
1248
1249            // Only appears when assembling higher-ranked `for<T> T: Clone`.
1250            ty::Bound(..) => {}
1251
1252            ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1253                bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
1254            }
1255
1256            // FIXME(scrabsha)
1257            ty::View(..) => unimplemented!(),
1258        }
1259    }
1260
1261    /// Assembles the `Sized` and `MetaSized` traits which are built-in to the language itself.
1262    {}
#[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/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1262u32),
                                    ::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))]
1263    fn assemble_builtin_sized_candidate(
1264        &mut self,
1265        self_ty: Ty<'tcx>,
1266        candidates: &mut SelectionCandidateSet<'tcx>,
1267        sizedness: SizedTraitKind,
1268    ) {
1269        match *self_ty.kind() {
1270            // Always sized.
1271            ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1272            | ty::Uint(_)
1273            | ty::Int(_)
1274            | ty::Bool
1275            | ty::Float(_)
1276            | ty::FnDef(..)
1277            | ty::FnPtr(..)
1278            | ty::RawPtr(..)
1279            | ty::Char
1280            | ty::Ref(..)
1281            | ty::Array(..)
1282            | ty::Closure(..)
1283            | ty::CoroutineClosure(..)
1284            | ty::Never
1285            | ty::Error(_) => {
1286                candidates.vec.push(SizedCandidate);
1287            }
1288
1289            ty::Coroutine(coroutine_def_id, _) => {
1290                if self.should_stall_coroutine(coroutine_def_id) {
1291                    candidates.ambiguous = true;
1292                } else {
1293                    candidates.vec.push(SizedCandidate);
1294                }
1295            }
1296
1297            ty::CoroutineWitness(..) => {
1298                candidates.vec.push(SizedCandidate);
1299            }
1300
1301            // Conditionally `Sized`.
1302            ty::Tuple(..) | ty::Pat(..) | ty::Adt(..) | ty::UnsafeBinder(_) => {
1303                candidates.vec.push(SizedCandidate);
1304            }
1305
1306            // `MetaSized` but not `Sized`.
1307            ty::Str | ty::Slice(_) | ty::Dynamic(..) => match sizedness {
1308                SizedTraitKind::Sized => {}
1309                SizedTraitKind::MetaSized => {
1310                    candidates.vec.push(SizedCandidate);
1311                }
1312            },
1313
1314            // Not `MetaSized` or `Sized`.
1315            ty::Foreign(..) | ty::View(..) => {}
1316
1317            ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => {}
1318
1319            ty::Infer(ty::TyVar(_)) => {
1320                candidates.ambiguous = true;
1321            }
1322
1323            // Only appears when assembling higher-ranked `for<T> T: Sized`.
1324            ty::Bound(..) => {}
1325
1326            ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1327                bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
1328            }
1329        }
1330    }
1331
1332    fn assemble_const_destruct_candidates(
1333        &mut self,
1334        _obligation: &PolyTraitObligation<'tcx>,
1335        candidates: &mut SelectionCandidateSet<'tcx>,
1336    ) {
1337        candidates.vec.push(BuiltinCandidate);
1338    }
1339
1340    fn assemble_candidate_for_tuple(
1341        &mut self,
1342        obligation: &PolyTraitObligation<'tcx>,
1343        candidates: &mut SelectionCandidateSet<'tcx>,
1344    ) {
1345        let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
1346        match self_ty.kind() {
1347            ty::Tuple(_) => {
1348                candidates.vec.push(BuiltinCandidate);
1349            }
1350            ty::Infer(ty::TyVar(_)) => {
1351                candidates.ambiguous = true;
1352            }
1353            ty::Bool
1354            | ty::Char
1355            | ty::Int(_)
1356            | ty::Uint(_)
1357            | ty::Float(_)
1358            | ty::Adt(_, _)
1359            | ty::Foreign(_)
1360            | ty::Str
1361            | ty::Array(_, _)
1362            | ty::Slice(_)
1363            | ty::RawPtr(_, _)
1364            | ty::Ref(_, _, _)
1365            | ty::FnDef(_, _)
1366            | ty::Pat(_, _)
1367            | ty::FnPtr(..)
1368            | ty::UnsafeBinder(_)
1369            | ty::Dynamic(_, _)
1370            | ty::Closure(..)
1371            | ty::CoroutineClosure(..)
1372            | ty::Coroutine(_, _)
1373            | ty::CoroutineWitness(..)
1374            | ty::Never
1375            | ty::Alias(..)
1376            | ty::Param(_)
1377            | ty::Bound(_, _)
1378            | ty::Error(_)
1379            | ty::Infer(_)
1380            | ty::Placeholder(_) => {}
1381
1382            // FIXME(scrabsha)
1383            ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
1384        }
1385    }
1386
1387    fn assemble_candidates_for_fn_ptr_trait(
1388        &mut self,
1389        obligation: &PolyTraitObligation<'tcx>,
1390        candidates: &mut SelectionCandidateSet<'tcx>,
1391    ) {
1392        let self_ty = self.infcx.deeply_resolve_ignoring_regions(obligation.self_ty());
1393
1394        match self_ty.skip_binder().kind() {
1395            ty::FnPtr(..) => candidates.vec.push(BuiltinCandidate),
1396            ty::Bool
1397            | ty::Char
1398            | ty::Int(_)
1399            | ty::Uint(_)
1400            | ty::Float(_)
1401            | ty::Adt(..)
1402            | ty::Foreign(..)
1403            | ty::Str
1404            | ty::Array(..)
1405            | ty::Pat(..)
1406            | ty::Slice(_)
1407            | ty::RawPtr(_, _)
1408            | ty::Ref(..)
1409            | ty::FnDef(..)
1410            | ty::Placeholder(..)
1411            | ty::Dynamic(..)
1412            | ty::Closure(..)
1413            | ty::CoroutineClosure(..)
1414            | ty::Coroutine(..)
1415            | ty::CoroutineWitness(..)
1416            | ty::UnsafeBinder(_)
1417            | ty::Never
1418            | ty::Tuple(..)
1419            | ty::Alias(..)
1420            | ty::Param(..)
1421            | ty::Bound(..)
1422            | ty::Error(_)
1423            | ty::Infer(
1424                ty::InferTy::IntVar(_)
1425                | ty::InferTy::FloatVar(_)
1426                | ty::InferTy::FreshIntTy(_)
1427                | ty::InferTy::FreshFloatTy(_),
1428            ) => {}
1429            ty::Infer(ty::InferTy::TyVar(_) | ty::InferTy::FreshTy(_)) => {
1430                candidates.ambiguous = true;
1431            }
1432
1433            // FIXME(scrabsha)
1434            ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
1435        }
1436    }
1437
1438    fn assemble_candidates_for_fn_static_trait(
1439        &mut self,
1440        obligation: &PolyTraitObligation<'tcx>,
1441        candidates: &mut SelectionCandidateSet<'tcx>,
1442    ) {
1443        let self_ty = self.infcx.deeply_resolve_ignoring_regions(obligation.self_ty());
1444
1445        match *self_ty.skip_binder().kind() {
1446            ty::FnDef(_, _) => candidates.vec.push(BuiltinCandidate),
1447            ty::Infer(ty::InferTy::TyVar(_) | ty::InferTy::FreshTy(_)) => {
1448                candidates.ambiguous = true;
1449            }
1450            _ => {}
1451        }
1452    }
1453
1454    fn assemble_candidates_for_bikeshed_guaranteed_no_drop_trait(
1455        &mut self,
1456        obligation: &PolyTraitObligation<'tcx>,
1457        candidates: &mut SelectionCandidateSet<'tcx>,
1458    ) {
1459        match obligation.predicate.self_ty().skip_binder().kind() {
1460            ty::Ref(..)
1461            | ty::Adt(..)
1462            | ty::Tuple(_)
1463            | ty::Array(..)
1464            | ty::FnDef(..)
1465            | ty::FnPtr(..)
1466            | ty::Error(_)
1467            | ty::Uint(_)
1468            | ty::Int(_)
1469            | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1470            | ty::Bool
1471            | ty::Float(_)
1472            | ty::Char
1473            | ty::RawPtr(..)
1474            | ty::Never
1475            | ty::Pat(..)
1476            | ty::Dynamic(..)
1477            | ty::Str
1478            | ty::Slice(_)
1479            | ty::Foreign(..)
1480            | ty::Alias(..)
1481            | ty::Param(_)
1482            | ty::Placeholder(..)
1483            | ty::Closure(..)
1484            | ty::CoroutineClosure(..)
1485            | ty::Coroutine(..)
1486            | ty::UnsafeBinder(_)
1487            | ty::CoroutineWitness(..)
1488            | ty::Bound(..) => {
1489                candidates.vec.push(BikeshedGuaranteedNoDropCandidate);
1490            }
1491
1492            ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1493                candidates.ambiguous = true;
1494            }
1495
1496            // FIXME(scrabsha)
1497            ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
1498        }
1499    }
1500
1501    fn assemble_candidates_for_try_as_dyn(
1502        &mut self,
1503        obligation: &PolyTraitObligation<'tcx>,
1504        candidates: &mut SelectionCandidateSet<'tcx>,
1505    ) {
1506        match *obligation.predicate.self_ty().skip_binder().kind() {
1507            ty::Dynamic(bounds, _lifetime) => {
1508                for bound in bounds {
1509                    match bound.skip_binder() {
1510                        ExistentialPredicate::Trait(_) => {}
1511                        // FIXME(try_as_dyn): check what kind of projections we can allow
1512                        ExistentialPredicate::Projection(_) => return,
1513                        // Auto traits do not affect lifetimes outside of specialization,
1514                        // which is disabled in reflection.
1515                        ExistentialPredicate::AutoTrait(_) => {}
1516                    }
1517                }
1518                candidates.vec.push(TryAsDynCandidate);
1519            }
1520
1521            ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1522                candidates.ambiguous = true;
1523            }
1524
1525            _ => {}
1526        }
1527    }
1528
1529    fn assemble_candidates_for_field_trait(
1530        &mut self,
1531        obligation: &PolyTraitObligation<'tcx>,
1532        candidates: &mut SelectionCandidateSet<'tcx>,
1533    ) {
1534        // FIXME(field_projections): We should not use `evaluate_obligation` in
1535        // the trait solver. Doing so means we don't track overflow and cycles properly
1536        // encountering query cycles instead.
1537        if let ty::Adt(def, args) = obligation.predicate.self_ty().skip_binder().kind()
1538            && let Some(FieldInfo { base, ty, .. }) =
1539                def.field_representing_type_info(self.tcx(), *args)
1540            // NOTE: these bounds have to be kept in sync with the definition of the `Field` trait
1541            // in `library/core/src/field.rs` as well as the new trait solver `fn
1542            // consider_builtin_field_candidate` in
1543            // `compiler/rustc_next_trait_solver/src/solve/trait_goals.rs`.
1544            && match self.infcx.evaluate_obligation(&PredicateObligation::new(
1545                self.tcx(),
1546                obligation.cause.clone(),
1547                obligation.param_env,
1548                TraitRef::new(
1549                    self.tcx(),
1550                    self.tcx().require_lang_item(LangItem::Sized, DUMMY_SP),
1551                    [base],
1552                ),
1553            )) {
1554                Ok(res) if res.must_apply_modulo_regions() => true,
1555                _ => false,
1556            }
1557            && match self.infcx.evaluate_obligation(&PredicateObligation::new(
1558                self.tcx(),
1559                obligation.cause.clone(),
1560                obligation.param_env,
1561                TraitRef::new(
1562                    self.tcx(),
1563                    self.tcx().require_lang_item(LangItem::Sized, DUMMY_SP),
1564                    [ty],
1565                ),
1566            )) {
1567                Ok(res) if res.must_apply_modulo_regions() => true,
1568                _ => false,
1569            }
1570            && match base.kind() {
1571                ty::Adt(def, _) => def.is_struct() && !def.repr().packed(),
1572                ty::Tuple(..) => true,
1573                _ => false,
1574            }
1575        {
1576            candidates.vec.push(BuiltinCandidate);
1577        }
1578    }
1579}