1use std::ops::ControlFlow;
10
11use hir::def_id::DefId;
12use rustc_attr_ir::lang_items::LangItem;
13use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
14use rustc_hir::{self as hir, CoroutineDesugaring, CoroutineKind};
15use rustc_infer::traits::{Obligation, PolyTraitObligation, PredicateObligation, SelectionError};
16use rustc_middle::ty::fast_reject::DeepRejectCtxt;
17use rustc_middle::ty::{
18 self, ExistentialPredicate, FieldInfo, SizedTraitKind, TraitRef, Ty, TypeVisitableExt,
19 elaborate,
20};
21use rustc_span::{DUMMY_SP, bug, span_bug};
22use tracing::{debug, instrument, trace};
23
24use super::SelectionCandidate::*;
25use super::{SelectionCandidateSet, SelectionContext, TraitObligationStack};
26use crate::traits::query::evaluate_obligation::InferCtxtExt;
27use crate::traits::util;
28
29impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
30 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("assemble_candidates",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(30u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
::tracing_core::field::FieldSet::new(&[],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{ meta.fields().value_set_all(&[]) })
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<SelectionCandidateSet<'tcx>, SelectionError<'tcx>> =
loop {};
return __tracing_attr_fake_return;
}
{
let TraitObligationStack { obligation, .. } = *stack;
let obligation =
&Obligation {
param_env: obligation.param_env,
cause: obligation.cause.clone(),
recursion_depth: obligation.recursion_depth,
predicate: self.infcx.deeply_resolve_ignoring_regions(obligation.predicate),
};
if obligation.predicate.skip_binder().self_ty().is_ty_var() {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:44",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(44u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("ty")
}> =
::tracing::__macro_support::FieldName::new("ty");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("ambiguous inference var or opaque type")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation.predicate.skip_binder().self_ty())
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
return Ok(SelectionCandidateSet {
vec: ::alloc::vec::Vec::new(),
ambiguous: true,
});
}
let mut candidates =
SelectionCandidateSet { vec: Vec::new(), ambiguous: false };
if obligation.polarity() == ty::ClausePolarity::Negative {
self.assemble_candidates_for_trait_alias(obligation,
&mut candidates);
self.assemble_candidates_from_impls(obligation,
&mut candidates);
self.assemble_candidates_from_caller_bounds(stack,
&mut candidates)?;
} else {
self.assemble_candidates_for_trait_alias(obligation,
&mut candidates);
let def_id = obligation.predicate.def_id();
let tcx = self.tcx();
let lang_item = tcx.as_lang_item(def_id);
match lang_item {
Some(LangItem::Copy | LangItem::Clone |
LangItem::TrivialClone) => {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:75",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(75u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation_self_ty")
}> =
::tracing::__macro_support::FieldName::new("obligation_self_ty");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation.predicate.skip_binder().self_ty())
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.assemble_candidates_from_impls(obligation,
&mut candidates);
self.assemble_builtin_copy_clone_candidate(obligation.predicate.self_ty().skip_binder(),
&mut candidates);
}
Some(LangItem::DiscriminantKind) => {
candidates.vec.push(BuiltinCandidate);
}
Some(LangItem::PointeeTrait) => {
candidates.vec.push(BuiltinCandidate);
}
Some(LangItem::Sized) => {
self.assemble_builtin_sized_candidate(obligation.predicate.self_ty().skip_binder(),
&mut candidates, SizedTraitKind::Sized);
}
Some(LangItem::MetaSized) => {
self.assemble_builtin_sized_candidate(obligation.predicate.self_ty().skip_binder(),
&mut candidates, SizedTraitKind::MetaSized);
}
Some(LangItem::PointeeSized) => {
::rustc_span::macros::bug_impl(None,
format_args!("`PointeeSized` is removed during lowering"),
Location::caller());
}
Some(LangItem::Unsize) => {
self.assemble_candidates_for_unsizing(obligation,
&mut candidates);
}
Some(LangItem::Destruct) => {
self.assemble_const_destruct_candidates(obligation,
&mut candidates);
}
Some(LangItem::TransmuteTrait) => {
self.assemble_candidates_from_impls(obligation,
&mut candidates);
self.assemble_candidates_for_transmutability(obligation,
&mut candidates);
}
Some(LangItem::Tuple) => {
self.assemble_candidate_for_tuple(obligation,
&mut candidates);
}
Some(LangItem::FnPtrTrait) => {
self.assemble_candidates_for_fn_ptr_trait(obligation,
&mut candidates);
}
Some(LangItem::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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:186",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(186u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("candidate list size: {0}",
candidates.vec.len()) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
Ok(candidates)
}
}
}#[instrument(skip(self, stack), level = "debug")]
31 pub(super) fn assemble_candidates<'o>(
32 &mut self,
33 stack: &TraitObligationStack<'o, 'tcx>,
34 ) -> Result<SelectionCandidateSet<'tcx>, SelectionError<'tcx>> {
35 let TraitObligationStack { obligation, .. } = *stack;
36 let obligation = &Obligation {
37 param_env: obligation.param_env,
38 cause: obligation.cause.clone(),
39 recursion_depth: obligation.recursion_depth,
40 predicate: self.infcx.deeply_resolve_ignoring_regions(obligation.predicate),
41 };
42
43 if obligation.predicate.skip_binder().self_ty().is_ty_var() {
44 debug!(ty = ?obligation.predicate.skip_binder().self_ty(), "ambiguous inference var or opaque type");
45 return Ok(SelectionCandidateSet { vec: vec![], ambiguous: true });
55 }
56
57 let mut candidates = SelectionCandidateSet { vec: Vec::new(), ambiguous: false };
58
59 if obligation.polarity() == ty::ClausePolarity::Negative {
61 self.assemble_candidates_for_trait_alias(obligation, &mut candidates);
62 self.assemble_candidates_from_impls(obligation, &mut candidates);
63 self.assemble_candidates_from_caller_bounds(stack, &mut candidates)?;
64 } else {
65 self.assemble_candidates_for_trait_alias(obligation, &mut candidates);
66
67 let def_id = obligation.predicate.def_id();
70 let tcx = self.tcx();
71
72 let lang_item = tcx.as_lang_item(def_id);
73 match lang_item {
74 Some(LangItem::Copy | LangItem::Clone | LangItem::TrivialClone) => {
75 debug!(obligation_self_ty = ?obligation.predicate.skip_binder().self_ty());
76
77 self.assemble_candidates_from_impls(obligation, &mut candidates);
80
81 self.assemble_builtin_copy_clone_candidate(
83 obligation.predicate.self_ty().skip_binder(),
84 &mut candidates,
85 );
86 }
87 Some(LangItem::DiscriminantKind) => {
88 candidates.vec.push(BuiltinCandidate);
90 }
91 Some(LangItem::PointeeTrait) => {
92 candidates.vec.push(BuiltinCandidate);
94 }
95 Some(LangItem::Sized) => {
96 self.assemble_builtin_sized_candidate(
97 obligation.predicate.self_ty().skip_binder(),
98 &mut candidates,
99 SizedTraitKind::Sized,
100 );
101 }
102 Some(LangItem::MetaSized) => {
103 self.assemble_builtin_sized_candidate(
104 obligation.predicate.self_ty().skip_binder(),
105 &mut candidates,
106 SizedTraitKind::MetaSized,
107 );
108 }
109 Some(LangItem::PointeeSized) => {
110 bug!("`PointeeSized` is removed during lowering");
111 }
112 Some(LangItem::Unsize) => {
113 self.assemble_candidates_for_unsizing(obligation, &mut candidates);
114 }
115 Some(LangItem::Destruct) => {
116 self.assemble_const_destruct_candidates(obligation, &mut candidates);
117 }
118 Some(LangItem::TransmuteTrait) => {
119 self.assemble_candidates_from_impls(obligation, &mut candidates);
121 self.assemble_candidates_for_transmutability(obligation, &mut candidates);
122 }
123 Some(LangItem::Tuple) => {
124 self.assemble_candidate_for_tuple(obligation, &mut candidates);
125 }
126 Some(LangItem::FnPtrTrait) => {
127 self.assemble_candidates_for_fn_ptr_trait(obligation, &mut candidates);
128 }
129 Some(LangItem::BikeshedGuaranteedNoDrop) => {
130 self.assemble_candidates_for_bikeshed_guaranteed_no_drop_trait(
131 obligation,
132 &mut candidates,
133 );
134 }
135 Some(LangItem::TryAsDyn) => {
136 self.assemble_candidates_for_try_as_dyn(obligation, &mut candidates);
137 }
138 Some(LangItem::Field) => {
139 self.assemble_candidates_for_field_trait(obligation, &mut candidates);
140 }
141 _ => {
142 match lang_item {
146 Some(LangItem::Coroutine) => {
147 self.assemble_coroutine_candidates(obligation, &mut candidates);
148 }
149 Some(LangItem::Future) => {
150 self.assemble_future_candidates(obligation, &mut candidates);
151 }
152 Some(LangItem::Iterator) => {
153 self.assemble_iterator_candidates(obligation, &mut candidates);
154 }
155 Some(LangItem::FusedIterator) => {
156 self.assemble_fused_iterator_candidates(obligation, &mut candidates);
157 }
158 Some(LangItem::AsyncIterator) => {
159 self.assemble_async_iterator_candidates(obligation, &mut candidates);
160 }
161 Some(LangItem::AsyncFnKindHelper) => {
162 self.assemble_async_fn_kind_helper_candidates(
163 obligation,
164 &mut candidates,
165 );
166 }
167 Some(LangItem::AsyncFn | LangItem::AsyncFnMut | LangItem::AsyncFnOnce) => {
168 self.assemble_async_closure_candidates(obligation, &mut candidates);
169 }
170 Some(LangItem::Fn | LangItem::FnMut | LangItem::FnOnce) => {
171 self.assemble_closure_candidates(obligation, &mut candidates);
172 self.assemble_fn_pointer_candidates(obligation, &mut candidates);
173 }
174 _ => {}
175 }
176
177 self.assemble_candidates_from_impls(obligation, &mut candidates);
178 self.assemble_candidates_from_object_ty(obligation, &mut candidates);
179 }
180 }
181
182 self.assemble_candidates_from_projected_tys(obligation, &mut candidates);
183 self.assemble_candidates_from_caller_bounds(stack, &mut candidates)?;
184 self.assemble_candidates_from_auto_impls(obligation, &mut candidates);
185 }
186 debug!("candidate list size: {}", candidates.vec.len());
187 Ok(candidates)
188 }
189
190 {}
#[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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(190u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
match obligation.predicate.skip_binder().trait_ref.self_ty().kind()
{
ty::Alias(_, ty::AliasTy {
kind: ty::Projection { .. } | ty::Opaque { .. }, .. }) => {}
ty::Infer(ty::TyVar(_)) => {
::rustc_span::macros::bug_impl(Some(obligation.cause.span),
format_args!("Self=_ should have been handled by assemble_candidates"),
Location::caller());
}
_ => return,
}
self.infcx.probe(|_|
{
let poly_trait_predicate =
self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
let placeholder_trait_predicate =
self.infcx.enter_forall_and_leak_universe(poly_trait_predicate);
let mut distinct_normalized_bounds = FxHashSet::default();
let _ =
self.for_each_item_bound::<!>(placeholder_trait_predicate.self_ty(),
|selcx, bound, idx, alias_bound_kind|
{
let Some(bound) =
bound.as_trait_clause() else {
return ControlFlow::Continue(());
};
if bound.polarity() != placeholder_trait_predicate.polarity
{
return ControlFlow::Continue(());
}
selcx.infcx.probe(|_|
{
let bound =
util::lazily_elaborate_sizedness_candidate(selcx.infcx,
obligation, bound);
match selcx.match_normalize_trait_ref(obligation,
placeholder_trait_predicate.trait_ref,
bound.map_bound(|pred| pred.trait_ref)) {
Ok(None) => {
candidates.vec.push(ProjectionCandidate {
idx,
kind: alias_bound_kind,
});
}
Ok(Some(normalized_trait)) if
distinct_normalized_bounds.insert(normalized_trait) => {
candidates.vec.push(ProjectionCandidate {
idx,
kind: alias_bound_kind,
});
}
_ => {}
}
});
ControlFlow::Continue(())
}, || candidates.ambiguous = true);
});
}
}
}#[instrument(level = "debug", skip(self, candidates))]
191 fn assemble_candidates_from_projected_tys(
192 &mut self,
193 obligation: &PolyTraitObligation<'tcx>,
194 candidates: &mut SelectionCandidateSet<'tcx>,
195 ) {
196 match obligation.predicate.skip_binder().trait_ref.self_ty().kind() {
199 ty::Alias(_, ty::AliasTy { kind: ty::Projection { .. } | ty::Opaque { .. }, .. }) => {}
201 ty::Infer(ty::TyVar(_)) => {
202 span_bug!(
203 obligation.cause.span,
204 "Self=_ should have been handled by assemble_candidates"
205 );
206 }
207 _ => return,
208 }
209
210 self.infcx.probe(|_| {
211 let poly_trait_predicate =
212 self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
213 let placeholder_trait_predicate =
214 self.infcx.enter_forall_and_leak_universe(poly_trait_predicate);
215
216 let mut distinct_normalized_bounds = FxHashSet::default();
220 let _ = self.for_each_item_bound::<!>(
221 placeholder_trait_predicate.self_ty(),
222 |selcx, bound, idx, alias_bound_kind| {
223 let Some(bound) = bound.as_trait_clause() else {
224 return ControlFlow::Continue(());
225 };
226 if bound.polarity() != placeholder_trait_predicate.polarity {
227 return ControlFlow::Continue(());
228 }
229
230 selcx.infcx.probe(|_| {
231 let bound = util::lazily_elaborate_sizedness_candidate(
232 selcx.infcx,
233 obligation,
234 bound,
235 );
236
237 match selcx.match_normalize_trait_ref(
239 obligation,
240 placeholder_trait_predicate.trait_ref,
241 bound.map_bound(|pred| pred.trait_ref),
242 ) {
243 Ok(None) => {
244 candidates
245 .vec
246 .push(ProjectionCandidate { idx, kind: alias_bound_kind });
247 }
248 Ok(Some(normalized_trait))
249 if distinct_normalized_bounds.insert(normalized_trait) =>
250 {
251 candidates
252 .vec
253 .push(ProjectionCandidate { idx, kind: alias_bound_kind });
254 }
255 _ => {}
256 }
257 });
258
259 ControlFlow::Continue(())
260 },
261 || candidates.ambiguous = true,
263 );
264 });
265 }
266
267 {}
#[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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(271u32),
::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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:277",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(277u32),
::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))]
272 fn assemble_candidates_from_caller_bounds<'o>(
273 &mut self,
274 stack: &TraitObligationStack<'o, 'tcx>,
275 candidates: &mut SelectionCandidateSet<'tcx>,
276 ) -> Result<(), SelectionError<'tcx>> {
277 debug!(?stack.obligation);
278
279 let bounds = stack
280 .obligation
281 .param_env
282 .caller_bounds()
283 .filter_map(|c| c.as_trait_clause())
284 .filter(|p| p.polarity() == stack.obligation.predicate.polarity());
286
287 let drcx = DeepRejectCtxt::relate_rigid_rigid(self.tcx());
288 let obligation_args = stack.obligation.predicate.skip_binder().trait_ref.args;
289 for bound in bounds {
291 let bound =
292 util::lazily_elaborate_sizedness_candidate(self.infcx, stack.obligation, bound);
293
294 if bound.def_id() != stack.obligation.predicate.def_id() {
296 continue;
297 }
298
299 let bound_trait_ref = bound.map_bound(|t| t.trait_ref);
300 if !drcx.args_may_unify(obligation_args, bound_trait_ref.skip_binder().args) {
301 continue;
302 }
303 let wc = self.where_clause_may_apply(stack, bound_trait_ref)?;
304 if wc.may_apply() {
305 candidates.vec.push(ParamCandidate(bound));
306 }
307 }
308
309 Ok(())
310 }
311
312 fn assemble_coroutine_candidates(
313 &mut self,
314 obligation: &PolyTraitObligation<'tcx>,
315 candidates: &mut SelectionCandidateSet<'tcx>,
316 ) {
317 let self_ty = obligation.self_ty().skip_binder();
321 match self_ty.kind() {
322 ty::Coroutine(did, ..) if self.tcx().is_general_coroutine(*did) => {
325 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:325",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(325u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
::tracing_core::field::FieldSet::new(&["message",
{
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");
326
327 candidates.vec.push(CoroutineCandidate);
328 }
329 ty::Infer(ty::TyVar(_)) => {
330 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:330",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(330u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
::tracing_core::field::FieldSet::new(&["message"],
::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");
331 candidates.ambiguous = true;
332 }
333 _ => {}
334 }
335 }
336
337 fn assemble_future_candidates(
338 &mut self,
339 obligation: &PolyTraitObligation<'tcx>,
340 candidates: &mut SelectionCandidateSet<'tcx>,
341 ) {
342 let self_ty = obligation.self_ty().skip_binder();
343 if let ty::Coroutine(did, ..) = self_ty.kind() {
344 if self.tcx().coroutine_is_async(*did) {
347 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:347",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(347u32),
::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");
348
349 candidates.vec.push(FutureCandidate);
350 }
351 }
352 }
353
354 fn assemble_iterator_candidates(
355 &mut self,
356 obligation: &PolyTraitObligation<'tcx>,
357 candidates: &mut SelectionCandidateSet<'tcx>,
358 ) {
359 let self_ty = obligation.self_ty().skip_binder();
360 if let ty::Coroutine(did, ..) = self_ty.kind()
363 && self.tcx().coroutine_is_gen(*did)
364 {
365 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:365",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(365u32),
::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");
366
367 candidates.vec.push(IteratorCandidate);
368 }
369 }
370
371 fn assemble_fused_iterator_candidates(
372 &mut self,
373 obligation: &PolyTraitObligation<'tcx>,
374 candidates: &mut SelectionCandidateSet<'tcx>,
375 ) {
376 if self.coroutine_is_gen(obligation.self_ty().skip_binder()) {
377 candidates.vec.push(BuiltinCandidate);
378 }
379 }
380
381 fn assemble_async_iterator_candidates(
382 &mut self,
383 obligation: &PolyTraitObligation<'tcx>,
384 candidates: &mut SelectionCandidateSet<'tcx>,
385 ) {
386 let self_ty = obligation.self_ty().skip_binder();
387 if let ty::Coroutine(did, args) = *self_ty.kind() {
388 if self.tcx().coroutine_is_async_gen(did) {
391 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:391",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(391u32),
::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");
392
393 let ty::Adt(_poll_def, args) = *args.as_coroutine().yield_ty().kind() else {
396 candidates.ambiguous = true;
397 return;
398 };
399 let ty::Adt(_option_def, _) = *args.type_at(0).kind() else {
400 candidates.ambiguous = true;
401 return;
402 };
403
404 candidates.vec.push(AsyncIteratorCandidate);
405 }
406 }
407 }
408
409 fn assemble_closure_candidates(
416 &mut self,
417 obligation: &PolyTraitObligation<'tcx>,
418 candidates: &mut SelectionCandidateSet<'tcx>,
419 ) {
420 let kind = self.tcx().fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
421
422 let self_ty = obligation.self_ty().skip_binder();
426 match *self_ty.kind() {
427 ty::Closure(def_id, _) => {
428 let is_const = self.tcx().is_const_fn(def_id);
429 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:429",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(429u32),
::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");
430 match self.infcx.closure_kind(self_ty) {
431 Some(closure_kind) => {
432 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:432",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(432u32),
::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");
433 if closure_kind.extends(kind) {
434 candidates.vec.push(ClosureCandidate { is_const });
435 }
436 }
437 None => {
438 if kind == ty::ClosureKind::FnOnce {
439 candidates.vec.push(ClosureCandidate { is_const });
440 } else {
441 candidates.ambiguous = true;
442 }
443 }
444 }
445 }
446 ty::CoroutineClosure(def_id, args) => {
447 let args = args.as_coroutine_closure();
448 let is_const = self.tcx().is_const_fn(def_id);
449 if let Some(closure_kind) = self.infcx.closure_kind(self_ty)
450 && !args.tupled_upvars_ty().is_ty_var()
452 {
453 if closure_kind.extends(kind) && !args.has_self_borrows() {
458 candidates.vec.push(ClosureCandidate { is_const });
459 } else if kind == ty::ClosureKind::FnOnce {
460 candidates.vec.push(ClosureCandidate { is_const });
461 }
462 } else if kind == ty::ClosureKind::FnOnce {
463 candidates.vec.push(ClosureCandidate { is_const });
464 } else {
465 candidates.ambiguous = true;
467 }
468 }
469 ty::Infer(ty::TyVar(_)) => {
470 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:470",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(470u32),
::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");
471 candidates.ambiguous = true;
472 }
473 _ => {}
474 }
475 }
476
477 {}
#[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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(477u32),
::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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:486",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(486u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("self_ty = {0:?}",
obligation.self_ty().skip_binder().kind()) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};
match *obligation.self_ty().skip_binder().kind() {
ty::CoroutineClosure(def_id, args) => {
if let Some(closure_kind) =
args.as_coroutine_closure().kind_ty().to_opt_closure_kind()
&& !closure_kind.extends(goal_kind) {
return;
}
let Some(coroutine_kind) =
self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(def_id)) else {
::rustc_span::macros::bug_impl(None,
format_args!("coroutine with no kind"), Location::caller());
};
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:503",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(503u32),
::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))]
478 fn assemble_async_closure_candidates(
479 &mut self,
480 obligation: &PolyTraitObligation<'tcx>,
481 candidates: &mut SelectionCandidateSet<'tcx>,
482 ) {
483 let goal_kind =
484 self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
485
486 debug!("self_ty = {:?}", obligation.self_ty().skip_binder().kind());
487 match *obligation.self_ty().skip_binder().kind() {
488 ty::CoroutineClosure(def_id, args) => {
489 if let Some(closure_kind) =
490 args.as_coroutine_closure().kind_ty().to_opt_closure_kind()
491 && !closure_kind.extends(goal_kind)
492 {
493 return;
494 }
495
496 let Some(coroutine_kind) =
498 self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(def_id))
499 else {
500 bug!("coroutine with no kind");
501 };
502
503 debug!(?coroutine_kind);
504 match coroutine_kind {
505 CoroutineKind::Desugared(CoroutineDesugaring::Async, _) => {
506 candidates.vec.push(AsyncClosureCandidate);
507 }
508 _ => (),
509 }
510 }
511 ty::Closure(_, args) => {
514 if let Some(closure_kind) = args.as_closure().kind_ty().to_opt_closure_kind()
515 && !closure_kind.extends(goal_kind)
516 {
517 return;
518 }
519 candidates.vec.push(AsyncClosureCandidate);
520 }
521 ty::FnPtr(sig_tys, hdr) => {
523 if sig_tys.with(hdr).is_fn_trait_compatible() {
524 candidates.vec.push(AsyncClosureCandidate);
525 }
526 }
527 ty::FnDef(def_id, _) => {
529 let tcx = self.tcx();
530 if tcx.fn_sig(def_id).skip_binder().is_fn_trait_compatible()
531 && tcx.codegen_fn_attrs(def_id).target_features.is_empty()
532 {
533 candidates.vec.push(AsyncClosureCandidate);
534 }
535 }
536 _ => {}
537 }
538 }
539
540 fn assemble_async_fn_kind_helper_candidates(
541 &mut self,
542 obligation: &PolyTraitObligation<'tcx>,
543 candidates: &mut SelectionCandidateSet<'tcx>,
544 ) {
545 let self_ty = obligation.self_ty().skip_binder();
546 let target_kind_ty = obligation.predicate.skip_binder().trait_ref.args.type_at(1);
547
548 if !(self_ty.is_integral() || self_ty.is_ty_var()) {
550 return;
551 }
552 if !(target_kind_ty.is_integral() || self_ty.is_ty_var()) {
553 return;
554 }
555
556 if let Some(closure_kind) = self_ty.to_opt_closure_kind()
559 && let Some(goal_kind) = target_kind_ty.to_opt_closure_kind()
560 && closure_kind.extends(goal_kind)
561 {
562 candidates.vec.push(AsyncFnKindHelperCandidate);
563 }
564 }
565
566 fn assemble_fn_pointer_candidates(
568 &mut self,
569 obligation: &PolyTraitObligation<'tcx>,
570 candidates: &mut SelectionCandidateSet<'tcx>,
571 ) {
572 let self_ty = obligation.self_ty().skip_binder();
577 match *self_ty.kind() {
578 ty::Infer(ty::TyVar(_)) => {
579 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:579",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(579u32),
::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");
580 candidates.ambiguous = true; }
582 ty::FnPtr(sig_tys, hdr) => {
584 if sig_tys.with(hdr).is_fn_trait_compatible() {
585 candidates.vec.push(FnPointerCandidate);
586 }
587 }
588 ty::FnDef(def_id, _) => {
590 let tcx = self.tcx();
591 if tcx.fn_sig(def_id).skip_binder().is_fn_trait_compatible()
592 && tcx.codegen_fn_attrs(def_id).target_features.is_empty()
593 {
594 candidates.vec.push(FnPointerCandidate);
595 }
596 }
597 _ => {}
598 }
599 }
600
601 {}
#[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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(602u32),
::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))]
603 fn assemble_candidates_from_impls(
604 &mut self,
605 obligation: &PolyTraitObligation<'tcx>,
606 candidates: &mut SelectionCandidateSet<'tcx>,
607 ) {
608 let drcx = DeepRejectCtxt::relate_rigid_infer(self.tcx());
609 let obligation_args = obligation.predicate.skip_binder().trait_ref.args;
610 self.tcx().for_each_relevant_impl(
611 obligation.predicate.def_id(),
612 obligation.predicate.skip_binder().trait_ref.self_ty(),
613 |impl_def_id| {
614 let impl_trait_header = self.tcx().impl_trait_header(impl_def_id);
618 if !drcx
619 .args_may_unify(obligation_args, impl_trait_header.trait_ref.skip_binder().args)
620 {
621 return;
622 }
623
624 if self.tcx().defaultness(impl_def_id).is_default() {
628 return;
629 }
630
631 if self.reject_fn_ptr_impls(
632 impl_def_id,
633 obligation,
634 impl_trait_header.trait_ref.skip_binder().self_ty(),
635 ) {
636 return;
637 }
638
639 self.infcx.probe(|_| {
640 if let Ok(_args) = self.match_impl(impl_def_id, impl_trait_header, obligation) {
641 candidates.vec.push(ImplCandidate(impl_def_id));
642 }
643 });
644 },
645 );
646 }
647
648 {}
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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(652u32),
::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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:672",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(672u32),
::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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:652",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(652u32),
::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)]
653 fn reject_fn_ptr_impls(
654 &mut self,
655 impl_def_id: DefId,
656 obligation: &PolyTraitObligation<'tcx>,
657 impl_self_ty: Ty<'tcx>,
658 ) -> bool {
659 if !matches!(impl_self_ty.kind(), ty::Param(..)) {
661 return false;
662 }
663 let Some(fn_ptr_trait) = self.tcx().lang_items().fn_ptr_trait() else {
664 return false;
665 };
666
667 for &(clause, _) in self.tcx().clauses_of(impl_def_id).clauses {
668 let ty::ClauseKind::Trait(pred) = clause.kind().skip_binder() else { continue };
669 if fn_ptr_trait != pred.trait_ref.def_id {
670 continue;
671 }
672 trace!(?pred);
673 if pred.self_ty() != impl_self_ty {
675 continue;
676 }
677
678 let self_ty = obligation.self_ty().skip_binder();
679 match self_ty.kind() {
680 ty::FnPtr(..) => return false,
683
684 ty::Placeholder(..)
686 | ty::Dynamic(_, _)
687 | ty::Alias(_, _)
688 | ty::Infer(_)
689 | ty::Param(..)
690 | ty::Bound(_, _) => {}
691
692 ty::Bool
695 | ty::Char
696 | ty::Int(_)
697 | ty::Uint(_)
698 | ty::Float(_)
699 | ty::Adt(_, _)
700 | ty::Foreign(_)
701 | ty::Str
702 | ty::Array(_, _)
703 | ty::Pat(_, _)
704 | ty::Slice(_)
705 | ty::RawPtr(_, _)
706 | ty::Ref(_, _, _)
707 | ty::Closure(..)
708 | ty::CoroutineClosure(..)
709 | ty::Coroutine(_, _)
710 | ty::CoroutineWitness(..)
711 | ty::UnsafeBinder(_)
712 | ty::Never
713 | ty::Tuple(_)
714 | ty::Error(_) => return true,
715 ty::FnDef(_, _) => return true,
718 }
719
720 let obligation = Obligation::new(
723 self.tcx(),
724 obligation.cause.clone(),
725 obligation.param_env,
726 self.tcx().mk_predicate(obligation.predicate.map_bound(|mut pred| {
727 pred.trait_ref =
728 ty::TraitRef::new(self.tcx(), fn_ptr_trait, [pred.trait_ref.self_ty()]);
729 ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred))
730 })),
731 );
732 if let Ok(r) = self.evaluate_root_obligation(&obligation) {
733 if !r.may_apply() {
734 return true;
735 }
736 }
737 }
738 false
739 }
740
741 fn assemble_candidates_from_auto_impls(
742 &mut self,
743 obligation: &PolyTraitObligation<'tcx>,
744 candidates: &mut SelectionCandidateSet<'tcx>,
745 ) {
746 let self_ty = obligation.self_ty().skip_binder();
748 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:748",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(748u32),
::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");
749
750 let def_id = obligation.predicate.def_id();
751
752 let mut check_impls = || {
753 let mut has_impl = false;
763 self.tcx().for_each_relevant_impl(def_id, self_ty, |_| has_impl = true);
764 if !has_impl {
765 candidates.vec.push(AutoImplCandidate)
766 }
767 };
768
769 if self.tcx().trait_is_auto(def_id) {
770 match *self_ty.kind() {
771 ty::Dynamic(..) => {
772 }
777 ty::Foreign(..) => {
778 if self.tcx().is_default_trait(def_id) {
786 check_impls()
787 }
788 }
789 ty::Param(..)
790 | ty::Alias(
791 _,
792 ty::AliasTy {
793 kind: ty::Projection { .. } | ty::Inherent { .. } | ty::Free { .. },
794 ..
795 },
796 )
797 | ty::Placeholder(..)
798 | ty::Bound(..) => {
799 }
813 ty::Infer(ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_)) => {
814 candidates.ambiguous = true;
816 }
817 ty::Coroutine(coroutine_def_id, _) => {
818 if self.tcx().is_lang_item(def_id, LangItem::Unpin) {
819 match self.tcx().coroutine_movability(coroutine_def_id) {
820 hir::Movability::Static => {
821 }
824 hir::Movability::Movable => {
825 candidates.vec.push(BuiltinCandidate);
828 }
829 }
830 } else {
831 if self.should_stall_coroutine(coroutine_def_id) {
832 candidates.ambiguous = true;
833 } else {
834 candidates.vec.push(AutoImplCandidate);
836 }
837 }
838 }
839
840 ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
841 ::rustc_span::macros::bug_impl(None,
format_args!("asked to assemble auto trait candidates of unexpected type: {0:?}",
self_ty), Location::caller());bug!(
842 "asked to assemble auto trait candidates of unexpected type: {:?}",
843 self_ty
844 );
845 }
846
847 ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, .. }) => {
848 if candidates.vec.iter().any(|c| #[allow(non_exhaustive_omitted_patterns)] match c {
ProjectionCandidate { .. } => true,
_ => false,
}matches!(c, ProjectionCandidate { .. })) {
849 } else if self.typing_mode().is_coherence() {
859 candidates.ambiguous = true;
862 } else if self.infcx.can_define_opaque_ty(def_id) {
863 candidates.ambiguous = true;
867 } else {
868 candidates.vec.push(AutoImplCandidate)
869 }
870 }
871
872 ty::CoroutineWitness(..) => {
873 candidates.vec.push(AutoImplCandidate);
874 }
875
876 ty::Bool
877 | ty::Char
878 | ty::Int(_)
879 | ty::Uint(_)
880 | ty::Float(_)
881 | ty::Str
882 | ty::Array(_, _)
883 | ty::Pat(_, _)
884 | ty::Slice(_)
885 | ty::Adt(..)
886 | ty::RawPtr(_, _)
887 | ty::Ref(..)
888 | ty::FnDef(..)
889 | ty::FnPtr(..)
890 | ty::Closure(..)
891 | ty::CoroutineClosure(..)
892 | ty::Never
893 | ty::Tuple(_)
894 | ty::UnsafeBinder(_) => {
895 if self.tcx().trait_def(def_id).safety.is_unsafe()
898 && self_ty.has_unsafe_fields()
899 {
900 return;
901 }
902
903 check_impls();
904 }
905 ty::Error(_) => {
906 candidates.vec.push(AutoImplCandidate);
907 }
908 }
909 }
910 }
911
912 fn assemble_candidates_from_object_ty(
914 &mut self,
915 obligation: &PolyTraitObligation<'tcx>,
916 candidates: &mut SelectionCandidateSet<'tcx>,
917 ) {
918 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:918",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(918u32),
::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!(
919 self_ty = ?obligation.self_ty().skip_binder(),
920 "assemble_candidates_from_object_ty",
921 );
922
923 if self.tcx().is_sizedness_trait(obligation.predicate.def_id()) {
924 return;
927 }
928
929 self.infcx.probe(|_snapshot| {
930 let poly_trait_predicate =
931 self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
932 self.infcx.enter_forall(poly_trait_predicate, |placeholder_trait_predicate| {
933 let self_ty = placeholder_trait_predicate.self_ty();
934 let principal_trait_ref = match self_ty.kind() {
935 ty::Dynamic(data, ..) => {
936 if data.auto_traits().any(|did| did == obligation.predicate.def_id()) {
937 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:937",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(937u32),
::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!(
938 "assemble_candidates_from_object_ty: matched builtin bound, \
939 pushing candidate"
940 );
941 candidates.vec.push(BuiltinObjectCandidate);
942 return;
943 }
944
945 if let Some(principal) = data.principal() {
946 principal.with_self_ty(self.tcx(), self_ty)
947 } else {
948 return;
950 }
951 }
952 ty::Infer(ty::TyVar(_)) => {
953 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:953",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(953u32),
::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");
954 candidates.ambiguous = true; return;
956 }
957 _ => return,
958 };
959
960 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:960",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(960u32),
::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");
961
962 let candidate_supertraits = util::supertraits(self.tcx(), principal_trait_ref)
968 .enumerate()
969 .filter(|&(_, upcast_trait_ref)| {
970 self.infcx.probe(|_| {
971 self.match_normalize_trait_ref(
972 obligation,
973 placeholder_trait_predicate.trait_ref,
974 upcast_trait_ref,
975 )
976 .is_ok()
977 })
978 })
979 .map(|(idx, _)| ObjectCandidate(idx));
980
981 candidates.vec.extend(candidate_supertraits);
982 })
983 })
984 }
985
986 fn assemble_candidates_for_unsizing(
988 &mut self,
989 obligation: &PolyTraitObligation<'tcx>,
990 candidates: &mut SelectionCandidateSet<'tcx>,
991 ) {
992 let Some(trait_pred) = obligation.predicate.no_bound_vars() else {
1007 return;
1009 };
1010 let source = trait_pred.self_ty();
1011 let target = trait_pred.trait_ref.args.type_at(1);
1012
1013 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:1013",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(1013u32),
::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");
1014
1015 match (source.kind(), target.kind()) {
1016 (&ty::Dynamic(a_data, a_region), &ty::Dynamic(b_data, b_region)) => {
1018 let principal_def_id_a = a_data.principal_def_id();
1030 let principal_def_id_b = b_data.principal_def_id();
1031 if principal_def_id_a == principal_def_id_b || principal_def_id_b.is_none() {
1032 let a_auto_traits: FxIndexSet<DefId> = a_data
1036 .auto_traits()
1037 .chain(
1038 principal_def_id_a
1039 .map(|principal_def_id| {
1040 elaborate::supertrait_def_ids(self.tcx(), principal_def_id)
1041 .filter(|def_id| self.tcx().trait_is_auto(*def_id))
1042 })
1043 .into_flat_iter(),
1044 )
1045 .collect();
1046 let auto_traits_compatible = b_data
1047 .auto_traits()
1048 .all(|b| a_auto_traits.contains(&b));
1050 if auto_traits_compatible {
1051 candidates.vec.push(BuiltinUnsizeCandidate);
1052 }
1053 } else if principal_def_id_a.is_some() && principal_def_id_b.is_some() {
1054 let principal_a = a_data.principal().unwrap();
1056 let target_trait_did = principal_def_id_b.unwrap();
1057 let source_trait_ref = principal_a.with_self_ty(self.tcx(), source);
1058
1059 for (idx, upcast_trait_ref) in
1060 util::supertraits(self.tcx(), source_trait_ref).enumerate()
1061 {
1062 self.infcx.probe(|_| {
1063 if upcast_trait_ref.def_id() == target_trait_did
1064 && let Ok(nested) = self.match_upcast_principal(
1065 obligation,
1066 ty::Unnormalized::new_wip(upcast_trait_ref),
1067 a_data,
1068 b_data,
1069 a_region,
1070 b_region,
1071 )
1072 {
1073 if nested.is_none() {
1074 candidates.ambiguous = true;
1075 }
1076 candidates.vec.push(TraitUpcastingUnsizeCandidate(idx));
1077 }
1078 })
1079 }
1080 }
1081 }
1082
1083 (_, &ty::Dynamic(_, _)) => {
1085 candidates.vec.push(BuiltinUnsizeCandidate);
1086 }
1087
1088 (&ty::Infer(ty::TyVar(_)), _) | (_, &ty::Infer(ty::TyVar(_))) => {
1092 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:1092",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(1092u32),
::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");
1093 candidates.ambiguous = true;
1094 }
1095
1096 (&ty::Array(..), &ty::Slice(_)) => {
1098 candidates.vec.push(BuiltinUnsizeCandidate);
1099 }
1100
1101 (&ty::Adt(def_id_a, _), &ty::Adt(def_id_b, _)) if def_id_a.is_struct() => {
1103 if def_id_a == def_id_b {
1104 candidates.vec.push(BuiltinUnsizeCandidate);
1105 }
1106 }
1107
1108 _ => {}
1109 };
1110 }
1111
1112 {}
#[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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(1112u32),
::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))]
1113 fn assemble_candidates_for_transmutability(
1114 &mut self,
1115 obligation: &PolyTraitObligation<'tcx>,
1116 candidates: &mut SelectionCandidateSet<'tcx>,
1117 ) {
1118 if obligation.predicate.has_non_region_param() {
1119 return;
1120 }
1121
1122 if obligation.has_non_region_infer() {
1123 candidates.ambiguous = true;
1124 return;
1125 }
1126
1127 candidates.vec.push(TransmutabilityCandidate);
1128 }
1129
1130 {}
#[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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(1130u32),
::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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:1138",
"rustc_trait_selection::traits::select::candidate_assembly",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(1138u32),
::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))]
1131 fn assemble_candidates_for_trait_alias(
1132 &mut self,
1133 obligation: &PolyTraitObligation<'tcx>,
1134 candidates: &mut SelectionCandidateSet<'tcx>,
1135 ) {
1136 let self_ty = obligation.self_ty().skip_binder();
1138 debug!(?self_ty);
1139
1140 let def_id = obligation.predicate.def_id();
1141
1142 if self.tcx().is_trait_alias(def_id) {
1143 candidates.vec.push(TraitAliasCandidate);
1144 }
1145 }
1146
1147 {}
#[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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(1149u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::candidate_assembly"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("self_ty")
}> =
::tracing::__macro_support::FieldName::new("self_ty");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
match *self_ty.kind() {
ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) | ty::Tuple(..) |
ty::Pat(..) => {
candidates.vec.push(BuiltinCandidate);
}
ty::Uint(_) | ty::Int(_) |
ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) | ty::Bool |
ty::Float(_) | ty::Char | ty::RawPtr(..) | ty::Never |
ty::Ref(_, _, hir::Mutability::Not) | ty::Array(..) => {}
ty::UnsafeBinder(_) => {}
ty::Dynamic(..) | ty::Str | ty::Slice(..) | ty::Foreign(..) =>
{}
ty::Ref(_, _, hir::Mutability::Mut) => {}
ty::Coroutine(coroutine_def_id, args) => {
if self.should_stall_coroutine(coroutine_def_id) {
candidates.ambiguous = true;
return;
}
match self.tcx().coroutine_movability(coroutine_def_id) {
hir::Movability::Static => {}
hir::Movability::Movable => {
if self.tcx().features().coroutine_clone() {
let resolved_upvars =
self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
if resolved_upvars.is_ty_var() {
candidates.ambiguous = true;
} else { candidates.vec.push(BuiltinCandidate); }
}
}
}
}
ty::Closure(_, args) => {
let resolved_upvars =
self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
if resolved_upvars.is_ty_var() {
candidates.ambiguous = true;
} else { candidates.vec.push(BuiltinCandidate); }
}
ty::CoroutineClosure(_, args) => {
let resolved_upvars =
self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
if resolved_upvars.is_ty_var() {
candidates.ambiguous = true;
} else { candidates.vec.push(BuiltinCandidate); }
}
ty::CoroutineWitness(..) => {
candidates.vec.push(SizedCandidate);
}
ty::Adt(..) | ty::Alias(..) | ty::Param(..) |
ty::Placeholder(..) => {}
ty::Infer(ty::TyVar(_)) => { candidates.ambiguous = true; }
ty::Bound(..) => {}
ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) |
ty::FreshFloatTy(_)) => {
::rustc_span::macros::bug_impl(None,
format_args!("asked to assemble builtin bounds of unexpected type: {0:?}",
self_ty), Location::caller());
}
}
}
}
}#[instrument(level = "debug", skip(self, candidates))]
1150 fn assemble_builtin_copy_clone_candidate(
1151 &mut self,
1152 self_ty: Ty<'tcx>,
1153 candidates: &mut SelectionCandidateSet<'tcx>,
1154 ) {
1155 match *self_ty.kind() {
1156 ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) | ty::Tuple(..) | ty::Pat(..) => {
1159 candidates.vec.push(BuiltinCandidate);
1160 }
1161
1162 ty::Uint(_)
1164 | ty::Int(_)
1165 | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1166 | ty::Bool
1167 | ty::Float(_)
1168 | ty::Char
1169 | ty::RawPtr(..)
1170 | ty::Never
1171 | ty::Ref(_, _, hir::Mutability::Not)
1172 | ty::Array(..) => {}
1173
1174 ty::UnsafeBinder(_) => {}
1177
1178 ty::Dynamic(..) | ty::Str | ty::Slice(..) | ty::Foreign(..) => {}
1180
1181 ty::Ref(_, _, hir::Mutability::Mut) => {}
1183
1184 ty::Coroutine(coroutine_def_id, args) => {
1185 if self.should_stall_coroutine(coroutine_def_id) {
1186 candidates.ambiguous = true;
1187 return;
1188 }
1189
1190 match self.tcx().coroutine_movability(coroutine_def_id) {
1191 hir::Movability::Static => {}
1192 hir::Movability::Movable => {
1193 if self.tcx().features().coroutine_clone() {
1194 let resolved_upvars =
1195 self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
1196 if resolved_upvars.is_ty_var() {
1197 candidates.ambiguous = true;
1199 } else {
1200 candidates.vec.push(BuiltinCandidate);
1201 }
1202 }
1203 }
1204 }
1205 }
1206
1207 ty::Closure(_, args) => {
1208 let resolved_upvars =
1209 self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
1210 if resolved_upvars.is_ty_var() {
1211 candidates.ambiguous = true;
1213 } else {
1214 candidates.vec.push(BuiltinCandidate);
1215 }
1216 }
1217
1218 ty::CoroutineClosure(_, args) => {
1219 let resolved_upvars =
1220 self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
1221 if resolved_upvars.is_ty_var() {
1222 candidates.ambiguous = true;
1224 } else {
1225 candidates.vec.push(BuiltinCandidate);
1226 }
1227 }
1228
1229 ty::CoroutineWitness(..) => {
1230 candidates.vec.push(SizedCandidate);
1231 }
1232
1233 ty::Adt(..) | ty::Alias(..) | ty::Param(..) | ty::Placeholder(..) => {}
1235
1236 ty::Infer(ty::TyVar(_)) => {
1237 candidates.ambiguous = true;
1238 }
1239
1240 ty::Bound(..) => {}
1242
1243 ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1244 bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
1245 }
1246 }
1247 }
1248
1249 {}
#[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/0abfedbc7cd4e725f126913880c95800394f7c37/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs"),
::tracing_core::__macro_support::Option::Some(1250u32),
::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_span::macros::bug_impl(None,
format_args!("asked to assemble builtin bounds of unexpected type: {0:?}",
self_ty), Location::caller());
}
}
}
}
}#[instrument(level = "debug", skip(self, candidates))]
1251 fn assemble_builtin_sized_candidate(
1252 &mut self,
1253 self_ty: Ty<'tcx>,
1254 candidates: &mut SelectionCandidateSet<'tcx>,
1255 sizedness: SizedTraitKind,
1256 ) {
1257 match *self_ty.kind() {
1258 ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1260 | ty::Uint(_)
1261 | ty::Int(_)
1262 | ty::Bool
1263 | ty::Float(_)
1264 | ty::FnDef(..)
1265 | ty::FnPtr(..)
1266 | ty::RawPtr(..)
1267 | ty::Char
1268 | ty::Ref(..)
1269 | ty::Array(..)
1270 | ty::Closure(..)
1271 | ty::CoroutineClosure(..)
1272 | ty::Never
1273 | ty::Error(_) => {
1274 candidates.vec.push(SizedCandidate);
1275 }
1276
1277 ty::Coroutine(coroutine_def_id, _) => {
1278 if self.should_stall_coroutine(coroutine_def_id) {
1279 candidates.ambiguous = true;
1280 } else {
1281 candidates.vec.push(SizedCandidate);
1282 }
1283 }
1284
1285 ty::CoroutineWitness(..) => {
1286 candidates.vec.push(SizedCandidate);
1287 }
1288
1289 ty::Tuple(..) | ty::Pat(..) | ty::Adt(..) | ty::UnsafeBinder(_) => {
1291 candidates.vec.push(SizedCandidate);
1292 }
1293
1294 ty::Str | ty::Slice(_) | ty::Dynamic(..) => match sizedness {
1296 SizedTraitKind::Sized => {}
1297 SizedTraitKind::MetaSized => {
1298 candidates.vec.push(SizedCandidate);
1299 }
1300 },
1301
1302 ty::Foreign(..) => {}
1304
1305 ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => {}
1306
1307 ty::Infer(ty::TyVar(_)) => {
1308 candidates.ambiguous = true;
1309 }
1310
1311 ty::Bound(..) => {}
1313
1314 ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1315 bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
1316 }
1317 }
1318 }
1319
1320 fn assemble_const_destruct_candidates(
1321 &mut self,
1322 _obligation: &PolyTraitObligation<'tcx>,
1323 candidates: &mut SelectionCandidateSet<'tcx>,
1324 ) {
1325 candidates.vec.push(BuiltinCandidate);
1326 }
1327
1328 fn assemble_candidate_for_tuple(
1329 &mut self,
1330 obligation: &PolyTraitObligation<'tcx>,
1331 candidates: &mut SelectionCandidateSet<'tcx>,
1332 ) {
1333 let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
1334 match self_ty.kind() {
1335 ty::Tuple(_) => {
1336 candidates.vec.push(BuiltinCandidate);
1337 }
1338 ty::Infer(ty::TyVar(_)) => {
1339 candidates.ambiguous = true;
1340 }
1341 ty::Bool
1342 | ty::Char
1343 | ty::Int(_)
1344 | ty::Uint(_)
1345 | ty::Float(_)
1346 | ty::Adt(_, _)
1347 | ty::Foreign(_)
1348 | ty::Str
1349 | ty::Array(_, _)
1350 | ty::Slice(_)
1351 | ty::RawPtr(_, _)
1352 | ty::Ref(_, _, _)
1353 | ty::FnDef(_, _)
1354 | ty::Pat(_, _)
1355 | ty::FnPtr(..)
1356 | ty::UnsafeBinder(_)
1357 | ty::Dynamic(_, _)
1358 | ty::Closure(..)
1359 | ty::CoroutineClosure(..)
1360 | ty::Coroutine(_, _)
1361 | ty::CoroutineWitness(..)
1362 | ty::Never
1363 | ty::Alias(..)
1364 | ty::Param(_)
1365 | ty::Bound(_, _)
1366 | ty::Error(_)
1367 | ty::Infer(_)
1368 | ty::Placeholder(_) => {}
1369 }
1370 }
1371
1372 fn assemble_candidates_for_fn_ptr_trait(
1373 &mut self,
1374 obligation: &PolyTraitObligation<'tcx>,
1375 candidates: &mut SelectionCandidateSet<'tcx>,
1376 ) {
1377 let self_ty = self.infcx.deeply_resolve_ignoring_regions(obligation.self_ty());
1378
1379 match self_ty.skip_binder().kind() {
1380 ty::FnPtr(..) => candidates.vec.push(BuiltinCandidate),
1381 ty::Bool
1382 | ty::Char
1383 | ty::Int(_)
1384 | ty::Uint(_)
1385 | ty::Float(_)
1386 | ty::Adt(..)
1387 | ty::Foreign(..)
1388 | ty::Str
1389 | ty::Array(..)
1390 | ty::Pat(..)
1391 | ty::Slice(_)
1392 | ty::RawPtr(_, _)
1393 | ty::Ref(..)
1394 | ty::FnDef(..)
1395 | ty::Placeholder(..)
1396 | ty::Dynamic(..)
1397 | ty::Closure(..)
1398 | ty::CoroutineClosure(..)
1399 | ty::Coroutine(..)
1400 | ty::CoroutineWitness(..)
1401 | ty::UnsafeBinder(_)
1402 | ty::Never
1403 | ty::Tuple(..)
1404 | ty::Alias(..)
1405 | ty::Param(..)
1406 | ty::Bound(..)
1407 | ty::Error(_)
1408 | ty::Infer(
1409 ty::InferTy::IntVar(_)
1410 | ty::InferTy::FloatVar(_)
1411 | ty::InferTy::FreshIntTy(_)
1412 | ty::InferTy::FreshFloatTy(_),
1413 ) => {}
1414 ty::Infer(ty::InferTy::TyVar(_) | ty::InferTy::FreshTy(_)) => {
1415 candidates.ambiguous = true;
1416 }
1417 }
1418 }
1419
1420 fn assemble_candidates_for_bikeshed_guaranteed_no_drop_trait(
1421 &mut self,
1422 obligation: &PolyTraitObligation<'tcx>,
1423 candidates: &mut SelectionCandidateSet<'tcx>,
1424 ) {
1425 match obligation.predicate.self_ty().skip_binder().kind() {
1426 ty::Ref(..)
1427 | ty::Adt(..)
1428 | ty::Tuple(_)
1429 | ty::Array(..)
1430 | ty::FnDef(..)
1431 | ty::FnPtr(..)
1432 | ty::Error(_)
1433 | ty::Uint(_)
1434 | ty::Int(_)
1435 | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1436 | ty::Bool
1437 | ty::Float(_)
1438 | ty::Char
1439 | ty::RawPtr(..)
1440 | ty::Never
1441 | ty::Pat(..)
1442 | ty::Dynamic(..)
1443 | ty::Str
1444 | ty::Slice(_)
1445 | ty::Foreign(..)
1446 | ty::Alias(..)
1447 | ty::Param(_)
1448 | ty::Placeholder(..)
1449 | ty::Closure(..)
1450 | ty::CoroutineClosure(..)
1451 | ty::Coroutine(..)
1452 | ty::UnsafeBinder(_)
1453 | ty::CoroutineWitness(..)
1454 | ty::Bound(..) => {
1455 candidates.vec.push(BikeshedGuaranteedNoDropCandidate);
1456 }
1457
1458 ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1459 candidates.ambiguous = true;
1460 }
1461 }
1462 }
1463
1464 fn assemble_candidates_for_try_as_dyn(
1465 &mut self,
1466 obligation: &PolyTraitObligation<'tcx>,
1467 candidates: &mut SelectionCandidateSet<'tcx>,
1468 ) {
1469 match *obligation.predicate.self_ty().skip_binder().kind() {
1470 ty::Dynamic(bounds, _lifetime) => {
1471 for bound in bounds {
1472 match bound.skip_binder() {
1473 ExistentialPredicate::Trait(_) => {}
1474 ExistentialPredicate::Projection(_) => return,
1476 ExistentialPredicate::AutoTrait(_) => {}
1479 }
1480 }
1481 candidates.vec.push(TryAsDynCandidate);
1482 }
1483
1484 ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1485 candidates.ambiguous = true;
1486 }
1487
1488 _ => {}
1489 }
1490 }
1491
1492 fn assemble_candidates_for_field_trait(
1493 &mut self,
1494 obligation: &PolyTraitObligation<'tcx>,
1495 candidates: &mut SelectionCandidateSet<'tcx>,
1496 ) {
1497 if let ty::Adt(def, args) = obligation.predicate.self_ty().skip_binder().kind()
1501 && let Some(FieldInfo { base, ty, .. }) =
1502 def.field_representing_type_info(self.tcx(), args)
1503 && match self.infcx.evaluate_obligation(&PredicateObligation::new(
1508 self.tcx(),
1509 obligation.cause.clone(),
1510 obligation.param_env,
1511 TraitRef::new(
1512 self.tcx(),
1513 self.tcx().require_lang_item(LangItem::Sized, DUMMY_SP),
1514 [base],
1515 ),
1516 )) {
1517 Ok(res) if res.must_apply_modulo_regions() => true,
1518 _ => false,
1519 }
1520 && match self.infcx.evaluate_obligation(&PredicateObligation::new(
1521 self.tcx(),
1522 obligation.cause.clone(),
1523 obligation.param_env,
1524 TraitRef::new(
1525 self.tcx(),
1526 self.tcx().require_lang_item(LangItem::Sized, DUMMY_SP),
1527 [ty],
1528 ),
1529 )) {
1530 Ok(res) if res.must_apply_modulo_regions() => true,
1531 _ => false,
1532 }
1533 && match base.kind() {
1534 ty::Adt(def, _) => def.is_struct() && !def.repr().packed(),
1535 ty::Tuple(..) => true,
1536 _ => false,
1537 }
1538 {
1539 candidates.vec.push(BuiltinCandidate);
1540 }
1541 }
1542}