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