1use std::ops::ControlFlow;
11
12use rustc_attr_ir::lang_items::LangItem;
13use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk};
14use rustc_infer::traits::ObligationCauseCode;
15use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData};
16use rustc_middle::ty::{self, GenericArgs, SizedTraitKind, Ty, Unnormalized, Upcast};
17use rustc_next_trait_solver::solve::flatten_answer_tree;
18use rustc_span::def_id::DefId;
19use rustc_span::{bug, span_bug};
20use thin_vec::thin_vec;
21use tracing::{debug, instrument};
22
23use super::SelectionCandidate::{self, *};
24use super::{PredicateObligations, SelectionContext};
25use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to};
26use crate::traits::util::{self, closure_trait_ref_and_return_type};
27use crate::traits::{
28 ImplSource, ImplSourceUserDefinedData, Normalized, Obligation, ObligationCause,
29 PolyTraitObligation, PredicateObligation, Selection, SelectionError, TraitObligation,
30};
31
32impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
33 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("confirm_candidate",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(33u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidate")
}> =
::tracing::__macro_support::FieldName::new("candidate");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<Selection<'tcx>, SelectionError<'tcx>> = loop {};
return __tracing_attr_fake_return;
}
{
Ok(match candidate {
SizedCandidate => {
let data = self.confirm_builtin_candidate(obligation);
ImplSource::Builtin(BuiltinImplSource::Misc, data)
}
BuiltinCandidate => {
let data = self.confirm_builtin_candidate(obligation);
ImplSource::Builtin(BuiltinImplSource::Misc, data)
}
TransmutabilityCandidate => {
let data =
self.confirm_transmutability_candidate(obligation)?;
ImplSource::Builtin(BuiltinImplSource::Misc, data)
}
ParamCandidate(param) => {
let obligations =
self.confirm_param_candidate(obligation,
param.map_bound(|t| t.trait_ref));
ImplSource::Param(obligations)
}
ImplCandidate(impl_def_id) => {
ImplSource::UserDefined(self.confirm_impl_candidate(obligation,
impl_def_id))
}
AutoImplCandidate => {
let data = self.confirm_auto_impl_candidate(obligation)?;
ImplSource::Builtin(BuiltinImplSource::Misc, data)
}
ProjectionCandidate { idx, .. } => {
let obligations =
self.confirm_projection_candidate(obligation, idx)?;
ImplSource::Param(obligations)
}
ObjectCandidate(idx) =>
self.confirm_object_candidate(obligation, idx)?,
ClosureCandidate { .. } => {
let vtable_closure =
self.confirm_closure_candidate(obligation)?;
ImplSource::Builtin(BuiltinImplSource::Misc, vtable_closure)
}
AsyncClosureCandidate => {
let vtable_closure =
self.confirm_async_closure_candidate(obligation)?;
ImplSource::Builtin(BuiltinImplSource::Misc, vtable_closure)
}
AsyncFnKindHelperCandidate => {
ImplSource::Builtin(BuiltinImplSource::Misc,
PredicateObligations::new())
}
CoroutineCandidate => {
let vtable_coroutine =
self.confirm_coroutine_candidate(obligation)?;
ImplSource::Builtin(BuiltinImplSource::Misc,
vtable_coroutine)
}
FutureCandidate => {
let vtable_future =
self.confirm_future_candidate(obligation)?;
ImplSource::Builtin(BuiltinImplSource::Misc, vtable_future)
}
IteratorCandidate => {
let vtable_iterator =
self.confirm_iterator_candidate(obligation)?;
ImplSource::Builtin(BuiltinImplSource::Misc,
vtable_iterator)
}
AsyncIteratorCandidate => {
let vtable_iterator =
self.confirm_async_iterator_candidate(obligation)?;
ImplSource::Builtin(BuiltinImplSource::Misc,
vtable_iterator)
}
FnPointerCandidate => {
let data = self.confirm_fn_pointer_candidate(obligation)?;
ImplSource::Builtin(BuiltinImplSource::Misc, data)
}
TraitAliasCandidate => {
let data = self.confirm_trait_alias_candidate(obligation);
ImplSource::Builtin(BuiltinImplSource::Misc, data)
}
BuiltinObjectCandidate => {
ImplSource::Builtin(BuiltinImplSource::Misc,
PredicateObligations::new())
}
BuiltinUnsizeCandidate =>
self.confirm_builtin_unsize_candidate(obligation)?,
TraitUpcastingUnsizeCandidate(idx) => {
self.confirm_trait_upcasting_unsize_candidate(obligation,
idx)?
}
BikeshedGuaranteedNoDropCandidate => {
self.confirm_bikeshed_guaranteed_no_drop_candidate(obligation)
}
TryAsDynCandidate =>
self.confirm_try_as_dyn_candidate(obligation),
})
}
}
}#[instrument(level = "debug", skip(self))]
34 pub(super) fn confirm_candidate(
35 &mut self,
36 obligation: &PolyTraitObligation<'tcx>,
37 candidate: SelectionCandidate<'tcx>,
38 ) -> Result<Selection<'tcx>, SelectionError<'tcx>> {
39 Ok(match candidate {
40 SizedCandidate => {
41 let data = self.confirm_builtin_candidate(obligation);
42 ImplSource::Builtin(BuiltinImplSource::Misc, data)
43 }
44
45 BuiltinCandidate => {
46 let data = self.confirm_builtin_candidate(obligation);
47 ImplSource::Builtin(BuiltinImplSource::Misc, data)
48 }
49
50 TransmutabilityCandidate => {
51 let data = self.confirm_transmutability_candidate(obligation)?;
52 ImplSource::Builtin(BuiltinImplSource::Misc, data)
53 }
54
55 ParamCandidate(param) => {
56 let obligations =
57 self.confirm_param_candidate(obligation, param.map_bound(|t| t.trait_ref));
58 ImplSource::Param(obligations)
59 }
60
61 ImplCandidate(impl_def_id) => {
62 ImplSource::UserDefined(self.confirm_impl_candidate(obligation, impl_def_id))
63 }
64
65 AutoImplCandidate => {
66 let data = self.confirm_auto_impl_candidate(obligation)?;
67 ImplSource::Builtin(BuiltinImplSource::Misc, data)
68 }
69
70 ProjectionCandidate { idx, .. } => {
71 let obligations = self.confirm_projection_candidate(obligation, idx)?;
72 ImplSource::Param(obligations)
73 }
74
75 ObjectCandidate(idx) => self.confirm_object_candidate(obligation, idx)?,
76
77 ClosureCandidate { .. } => {
78 let vtable_closure = self.confirm_closure_candidate(obligation)?;
79 ImplSource::Builtin(BuiltinImplSource::Misc, vtable_closure)
80 }
81
82 AsyncClosureCandidate => {
83 let vtable_closure = self.confirm_async_closure_candidate(obligation)?;
84 ImplSource::Builtin(BuiltinImplSource::Misc, vtable_closure)
85 }
86
87 AsyncFnKindHelperCandidate => {
90 ImplSource::Builtin(BuiltinImplSource::Misc, PredicateObligations::new())
91 }
92
93 CoroutineCandidate => {
94 let vtable_coroutine = self.confirm_coroutine_candidate(obligation)?;
95 ImplSource::Builtin(BuiltinImplSource::Misc, vtable_coroutine)
96 }
97
98 FutureCandidate => {
99 let vtable_future = self.confirm_future_candidate(obligation)?;
100 ImplSource::Builtin(BuiltinImplSource::Misc, vtable_future)
101 }
102
103 IteratorCandidate => {
104 let vtable_iterator = self.confirm_iterator_candidate(obligation)?;
105 ImplSource::Builtin(BuiltinImplSource::Misc, vtable_iterator)
106 }
107
108 AsyncIteratorCandidate => {
109 let vtable_iterator = self.confirm_async_iterator_candidate(obligation)?;
110 ImplSource::Builtin(BuiltinImplSource::Misc, vtable_iterator)
111 }
112
113 FnPointerCandidate => {
114 let data = self.confirm_fn_pointer_candidate(obligation)?;
115 ImplSource::Builtin(BuiltinImplSource::Misc, data)
116 }
117
118 TraitAliasCandidate => {
119 let data = self.confirm_trait_alias_candidate(obligation);
120 ImplSource::Builtin(BuiltinImplSource::Misc, data)
121 }
122
123 BuiltinObjectCandidate => {
124 ImplSource::Builtin(BuiltinImplSource::Misc, PredicateObligations::new())
128 }
129
130 BuiltinUnsizeCandidate => self.confirm_builtin_unsize_candidate(obligation)?,
131
132 TraitUpcastingUnsizeCandidate(idx) => {
133 self.confirm_trait_upcasting_unsize_candidate(obligation, idx)?
134 }
135
136 BikeshedGuaranteedNoDropCandidate => {
137 self.confirm_bikeshed_guaranteed_no_drop_candidate(obligation)
138 }
139
140 TryAsDynCandidate => self.confirm_try_as_dyn_candidate(obligation),
141 })
142 }
143
144 fn confirm_projection_candidate(
145 &mut self,
146 obligation: &PolyTraitObligation<'tcx>,
147 idx: usize,
148 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
149 let placeholder_trait_predicate =
150 self.infcx.enter_forall_and_leak_universe(obligation.predicate).trait_ref;
151 let placeholder_self_ty = self.infcx.shallow_resolve(placeholder_trait_predicate.self_ty());
152 let candidate_predicate = self
153 .for_each_item_bound(
154 placeholder_self_ty,
155 |_, clause, clause_idx, _| {
156 if clause_idx == idx {
157 ControlFlow::Break(clause)
158 } else {
159 ControlFlow::Continue(())
160 }
161 },
162 || ::core::panicking::unreachable_default_msg()unreachable!(),
163 )
164 .break_value()
165 .expect("expected to index into clause that exists");
166 let candidate_predicate = candidate_predicate
167 .as_trait_clause()
168 .expect("projection candidate is not a trait predicate");
169 let candidate_predicate =
170 util::lazily_elaborate_sizedness_candidate(self.infcx, obligation, candidate_predicate);
171
172 let candidate = candidate_predicate.map_bound(|t| t.trait_ref);
173
174 let candidate = self.infcx.instantiate_binder_with_fresh_vars(
175 obligation.cause.span,
176 BoundRegionConversionTime::HigherRankedType,
177 candidate,
178 );
179 let mut obligations = PredicateObligations::new();
180 let candidate = normalize_with_depth_to(
181 self,
182 obligation.param_env,
183 obligation.cause.clone(),
184 obligation.recursion_depth + 1,
185 ty::Unnormalized::new_wip(candidate),
186 &mut obligations,
187 );
188
189 obligations.extend(
190 self.infcx
191 .at(&obligation.cause, obligation.param_env)
192 .eq(DefineOpaqueTypes::No, placeholder_trait_predicate, candidate)
193 .map(|InferOk { obligations, .. }| obligations)
194 .map_err(|_| SelectionError::Unimplemented)?,
195 );
196
197 Ok(obligations)
198 }
199
200 fn confirm_param_candidate(
201 &mut self,
202 obligation: &PolyTraitObligation<'tcx>,
203 param: ty::PolyTraitRef<'tcx>,
204 ) -> PredicateObligations<'tcx> {
205 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:205",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(205u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("param")
}> =
::tracing::__macro_support::FieldName::new("param");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_param_candidate")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(¶m)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?obligation, ?param, "confirm_param_candidate");
206
207 let param = util::lazily_elaborate_sizedness_candidate(
208 self.infcx,
209 obligation,
210 param.upcast(self.infcx.tcx),
211 )
212 .map_bound(|p| p.trait_ref);
213
214 match self.match_where_clause_trait_ref(obligation, param) {
219 Ok(obligations) => obligations,
220 Err(()) => {
221 ::rustc_span::macros::bug_impl(None,
format_args!("Where clause `{0:?}` was applicable to `{1:?}` but now is not",
param, obligation), Location::caller());bug!(
222 "Where clause `{:?}` was applicable to `{:?}` but now is not",
223 param,
224 obligation
225 );
226 }
227 }
228 }
229
230 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("confirm_builtin_candidate",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(230u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: PredicateObligations<'tcx> =
loop {};
return __tracing_attr_fake_return;
}
{
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:235",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(235u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_builtin_candidate")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let tcx = self.tcx();
let trait_def = obligation.predicate.def_id();
let self_ty =
self.infcx.shallow_resolve(self.infcx.enter_forall_and_leak_universe(obligation.predicate.self_ty()));
let types =
match tcx.as_lang_item(trait_def) {
Some(LangItem::Sized) =>
self.sizedness_conditions(self_ty, SizedTraitKind::Sized),
Some(LangItem::MetaSized) => {
self.sizedness_conditions(self_ty,
SizedTraitKind::MetaSized)
}
Some(LangItem::PointeeSized) => {
::rustc_span::macros::bug_impl(None,
format_args!("`PointeeSized` is removing during lowering"),
Location::caller());
}
Some(LangItem::Copy | LangItem::Clone |
LangItem::TrivialClone) => {
self.copy_clone_conditions(self_ty)
}
Some(LangItem::FusedIterator) => {
if self.coroutine_is_gen(self_ty) {
ty::Binder::dummy(::alloc::vec::Vec::new())
} else {
{
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("tried to assemble `FusedIterator` for non-gen coroutine")));
};
}
}
Some(LangItem::Destruct | LangItem::DiscriminantKind |
LangItem::Field | LangItem::FnPtrTrait |
LangItem::FnAddrTrait | LangItem::PointeeTrait |
LangItem::Tuple | LangItem::Unpin) =>
ty::Binder::dummy(::alloc::vec::Vec::new()),
other =>
::rustc_span::macros::bug_impl(None,
format_args!("unexpected builtin trait {0:?} ({1:?})",
trait_def, other), Location::caller()),
};
let types =
self.infcx.enter_forall_and_leak_universe(types);
let cause =
obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
self.collect_predicates_for_types(obligation.param_env,
cause, obligation.recursion_depth + 1, trait_def, types)
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:230",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(230u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
231 fn confirm_builtin_candidate(
232 &mut self,
233 obligation: &PolyTraitObligation<'tcx>,
234 ) -> PredicateObligations<'tcx> {
235 debug!(?obligation, "confirm_builtin_candidate");
236 let tcx = self.tcx();
237 let trait_def = obligation.predicate.def_id();
238 let self_ty = self.infcx.shallow_resolve(
239 self.infcx.enter_forall_and_leak_universe(obligation.predicate.self_ty()),
240 );
241 let types = match tcx.as_lang_item(trait_def) {
242 Some(LangItem::Sized) => self.sizedness_conditions(self_ty, SizedTraitKind::Sized),
243 Some(LangItem::MetaSized) => {
244 self.sizedness_conditions(self_ty, SizedTraitKind::MetaSized)
245 }
246 Some(LangItem::PointeeSized) => {
247 bug!("`PointeeSized` is removing during lowering");
248 }
249 Some(LangItem::Copy | LangItem::Clone | LangItem::TrivialClone) => {
250 self.copy_clone_conditions(self_ty)
251 }
252 Some(LangItem::FusedIterator) => {
253 if self.coroutine_is_gen(self_ty) {
254 ty::Binder::dummy(vec![])
255 } else {
256 unreachable!("tried to assemble `FusedIterator` for non-gen coroutine");
257 }
258 }
259 Some(
260 LangItem::Destruct
261 | LangItem::DiscriminantKind
262 | LangItem::Field
263 | LangItem::FnPtrTrait
264 | LangItem::FnAddrTrait
265 | LangItem::PointeeTrait
266 | LangItem::Tuple
267 | LangItem::Unpin,
268 ) => ty::Binder::dummy(vec![]),
269 other => bug!("unexpected builtin trait {trait_def:?} ({other:?})"),
270 };
271 let types = self.infcx.enter_forall_and_leak_universe(types);
272
273 let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
274 self.collect_predicates_for_types(
275 obligation.param_env,
276 cause,
277 obligation.recursion_depth + 1,
278 trait_def,
279 types,
280 )
281 }
282
283 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("confirm_transmutability_candidate",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(283u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<PredicateObligations<'tcx>, SelectionError<'tcx>> =
loop {};
return __tracing_attr_fake_return;
}
{
use rustc_middle::ty::transmute::Answer;
let predicate =
self.infcx.enter_forall_and_leak_universe(obligation.predicate);
let mut assume = predicate.trait_ref.args.const_at(2);
if self.tcx().features().generic_const_exprs() {
assume =
crate::traits::evaluate_const(self.infcx, assume,
obligation.param_env)
}
let Some(assume) =
rustc_transmute::Assume::from_const(self.infcx.tcx,
assume) else { return Err(SelectionError::Unimplemented); };
let dst = predicate.trait_ref.args.type_at(0);
let src = predicate.trait_ref.args.type_at(1);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:303",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(303u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("src")
}> =
::tracing::__macro_support::FieldName::new("src");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("dst")
}> =
::tracing::__macro_support::FieldName::new("dst");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&src)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dst)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let mut transmute_env =
rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx);
let maybe_transmutable =
transmute_env.is_transmutable(src, dst, assume);
let fully_flattened =
match maybe_transmutable {
Answer::No(_) => return Err(SelectionError::Unimplemented),
Answer::Yes => PredicateObligations::new(),
Answer::If(cond) => {
flatten_answer_tree(self.tcx(),
obligation.predicate.skip_binder(),
cond).into_iter().map(|predicate|
{
Obligation::new(self.infcx.tcx, obligation.cause.clone(),
obligation.param_env, predicate)
}).collect()
}
};
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:325",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(325u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fully_flattened")
}> =
::tracing::__macro_support::FieldName::new("fully_flattened");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fully_flattened)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
Ok(fully_flattened)
}
}
}#[instrument(level = "debug", skip(self))]
284 fn confirm_transmutability_candidate(
285 &mut self,
286 obligation: &PolyTraitObligation<'tcx>,
287 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
288 use rustc_middle::ty::transmute::Answer;
289
290 let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
291
292 let mut assume = predicate.trait_ref.args.const_at(2);
293 if self.tcx().features().generic_const_exprs() {
294 assume = crate::traits::evaluate_const(self.infcx, assume, obligation.param_env)
295 }
296 let Some(assume) = rustc_transmute::Assume::from_const(self.infcx.tcx, assume) else {
297 return Err(SelectionError::Unimplemented);
298 };
299
300 let dst = predicate.trait_ref.args.type_at(0);
301 let src = predicate.trait_ref.args.type_at(1);
302
303 debug!(?src, ?dst);
304 let mut transmute_env = rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx);
305 let maybe_transmutable = transmute_env.is_transmutable(src, dst, assume);
306
307 let fully_flattened = match maybe_transmutable {
308 Answer::No(_) => return Err(SelectionError::Unimplemented),
309 Answer::Yes => PredicateObligations::new(),
310 Answer::If(cond) => {
311 flatten_answer_tree(self.tcx(), obligation.predicate.skip_binder(), cond)
312 .into_iter()
313 .map(|predicate| {
314 Obligation::new(
315 self.infcx.tcx,
316 obligation.cause.clone(),
317 obligation.param_env,
318 predicate,
319 )
320 })
321 .collect()
322 }
323 };
324
325 debug!(?fully_flattened);
326 Ok(fully_flattened)
327 }
328
329 fn confirm_auto_impl_candidate(
335 &mut self,
336 obligation: &PolyTraitObligation<'tcx>,
337 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
338 {
match (&obligation.predicate.polarity(), &ty::ClausePolarity::Positive) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};assert_eq!(obligation.predicate.polarity(), ty::ClausePolarity::Positive);
339
340 let self_ty = obligation.predicate.self_ty().map_bound(|ty| self.infcx.shallow_resolve(ty));
341 let self_ty = self.infcx.enter_forall_and_leak_universe(self_ty);
342
343 let constituents = self.constituent_types_for_auto_trait(self_ty)?;
344 let constituents = self.infcx.enter_forall_and_leak_universe(constituents);
345
346 let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
347 let mut obligations = self.collect_predicates_for_types(
348 obligation.param_env,
349 cause.clone(),
350 obligation.recursion_depth + 1,
351 obligation.predicate.def_id(),
352 constituents.types,
353 );
354
355 if self.tcx().sess.opts.unstable_opts.higher_ranked_assumptions {
359 for assumption in constituents.assumptions {
363 let assumption = normalize_with_depth_to(
364 self,
365 obligation.param_env,
366 cause.clone(),
367 obligation.recursion_depth + 1,
368 Unnormalized::new_wip(assumption),
369 &mut obligations,
370 );
371 self.infcx.register_region_assumption(assumption);
372 }
373 }
374
375 Ok(obligations)
376 }
377
378 fn confirm_impl_candidate(
379 &mut self,
380 obligation: &PolyTraitObligation<'tcx>,
381 impl_def_id: DefId,
382 ) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>> {
383 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:383",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(383u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("impl_def_id")
}> =
::tracing::__macro_support::FieldName::new("impl_def_id");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_impl_candidate")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_def_id)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?obligation, ?impl_def_id, "confirm_impl_candidate");
384
385 let args = self.rematch_impl(impl_def_id, obligation);
388 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:388",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(388u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("args")
}> =
::tracing::__macro_support::FieldName::new("args");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("impl args")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?args, "impl args");
389
390 self.vtable_impl(
391 impl_def_id,
392 args,
393 &obligation.cause,
394 obligation.recursion_depth + 1,
395 obligation.param_env,
396 obligation.predicate,
397 )
398 }
399
400 fn vtable_impl(
401 &mut self,
402 impl_def_id: DefId,
403 args: Normalized<'tcx, GenericArgs<'tcx>>,
404 cause: &ObligationCause<'tcx>,
405 recursion_depth: usize,
406 param_env: ty::ParamEnv<'tcx>,
407 parent_trait_pred: ty::Binder<'tcx, ty::TraitClause<'tcx>>,
408 ) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>> {
409 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:409",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(409u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("impl_def_id")
}> =
::tracing::__macro_support::FieldName::new("impl_def_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("args")
}> =
::tracing::__macro_support::FieldName::new("args");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("recursion_depth")
}> =
::tracing::__macro_support::FieldName::new("recursion_depth");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("vtable_impl")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_def_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&recursion_depth)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?impl_def_id, ?args, ?recursion_depth, "vtable_impl");
410
411 let mut impl_obligations = self.impl_or_trait_obligations(
412 cause,
413 recursion_depth,
414 param_env,
415 impl_def_id,
416 args.value,
417 parent_trait_pred,
418 );
419
420 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:420",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(420u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("impl_obligations")
}> =
::tracing::__macro_support::FieldName::new("impl_obligations");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("vtable_impl")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_obligations)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?impl_obligations, "vtable_impl");
421
422 impl_obligations.extend(args.obligations);
428
429 ImplSourceUserDefinedData { impl_def_id, args: args.value, nested: impl_obligations }
430 }
431
432 fn confirm_object_candidate(
433 &mut self,
434 obligation: &PolyTraitObligation<'tcx>,
435 index: usize,
436 ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
437 let tcx = self.tcx();
438 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:438",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(438u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("index")
}> =
::tracing::__macro_support::FieldName::new("index");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_object_candidate")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&index)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?obligation, ?index, "confirm_object_candidate");
439
440 let trait_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
441 let self_ty = self.infcx.shallow_resolve(trait_predicate.self_ty());
442 let ty::Dynamic(data, ..) = *self_ty.kind() else {
443 ::rustc_span::macros::bug_impl(Some(obligation.cause.span),
format_args!("object candidate with non-object"), Location::caller());span_bug!(obligation.cause.span, "object candidate with non-object");
444 };
445
446 let object_trait_ref = data.principal().unwrap_or_else(|| {
447 ::rustc_span::macros::bug_impl(Some(obligation.cause.span),
format_args!("object candidate with no principal"), Location::caller())span_bug!(obligation.cause.span, "object candidate with no principal")
448 });
449 let object_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
450 obligation.cause.span,
451 BoundRegionConversionTime::HigherRankedType,
452 object_trait_ref,
453 );
454 let object_trait_ref = object_trait_ref.with_self_ty(self.tcx(), self_ty);
455
456 let mut nested = PredicateObligations::new();
457
458 let mut supertraits = util::supertraits(tcx, ty::Binder::dummy(object_trait_ref));
459 let unnormalized_upcast_trait_ref =
460 supertraits.nth(index).expect("supertraits iterator no longer has as many elements");
461
462 let upcast_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
463 obligation.cause.span,
464 BoundRegionConversionTime::HigherRankedType,
465 unnormalized_upcast_trait_ref,
466 );
467 let upcast_trait_ref = normalize_with_depth_to(
468 self,
469 obligation.param_env,
470 obligation.cause.clone(),
471 obligation.recursion_depth + 1,
472 ty::Unnormalized::new_wip(upcast_trait_ref),
473 &mut nested,
474 );
475
476 nested.extend(
477 self.infcx
478 .at(&obligation.cause, obligation.param_env)
479 .eq(DefineOpaqueTypes::No, trait_predicate.trait_ref, upcast_trait_ref)
480 .map(|InferOk { obligations, .. }| obligations)
481 .map_err(|_| SelectionError::Unimplemented)?,
482 );
483
484 for supertrait in tcx
487 .explicit_super_clauses_of(trait_predicate.def_id())
488 .iter_instantiated_copied(tcx, trait_predicate.trait_ref.args)
489 .map(|clause| clause.unzip().0)
490 {
491 let normalized_supertrait = normalize_with_depth_to(
492 self,
493 obligation.param_env,
494 obligation.cause.clone(),
495 obligation.recursion_depth + 1,
496 supertrait,
497 &mut nested,
498 );
499 nested.push(obligation.with(tcx, normalized_supertrait));
500 }
501
502 let assoc_types: Vec<_> = tcx
503 .associated_items(trait_predicate.def_id())
504 .in_definition_order()
505 .filter(|item| !tcx.generics_require_sized_self(item.def_id))
508 .filter_map(|item| if item.is_type() { Some(item.def_id) } else { None })
509 .collect();
510
511 for assoc_type in assoc_types {
512 let defs: &ty::Generics = tcx.generics_of(assoc_type);
513
514 if !defs.own_params.is_empty() {
515 tcx.dcx().span_delayed_bug(
516 obligation.cause.span,
517 "GATs in trait object shouldn't have been considered",
518 );
519 return Err(SelectionError::TraitDynIncompatible(trait_predicate.trait_ref.def_id));
520 }
521
522 for bound in self.tcx().item_bounds(assoc_type).transpose_iter() {
526 let normalized_bound = normalize_with_depth_to(
527 self,
528 obligation.param_env,
529 obligation.cause.clone(),
530 obligation.recursion_depth + 1,
531 bound.instantiate(tcx, trait_predicate.trait_ref.args),
532 &mut nested,
533 );
534 nested.push(obligation.with(tcx, normalized_bound));
535 }
536 }
537
538 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:538",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(538u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("nested")
}> =
::tracing::__macro_support::FieldName::new("nested");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("object nested obligations")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&nested)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?nested, "object nested obligations");
539
540 Ok(ImplSource::Builtin(BuiltinImplSource::Object(index), nested))
541 }
542
543 fn confirm_fn_pointer_candidate(
544 &mut self,
545 obligation: &PolyTraitObligation<'tcx>,
546 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
547 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:547",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(547u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_fn_pointer_candidate")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?obligation, "confirm_fn_pointer_candidate");
548 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
549 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
550
551 let tcx = self.tcx();
552 let sig = self_ty.unnormalized_fn_sig(tcx);
553 let output_ty = sig.map(|sig| self.infcx.enter_forall_and_leak_universe(sig.output()));
554 let sig = sig.skip_norm_wip();
555 let trait_ref = closure_trait_ref_and_return_type(
556 tcx,
557 obligation.predicate.def_id(),
558 self_ty,
559 sig,
560 util::TupleArgumentsFlag::Yes,
561 )
562 .map_bound(|(trait_ref, _)| trait_ref);
563
564 let mut nested =
565 self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?;
566 let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
567
568 let output_ty = normalize_with_depth_to(
570 self,
571 obligation.param_env,
572 cause.clone(),
573 obligation.recursion_depth,
574 output_ty,
575 &mut nested,
576 );
577 let tr = ty::TraitRef::new(
578 self.tcx(),
579 self.tcx().require_lang_item(LangItem::Sized, cause.span),
580 [output_ty],
581 );
582 nested.push(Obligation::new(self.infcx.tcx, cause, obligation.param_env, tr));
583
584 Ok(nested)
585 }
586
587 fn confirm_trait_alias_candidate(
588 &mut self,
589 obligation: &PolyTraitObligation<'tcx>,
590 ) -> PredicateObligations<'tcx> {
591 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:591",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(591u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_trait_alias_candidate")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?obligation, "confirm_trait_alias_candidate");
592
593 let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
594 let trait_ref = predicate.trait_ref;
595 let trait_def_id = trait_ref.def_id;
596 let args = trait_ref.args;
597
598 let trait_obligations = self.impl_or_trait_obligations(
599 &obligation.cause,
600 obligation.recursion_depth,
601 obligation.param_env,
602 trait_def_id,
603 args,
604 obligation.predicate,
605 );
606
607 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:607",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(607u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("trait_def_id")
}> =
::tracing::__macro_support::FieldName::new("trait_def_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("trait_obligations")
}> =
::tracing::__macro_support::FieldName::new("trait_obligations");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("trait alias obligations")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_def_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_obligations)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?trait_def_id, ?trait_obligations, "trait alias obligations");
608
609 trait_obligations
610 }
611
612 fn confirm_coroutine_candidate(
613 &mut self,
614 obligation: &PolyTraitObligation<'tcx>,
615 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
616 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
617 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
618 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
619 ::rustc_span::macros::bug_impl(None,
format_args!("closure candidate for non-closure {0:?}", obligation),
Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
620 };
621
622 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:622",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(622u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("coroutine_def_id")
}> =
::tracing::__macro_support::FieldName::new("coroutine_def_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("args")
}> =
::tracing::__macro_support::FieldName::new("args");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_coroutine_candidate")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coroutine_def_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_coroutine_candidate");
623
624 let coroutine_sig = args.as_coroutine().sig();
625
626 let (trait_ref, _, _) = super::util::coroutine_trait_ref_and_outputs(
627 self.tcx(),
628 obligation.predicate.def_id(),
629 self_ty,
630 coroutine_sig,
631 );
632
633 let nested = self.equate_trait_refs(
634 obligation.with(self.tcx(), placeholder_predicate),
635 ty::Binder::dummy(trait_ref),
636 )?;
637 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:637",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(637u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("trait_ref")
}> =
::tracing::__macro_support::FieldName::new("trait_ref");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("nested")
}> =
::tracing::__macro_support::FieldName::new("nested");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("coroutine candidate obligations")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&nested)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?trait_ref, ?nested, "coroutine candidate obligations");
638
639 Ok(nested)
640 }
641
642 fn confirm_future_candidate(
643 &mut self,
644 obligation: &PolyTraitObligation<'tcx>,
645 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
646 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
647 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
648 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
649 ::rustc_span::macros::bug_impl(None,
format_args!("closure candidate for non-closure {0:?}", obligation),
Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
650 };
651
652 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:652",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(652u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("coroutine_def_id")
}> =
::tracing::__macro_support::FieldName::new("coroutine_def_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("args")
}> =
::tracing::__macro_support::FieldName::new("args");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_future_candidate")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coroutine_def_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_future_candidate");
653
654 let coroutine_sig = args.as_coroutine().sig();
655
656 let (trait_ref, _) = super::util::future_trait_ref_and_outputs(
657 self.tcx(),
658 obligation.predicate.def_id(),
659 self_ty,
660 coroutine_sig,
661 );
662
663 let nested = self.equate_trait_refs(
664 obligation.with(self.tcx(), placeholder_predicate),
665 ty::Binder::dummy(trait_ref),
666 )?;
667 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:667",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(667u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("trait_ref")
}> =
::tracing::__macro_support::FieldName::new("trait_ref");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("nested")
}> =
::tracing::__macro_support::FieldName::new("nested");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("future candidate obligations")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&nested)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?trait_ref, ?nested, "future candidate obligations");
668
669 Ok(nested)
670 }
671
672 fn confirm_iterator_candidate(
673 &mut self,
674 obligation: &PolyTraitObligation<'tcx>,
675 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
676 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
677 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
678 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
679 ::rustc_span::macros::bug_impl(None,
format_args!("closure candidate for non-closure {0:?}", obligation),
Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
680 };
681
682 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:682",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(682u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("coroutine_def_id")
}> =
::tracing::__macro_support::FieldName::new("coroutine_def_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("args")
}> =
::tracing::__macro_support::FieldName::new("args");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_iterator_candidate")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coroutine_def_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_iterator_candidate");
683
684 let gen_sig = args.as_coroutine().sig();
685
686 let (trait_ref, _) = super::util::iterator_trait_ref_and_outputs(
687 self.tcx(),
688 obligation.predicate.def_id(),
689 self_ty,
690 gen_sig,
691 );
692
693 let nested = self.equate_trait_refs(
694 obligation.with(self.tcx(), placeholder_predicate),
695 ty::Binder::dummy(trait_ref),
696 )?;
697 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:697",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(697u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("trait_ref")
}> =
::tracing::__macro_support::FieldName::new("trait_ref");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("nested")
}> =
::tracing::__macro_support::FieldName::new("nested");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("iterator candidate obligations")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&nested)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?trait_ref, ?nested, "iterator candidate obligations");
698
699 Ok(nested)
700 }
701
702 fn confirm_async_iterator_candidate(
703 &mut self,
704 obligation: &PolyTraitObligation<'tcx>,
705 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
706 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
707 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
708 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
709 ::rustc_span::macros::bug_impl(None,
format_args!("closure candidate for non-closure {0:?}", obligation),
Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
710 };
711
712 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:712",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(712u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("coroutine_def_id")
}> =
::tracing::__macro_support::FieldName::new("coroutine_def_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("args")
}> =
::tracing::__macro_support::FieldName::new("args");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_async_iterator_candidate")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coroutine_def_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_async_iterator_candidate");
713
714 let gen_sig = args.as_coroutine().sig();
715
716 let (trait_ref, _) = super::util::async_iterator_trait_ref_and_outputs(
717 self.tcx(),
718 obligation.predicate.def_id(),
719 self_ty,
720 gen_sig,
721 );
722
723 let nested = self.equate_trait_refs(
724 obligation.with(self.tcx(), placeholder_predicate),
725 ty::Binder::dummy(trait_ref),
726 )?;
727 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:727",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(727u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("trait_ref")
}> =
::tracing::__macro_support::FieldName::new("trait_ref");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("nested")
}> =
::tracing::__macro_support::FieldName::new("nested");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("iterator candidate obligations")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&nested)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?trait_ref, ?nested, "iterator candidate obligations");
728
729 Ok(nested)
730 }
731
732 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("confirm_closure_candidate",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(732u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<PredicateObligations<'tcx>, SelectionError<'tcx>> =
loop {};
return __tracing_attr_fake_return;
}
{
let placeholder_predicate =
self.infcx.enter_forall_and_leak_universe(obligation.predicate);
let self_ty: Ty<'_> =
self.infcx.shallow_resolve(placeholder_predicate.self_ty());
let trait_ref =
match *self_ty.kind() {
ty::Closure(..) => {
self.closure_trait_ref_unnormalized(self_ty,
obligation.predicate.def_id())
}
ty::CoroutineClosure(_, args) => {
args.as_coroutine_closure().coroutine_closure_sig().map_bound(|sig|
{
ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(),
[self_ty, sig.tupled_inputs_ty])
})
}
_ => {
::rustc_span::macros::bug_impl(None,
format_args!("closure candidate for non-closure {0:?}",
obligation), Location::caller());
}
};
self.equate_trait_refs(obligation.with(self.tcx(),
placeholder_predicate), trait_ref)
}
}
}#[instrument(skip(self), level = "debug")]
733 fn confirm_closure_candidate(
734 &mut self,
735 obligation: &PolyTraitObligation<'tcx>,
736 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
737 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
738 let self_ty: Ty<'_> = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
739
740 let trait_ref = match *self_ty.kind() {
741 ty::Closure(..) => {
742 self.closure_trait_ref_unnormalized(self_ty, obligation.predicate.def_id())
743 }
744 ty::CoroutineClosure(_, args) => {
745 args.as_coroutine_closure().coroutine_closure_sig().map_bound(|sig| {
746 ty::TraitRef::new(
747 self.tcx(),
748 obligation.predicate.def_id(),
749 [self_ty, sig.tupled_inputs_ty],
750 )
751 })
752 }
753 _ => {
754 bug!("closure candidate for non-closure {:?}", obligation);
755 }
756 };
757
758 self.equate_trait_refs(obligation.with(self.tcx(), placeholder_predicate), trait_ref)
759 }
760
761 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("confirm_async_closure_candidate",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(761u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<PredicateObligations<'tcx>, SelectionError<'tcx>> =
loop {};
return __tracing_attr_fake_return;
}
{
let placeholder_predicate =
self.infcx.enter_forall_and_leak_universe(obligation.predicate);
let self_ty =
self.infcx.shallow_resolve(placeholder_predicate.self_ty());
let tcx = self.tcx();
let mut nested = PredicateObligations::new();
let (trait_ref, kind_ty) =
match *self_ty.kind() {
ty::CoroutineClosure(_, args) => {
let args = args.as_coroutine_closure();
let trait_ref =
args.coroutine_closure_sig().map_bound(|sig|
{
ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(),
[self_ty, sig.tupled_inputs_ty])
});
(trait_ref, args.kind_ty())
}
ty::FnDef(..) | ty::FnPtr(..) => {
let sig = self_ty.fn_sig(tcx);
let trait_ref =
sig.map_bound(|sig|
{
ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(),
[self_ty, Ty::new_tup(tcx, sig.inputs())])
});
let future_trait_def_id =
tcx.require_lang_item(LangItem::Future,
obligation.cause.span);
nested.push(obligation.with(tcx,
sig.output().map_bound(|output_ty|
{
ty::TraitRef::new(tcx, future_trait_def_id, [output_ty])
})));
let sized_trait_def_id =
tcx.require_lang_item(LangItem::Sized,
obligation.cause.span);
nested.push(obligation.with(tcx,
sig.output().map_bound(|output_ty|
{
ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
})));
(trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn))
}
ty::Closure(_, args) => {
let args = args.as_closure();
let sig = args.sig();
let trait_ref =
sig.map_bound(|sig|
{
ty::TraitRef::new(self.tcx(), obligation.predicate.def_id(),
[self_ty, sig.inputs()[0]])
});
let future_trait_def_id =
tcx.require_lang_item(LangItem::Future,
obligation.cause.span);
let placeholder_output_ty =
self.infcx.enter_forall_and_leak_universe(sig.output());
nested.push(obligation.with(tcx,
ty::TraitRef::new(tcx, future_trait_def_id,
[placeholder_output_ty])));
let sized_trait_def_id =
tcx.require_lang_item(LangItem::Sized,
obligation.cause.span);
nested.push(obligation.with(tcx,
sig.output().map_bound(|output_ty|
{
ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
})));
(trait_ref, args.kind_ty())
}
_ =>
::rustc_span::macros::bug_impl(None,
format_args!("expected callable type for AsyncFn candidate"),
Location::caller()),
};
nested.extend(self.equate_trait_refs(obligation.with(tcx,
placeholder_predicate), trait_ref)?);
let goal_kind =
self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
if let Some(closure_kind) =
self.infcx.shallow_resolve(kind_ty).to_opt_closure_kind() {
if !closure_kind.extends(goal_kind) {
return Err(SelectionError::Unimplemented);
}
} else {
nested.push(Obligation::new(self.tcx(),
obligation.derived_cause(ObligationCauseCode::BuiltinDerived),
obligation.param_env,
ty::TraitRef::new(self.tcx(),
self.tcx().require_lang_item(LangItem::AsyncFnKindHelper,
obligation.cause.span),
[kind_ty, Ty::from_closure_kind(self.tcx(), goal_kind)])));
}
Ok(nested)
}
}
}#[instrument(skip(self), level = "debug")]
762 fn confirm_async_closure_candidate(
763 &mut self,
764 obligation: &PolyTraitObligation<'tcx>,
765 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
766 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
767 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
768
769 let tcx = self.tcx();
770
771 let mut nested = PredicateObligations::new();
772 let (trait_ref, kind_ty) = match *self_ty.kind() {
773 ty::CoroutineClosure(_, args) => {
774 let args = args.as_coroutine_closure();
775 let trait_ref = args.coroutine_closure_sig().map_bound(|sig| {
776 ty::TraitRef::new(
777 self.tcx(),
778 obligation.predicate.def_id(),
779 [self_ty, sig.tupled_inputs_ty],
780 )
781 });
782
783 (trait_ref, args.kind_ty())
787 }
788 ty::FnDef(..) | ty::FnPtr(..) => {
789 let sig = self_ty.fn_sig(tcx);
790 let trait_ref = sig.map_bound(|sig| {
791 ty::TraitRef::new(
792 self.tcx(),
793 obligation.predicate.def_id(),
794 [self_ty, Ty::new_tup(tcx, sig.inputs())],
795 )
796 });
797
798 let future_trait_def_id =
800 tcx.require_lang_item(LangItem::Future, obligation.cause.span);
801 nested.push(obligation.with(
802 tcx,
803 sig.output().map_bound(|output_ty| {
804 ty::TraitRef::new(tcx, future_trait_def_id, [output_ty])
805 }),
806 ));
807 let sized_trait_def_id =
808 tcx.require_lang_item(LangItem::Sized, obligation.cause.span);
809 nested.push(obligation.with(
810 tcx,
811 sig.output().map_bound(|output_ty| {
812 ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
813 }),
814 ));
815
816 (trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn))
817 }
818 ty::Closure(_, args) => {
819 let args = args.as_closure();
820 let sig = args.sig();
821 let trait_ref = sig.map_bound(|sig| {
822 ty::TraitRef::new(
823 self.tcx(),
824 obligation.predicate.def_id(),
825 [self_ty, sig.inputs()[0]],
826 )
827 });
828
829 let future_trait_def_id =
831 tcx.require_lang_item(LangItem::Future, obligation.cause.span);
832 let placeholder_output_ty = self.infcx.enter_forall_and_leak_universe(sig.output());
833 nested.push(obligation.with(
834 tcx,
835 ty::TraitRef::new(tcx, future_trait_def_id, [placeholder_output_ty]),
836 ));
837 let sized_trait_def_id =
838 tcx.require_lang_item(LangItem::Sized, obligation.cause.span);
839 nested.push(obligation.with(
840 tcx,
841 sig.output().map_bound(|output_ty| {
842 ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
843 }),
844 ));
845
846 (trait_ref, args.kind_ty())
847 }
848 _ => bug!("expected callable type for AsyncFn candidate"),
849 };
850
851 nested.extend(
852 self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?,
853 );
854
855 let goal_kind =
856 self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
857
858 if let Some(closure_kind) = self.infcx.shallow_resolve(kind_ty).to_opt_closure_kind() {
862 if !closure_kind.extends(goal_kind) {
863 return Err(SelectionError::Unimplemented);
864 }
865 } else {
866 nested.push(Obligation::new(
867 self.tcx(),
868 obligation.derived_cause(ObligationCauseCode::BuiltinDerived),
869 obligation.param_env,
870 ty::TraitRef::new(
871 self.tcx(),
872 self.tcx()
873 .require_lang_item(LangItem::AsyncFnKindHelper, obligation.cause.span),
874 [kind_ty, Ty::from_closure_kind(self.tcx(), goal_kind)],
875 ),
876 ));
877 }
878
879 Ok(nested)
880 }
881
882 {}
#[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("equate_trait_refs",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(907u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("found_trait_ref")
}> =
::tracing::__macro_support::FieldName::new("found_trait_ref");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&found_trait_ref)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<PredicateObligations<'tcx>, SelectionError<'tcx>> =
loop {};
return __tracing_attr_fake_return;
}
{
let found_trait_ref =
self.infcx.instantiate_binder_with_fresh_vars(obligation.cause.span,
BoundRegionConversionTime::HigherRankedType,
found_trait_ref);
let Normalized {
obligations: nested,
value: (obligation_trait_ref, found_trait_ref) } =
normalize_with_depth(self, obligation.param_env,
obligation.cause.clone(), obligation.recursion_depth + 1,
Unnormalized::new_wip((obligation.predicate.trait_ref,
found_trait_ref)));
self.infcx.at(&obligation.cause,
obligation.param_env).eq(DefineOpaqueTypes::Yes,
obligation_trait_ref,
found_trait_ref).map(|InferOk { mut obligations, .. }|
{
obligations.extend(nested);
obligations
}).map_err(|terr|
{
SelectionError::SignatureMismatch(Box::new(SignatureMismatchData {
expected_trait_ref: obligation_trait_ref,
found_trait_ref,
terr,
}))
})
}
}
}#[instrument(skip(self), level = "trace")]
908 fn equate_trait_refs(
909 &mut self,
910 obligation: TraitObligation<'tcx>,
911 found_trait_ref: ty::PolyTraitRef<'tcx>,
912 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
913 let found_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
914 obligation.cause.span,
915 BoundRegionConversionTime::HigherRankedType,
916 found_trait_ref,
917 );
918 let Normalized { obligations: nested, value: (obligation_trait_ref, found_trait_ref) } =
920 normalize_with_depth(
921 self,
922 obligation.param_env,
923 obligation.cause.clone(),
924 obligation.recursion_depth + 1,
925 Unnormalized::new_wip((obligation.predicate.trait_ref, found_trait_ref)),
926 );
927
928 self.infcx
930 .at(&obligation.cause, obligation.param_env)
931 .eq(DefineOpaqueTypes::Yes, obligation_trait_ref, found_trait_ref)
932 .map(|InferOk { mut obligations, .. }| {
933 obligations.extend(nested);
934 obligations
935 })
936 .map_err(|terr| {
937 SelectionError::SignatureMismatch(Box::new(SignatureMismatchData {
938 expected_trait_ref: obligation_trait_ref,
939 found_trait_ref,
940 terr,
941 }))
942 })
943 }
944
945 fn confirm_trait_upcasting_unsize_candidate(
946 &mut self,
947 obligation: &PolyTraitObligation<'tcx>,
948 idx: usize,
949 ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
950 let tcx = self.tcx();
951
952 let predicate = obligation.predicate.no_bound_vars().unwrap();
955 let a_ty = self.infcx.shallow_resolve(predicate.self_ty());
956 let b_ty = self.infcx.shallow_resolve(predicate.trait_ref.args.type_at(1));
957
958 let ty::Dynamic(a_data, a_region) = *a_ty.kind() else {
959 ::rustc_span::macros::bug_impl(None,
format_args!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`"),
Location::caller())bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
960 };
961 let ty::Dynamic(b_data, b_region) = *b_ty.kind() else {
962 ::rustc_span::macros::bug_impl(None,
format_args!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`"),
Location::caller())bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
963 };
964
965 let source_principal = a_data.principal().unwrap().with_self_ty(tcx, a_ty);
966 let unnormalized_upcast_principal =
967 ty::Unnormalized::new_wip(util::supertraits(tcx, source_principal).nth(idx).unwrap());
968
969 let nested = self
970 .match_upcast_principal(
971 obligation,
972 unnormalized_upcast_principal,
973 a_data,
974 b_data,
975 a_region,
976 b_region,
977 )?
978 .expect("did not expect ambiguity during confirmation");
979
980 Ok(ImplSource::Builtin(BuiltinImplSource::TraitUpcasting(idx), nested))
981 }
982
983 fn confirm_builtin_unsize_candidate(
984 &mut self,
985 obligation: &PolyTraitObligation<'tcx>,
986 ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
987 let tcx = self.tcx();
988
989 let source = self.infcx.shallow_resolve(obligation.self_ty().no_bound_vars().unwrap());
992 let target = obligation.predicate.skip_binder().trait_ref.args.type_at(1);
993 let target = self.infcx.shallow_resolve(target);
994 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:994",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5f4effd579500175af844241eb179e756190f1e7/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(994u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("source")
}> =
::tracing::__macro_support::FieldName::new("source");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("target")
}> =
::tracing::__macro_support::FieldName::new("target");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("confirm_builtin_unsize_candidate")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&target)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?source, ?target, "confirm_builtin_unsize_candidate");
995
996 Ok(match (source.kind(), target.kind()) {
997 (&ty::Dynamic(data_a, r_a), &ty::Dynamic(data_b, r_b)) => {
999 let existential_predicates = if data_b.principal().is_some() {
1002 tcx.mk_poly_existential_predicates_from_iter(
1003 data_a
1004 .principal()
1005 .map(|b| b.map_bound(ty::ExistentialPredicate::Trait))
1006 .into_iter()
1007 .chain(
1008 data_a
1009 .projection_bounds()
1010 .map(|b| b.map_bound(ty::ExistentialPredicate::Projection)),
1011 )
1012 .chain(
1013 data_b
1014 .auto_traits()
1015 .map(ty::ExistentialPredicate::AutoTrait)
1016 .map(ty::Binder::dummy),
1017 ),
1018 )
1019 } else {
1020 tcx.mk_poly_existential_predicates_from_iter(
1025 data_b
1026 .auto_traits()
1027 .map(ty::ExistentialPredicate::AutoTrait)
1028 .map(ty::Binder::dummy),
1029 )
1030 };
1031 let source_trait = Ty::new_dynamic(tcx, existential_predicates, r_b);
1032
1033 let InferOk { mut obligations, .. } = self
1036 .infcx
1037 .sup_raw(
1038 &obligation.cause,
1039 obligation.param_env,
1040 DefineOpaqueTypes::Yes,
1041 target,
1042 source_trait,
1043 )
1044 .map_err(|_| SelectionError::Unimplemented)?;
1045
1046 let outlives = ty::OutlivesClause(r_a, r_b);
1048 obligations.push(Obligation::with_depth(
1049 tcx,
1050 obligation.cause.clone(),
1051 obligation.recursion_depth + 1,
1052 obligation.param_env,
1053 obligation.predicate.rebind(outlives),
1054 ));
1055
1056 ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1057 }
1058
1059 (_, &ty::Dynamic(data, r)) => {
1061 let mut object_dids = data.auto_traits().chain(data.principal_def_id());
1062 if let Some(did) = object_dids.find(|did| !tcx.is_dyn_compatible(*did)) {
1063 return Err(SelectionError::TraitDynIncompatible(did));
1064 }
1065
1066 let predicate_to_obligation = |predicate| {
1067 Obligation::with_depth(
1068 tcx,
1069 obligation.cause.clone(),
1070 obligation.recursion_depth + 1,
1071 obligation.param_env,
1072 predicate,
1073 )
1074 };
1075
1076 let mut nested: PredicateObligations<'_> = data
1083 .iter()
1084 .map(|predicate| predicate_to_obligation(predicate.with_self_ty(tcx, source)))
1085 .collect();
1086
1087 let tr = ty::TraitRef::new(
1089 tcx,
1090 tcx.require_lang_item(LangItem::Sized, obligation.cause.span),
1091 [source],
1092 );
1093 nested.push(predicate_to_obligation(tr.upcast(tcx)));
1094
1095 let outlives = ty::OutlivesClause(source, r);
1098 nested.push(predicate_to_obligation(
1099 ty::ClauseKind::TypeOutlives(outlives).upcast(tcx),
1100 ));
1101
1102 ImplSource::Builtin(BuiltinImplSource::Misc, nested)
1103 }
1104
1105 (&ty::Array(a, _), &ty::Slice(b)) => {
1107 let InferOk { obligations, .. } = self
1108 .infcx
1109 .at(&obligation.cause, obligation.param_env)
1110 .eq(DefineOpaqueTypes::Yes, b, a)
1111 .map_err(|_| SelectionError::Unimplemented)?;
1112
1113 ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1114 }
1115
1116 (&ty::Adt(def, args_a), &ty::Adt(_, args_b)) => {
1118 let unsizing_params = tcx.unsizing_params_for_adt(def.did());
1119 if unsizing_params.is_empty() {
1120 return Err(SelectionError::Unimplemented);
1121 }
1122
1123 let tail_field = def.non_enum_variant().tail();
1124 let tail_field_ty = tcx.type_of(tail_field.did);
1125
1126 let mut nested = PredicateObligations::new();
1127
1128 let source_tail = normalize_with_depth_to(
1132 self,
1133 obligation.param_env,
1134 obligation.cause.clone(),
1135 obligation.recursion_depth + 1,
1136 tail_field_ty.instantiate(tcx, args_a),
1137 &mut nested,
1138 );
1139 let target_tail = normalize_with_depth_to(
1140 self,
1141 obligation.param_env,
1142 obligation.cause.clone(),
1143 obligation.recursion_depth + 1,
1144 tail_field_ty.instantiate(tcx, args_b),
1145 &mut nested,
1146 );
1147
1148 let args =
1151 tcx.mk_args_from_iter(args_a.iter().enumerate().map(|(i, k)| {
1152 if unsizing_params.contains(i as u32) { args_b[i] } else { k }
1153 }));
1154 let new_struct = Ty::new_adt(tcx, def, args);
1155 let InferOk { obligations, .. } = self
1156 .infcx
1157 .at(&obligation.cause, obligation.param_env)
1158 .eq(DefineOpaqueTypes::Yes, target, new_struct)
1159 .map_err(|_| SelectionError::Unimplemented)?;
1160 nested.extend(obligations);
1161
1162 let tail_unsize_obligation = obligation.with(
1164 tcx,
1165 ty::TraitRef::new(
1166 tcx,
1167 obligation.predicate.def_id(),
1168 [source_tail, target_tail],
1169 ),
1170 );
1171 nested.push(tail_unsize_obligation);
1172
1173 ImplSource::Builtin(BuiltinImplSource::Misc, nested)
1174 }
1175
1176 _ => ::rustc_span::macros::bug_impl(None,
format_args!("source: {0}, target: {1}", source, target),
Location::caller())bug!("source: {source}, target: {target}"),
1177 })
1178 }
1179
1180 fn confirm_bikeshed_guaranteed_no_drop_candidate(
1183 &mut self,
1184 obligation: &PolyTraitObligation<'tcx>,
1185 ) -> ImplSource<'tcx, PredicateObligation<'tcx>> {
1186 let mut obligations = ::thin_vec::ThinVec::new()thin_vec![];
1187
1188 let tcx = self.tcx();
1189 let self_ty = obligation.predicate.self_ty();
1190 match *self_ty.skip_binder().kind() {
1191 ty::Ref(..) => {}
1193 ty::Adt(def, _) if def.is_manually_drop() => {}
1195 ty::Tuple(tys) => {
1198 obligations.extend(tys.iter().map(|elem_ty| {
1199 obligation.with(
1200 tcx,
1201 self_ty.rebind(ty::TraitRef::new(
1202 tcx,
1203 obligation.predicate.def_id(),
1204 [elem_ty],
1205 )),
1206 )
1207 }));
1208 }
1209 ty::Array(elem_ty, _) => {
1210 obligations.push(obligation.with(
1211 tcx,
1212 self_ty.rebind(ty::TraitRef::new(
1213 tcx,
1214 obligation.predicate.def_id(),
1215 [elem_ty],
1216 )),
1217 ));
1218 }
1219
1220 ty::FnDef(..)
1224 | ty::FnPtr(..)
1225 | ty::Error(_)
1226 | ty::Uint(_)
1227 | ty::Int(_)
1228 | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1229 | ty::Bool
1230 | ty::Float(_)
1231 | ty::Char
1232 | ty::RawPtr(..)
1233 | ty::Never
1234 | ty::Pat(..)
1235 | ty::Dynamic(..)
1236 | ty::Str
1237 | ty::Slice(_)
1238 | ty::Foreign(..)
1239 | ty::Adt(..)
1240 | ty::Alias(..)
1241 | ty::Param(_)
1242 | ty::Placeholder(..)
1243 | ty::Closure(..)
1244 | ty::CoroutineClosure(..)
1245 | ty::Coroutine(..)
1246 | ty::UnsafeBinder(_)
1247 | ty::CoroutineWitness(..)
1248 | ty::Bound(..) => {
1249 obligations.push(obligation.with(
1250 tcx,
1251 self_ty.map_bound(|ty| {
1252 ty::TraitRef::new(
1253 tcx,
1254 tcx.require_lang_item(LangItem::Copy, obligation.cause.span),
1255 [ty],
1256 )
1257 }),
1258 ));
1259 }
1260
1261 ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1262 {
::core::panicking::panic_fmt(format_args!("unexpected type `{0:?}`",
self_ty));
}panic!("unexpected type `{self_ty:?}`")
1263 }
1264
1265 ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
1267 }
1268
1269 ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1270 }
1271
1272 fn confirm_try_as_dyn_candidate(
1273 &mut self,
1274 obligation: &PolyTraitObligation<'tcx>,
1275 ) -> ImplSource<'tcx, PredicateObligation<'tcx>> {
1276 let tcx = self.tcx();
1277
1278 let mut obligations = PredicateObligations::new();
1279
1280 let self_ty = obligation.predicate.self_ty();
1281 let ty_lifetime = obligation.predicate.map_bound(|p| p.trait_ref.args.region_at(1));
1282
1283 match *self_ty.skip_binder().kind() {
1284 ty::Dynamic(_bounds, lifetime) => {
1285 obligations.push(obligation.with(
1286 tcx,
1287 ty_lifetime.map_bound(|ty_lifetime| ty::OutlivesClause(ty_lifetime, lifetime)),
1288 ));
1289 }
1290
1291 ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1292 {
::core::panicking::panic_fmt(format_args!("unexpected type `{0:?}`",
self_ty));
}panic!("unexpected type `{self_ty:?}`")
1293 }
1294
1295 _ => {}
1296 }
1297 ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1298 }
1299}