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/5989b83b125120725b75332ca63d15fe93c912dd/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
170 let candidate = candidate_predicate.map_bound(|t| t.trait_ref);
171
172 let candidate = self.infcx.instantiate_binder_with_fresh_vars(
173 obligation.cause.span,
174 BoundRegionConversionTime::HigherRankedType,
175 candidate,
176 );
177 let mut obligations = PredicateObligations::new();
178 let candidate = normalize_with_depth_to(
179 self,
180 obligation.param_env,
181 obligation.cause.clone(),
182 obligation.recursion_depth + 1,
183 ty::Unnormalized::new_wip(candidate),
184 &mut obligations,
185 );
186
187 obligations.extend(
188 self.infcx
189 .eq_raw(
190 &obligation.cause,
191 obligation.param_env,
192 DefineOpaqueTypes::No,
193 placeholder_trait_predicate,
194 candidate,
195 )
196 .map(|InferOk { obligations, .. }| obligations)
197 .map_err(|_| SelectionError::Unimplemented)?,
198 );
199
200 Ok(obligations)
201 }
202
203 fn confirm_param_candidate(
204 &mut self,
205 obligation: &PolyTraitObligation<'tcx>,
206 param: ty::PolyTraitRef<'tcx>,
207 ) -> PredicateObligations<'tcx> {
208 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:208",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(208u32),
::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");
209
210 match self.match_where_clause_trait_ref(obligation, param) {
215 Ok(obligations) => obligations,
216 Err(()) => {
217 ::rustc_span::macros::bug_impl(None,
format_args!("Where clause `{0:?}` was applicable to `{1:?}` but now is not",
param, obligation), Location::caller());bug!(
218 "Where clause `{:?}` was applicable to `{:?}` but now is not",
219 param,
220 obligation
221 );
222 }
223 }
224 }
225
226 {}
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/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(226u32),
::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/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:231",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(231u32),
::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/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:226",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(226u32),
::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)]
227 fn confirm_builtin_candidate(
228 &mut self,
229 obligation: &PolyTraitObligation<'tcx>,
230 ) -> PredicateObligations<'tcx> {
231 debug!(?obligation, "confirm_builtin_candidate");
232 let tcx = self.tcx();
233 let trait_def = obligation.predicate.def_id();
234 let self_ty = self.infcx.shallow_resolve(
235 self.infcx.enter_forall_and_leak_universe(obligation.predicate.self_ty()),
236 );
237 let types = match tcx.as_lang_item(trait_def) {
238 Some(LangItem::Sized) => self.sizedness_conditions(self_ty, SizedTraitKind::Sized),
239 Some(LangItem::MetaSized) => {
240 self.sizedness_conditions(self_ty, SizedTraitKind::MetaSized)
241 }
242 Some(LangItem::PointeeSized) => {
243 bug!("`PointeeSized` is removing during lowering");
244 }
245 Some(LangItem::Copy | LangItem::Clone | LangItem::TrivialClone) => {
246 self.copy_clone_conditions(self_ty)
247 }
248 Some(LangItem::FusedIterator) => {
249 if self.coroutine_is_gen(self_ty) {
250 ty::Binder::dummy(vec![])
251 } else {
252 unreachable!("tried to assemble `FusedIterator` for non-gen coroutine");
253 }
254 }
255 Some(
256 LangItem::Destruct
257 | LangItem::DiscriminantKind
258 | LangItem::Field
259 | LangItem::FnPtrTrait
260 | LangItem::FnAddrTrait
261 | LangItem::PointeeTrait
262 | LangItem::Tuple
263 | LangItem::Unpin,
264 ) => ty::Binder::dummy(vec![]),
265 other => bug!("unexpected builtin trait {trait_def:?} ({other:?})"),
266 };
267 let types = self.infcx.enter_forall_and_leak_universe(types);
268
269 let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
270 self.collect_predicates_for_types(
271 obligation.param_env,
272 cause,
273 obligation.recursion_depth + 1,
274 trait_def,
275 types,
276 )
277 }
278
279 {}
#[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/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(279u32),
::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/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:299",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(299u32),
::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/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:321",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(321u32),
::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))]
280 fn confirm_transmutability_candidate(
281 &mut self,
282 obligation: &PolyTraitObligation<'tcx>,
283 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
284 use rustc_middle::ty::transmute::Answer;
285
286 let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
287
288 let mut assume = predicate.trait_ref.args.const_at(2);
289 if self.tcx().features().generic_const_exprs() {
290 assume = crate::traits::evaluate_const(self.infcx, assume, obligation.param_env)
291 }
292 let Some(assume) = rustc_transmute::Assume::from_const(self.infcx.tcx, assume) else {
293 return Err(SelectionError::Unimplemented);
294 };
295
296 let dst = predicate.trait_ref.args.type_at(0);
297 let src = predicate.trait_ref.args.type_at(1);
298
299 debug!(?src, ?dst);
300 let mut transmute_env = rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx);
301 let maybe_transmutable = transmute_env.is_transmutable(src, dst, assume);
302
303 let fully_flattened = match maybe_transmutable {
304 Answer::No(_) => return Err(SelectionError::Unimplemented),
305 Answer::Yes => PredicateObligations::new(),
306 Answer::If(cond) => {
307 flatten_answer_tree(self.tcx(), obligation.predicate.skip_binder(), cond)
308 .into_iter()
309 .map(|predicate| {
310 Obligation::new(
311 self.infcx.tcx,
312 obligation.cause.clone(),
313 obligation.param_env,
314 predicate,
315 )
316 })
317 .collect()
318 }
319 };
320
321 debug!(?fully_flattened);
322 Ok(fully_flattened)
323 }
324
325 fn confirm_auto_impl_candidate(
331 &mut self,
332 obligation: &PolyTraitObligation<'tcx>,
333 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
334 {
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);
335
336 let self_ty = obligation.predicate.self_ty().map_bound(|ty| self.infcx.shallow_resolve(ty));
337 let self_ty = self.infcx.enter_forall_and_leak_universe(self_ty);
338
339 let constituents = self.constituent_types_for_auto_trait(self_ty)?;
340 let constituents = self.infcx.enter_forall_and_leak_universe(constituents);
341
342 let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
343 let mut obligations = self.collect_predicates_for_types(
344 obligation.param_env,
345 cause.clone(),
346 obligation.recursion_depth + 1,
347 obligation.predicate.def_id(),
348 constituents.types,
349 );
350
351 if self.tcx().sess.opts.unstable_opts.higher_ranked_assumptions {
355 for assumption in constituents.assumptions {
359 let assumption = normalize_with_depth_to(
360 self,
361 obligation.param_env,
362 cause.clone(),
363 obligation.recursion_depth + 1,
364 Unnormalized::new_wip(assumption),
365 &mut obligations,
366 );
367 self.infcx.register_region_assumption(assumption);
368 }
369 }
370
371 Ok(obligations)
372 }
373
374 fn confirm_impl_candidate(
375 &mut self,
376 obligation: &PolyTraitObligation<'tcx>,
377 impl_def_id: DefId,
378 ) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>> {
379 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:379",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(379u32),
::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");
380
381 let args = self.rematch_impl(impl_def_id, obligation);
384 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:384",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(384u32),
::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");
385
386 self.vtable_impl(
387 impl_def_id,
388 args,
389 &obligation.cause,
390 obligation.recursion_depth + 1,
391 obligation.param_env,
392 obligation.predicate,
393 )
394 }
395
396 fn vtable_impl(
397 &mut self,
398 impl_def_id: DefId,
399 args: Normalized<'tcx, GenericArgs<'tcx>>,
400 cause: &ObligationCause<'tcx>,
401 recursion_depth: usize,
402 param_env: ty::ParamEnv<'tcx>,
403 parent_trait_pred: ty::Binder<'tcx, ty::TraitClause<'tcx>>,
404 ) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>> {
405 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:405",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(405u32),
::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");
406
407 let mut impl_obligations = self.impl_or_trait_obligations(
408 cause,
409 recursion_depth,
410 param_env,
411 impl_def_id,
412 args.value,
413 parent_trait_pred,
414 );
415
416 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:416",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(416u32),
::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");
417
418 impl_obligations.extend(args.obligations);
424
425 ImplSourceUserDefinedData { impl_def_id, args: args.value, nested: impl_obligations }
426 }
427
428 fn confirm_object_candidate(
429 &mut self,
430 obligation: &PolyTraitObligation<'tcx>,
431 index: usize,
432 ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
433 let tcx = self.tcx();
434 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:434",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(434u32),
::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");
435
436 let trait_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
437 let self_ty = self.infcx.shallow_resolve(trait_predicate.self_ty());
438 let ty::Dynamic(data, ..) = *self_ty.kind() else {
439 ::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");
440 };
441
442 let object_trait_ref = data.principal().unwrap_or_else(|| {
443 ::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")
444 });
445 let object_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
446 obligation.cause.span,
447 BoundRegionConversionTime::HigherRankedType,
448 object_trait_ref,
449 );
450 let object_trait_ref = object_trait_ref.with_self_ty(self.tcx(), self_ty);
451
452 let mut nested = PredicateObligations::new();
453
454 let mut supertraits = util::supertraits(tcx, ty::Binder::dummy(object_trait_ref));
455 let unnormalized_upcast_trait_ref = supertraits
456 .nth(index)
457 .expect("supertraits iterator no longer has as many elements")
458 .map(|trait_ref| {
459 self.infcx.instantiate_binder_with_fresh_vars(
460 obligation.cause.span,
461 BoundRegionConversionTime::HigherRankedType,
462 trait_ref,
463 )
464 });
465 let upcast_trait_ref = normalize_with_depth_to(
466 self,
467 obligation.param_env,
468 obligation.cause.clone(),
469 obligation.recursion_depth + 1,
470 unnormalized_upcast_trait_ref,
471 &mut nested,
472 );
473
474 nested.extend(
475 self.infcx
476 .eq_raw(
477 &obligation.cause,
478 obligation.param_env,
479 DefineOpaqueTypes::No,
480 trait_predicate.trait_ref,
481 upcast_trait_ref,
482 )
483 .map(|InferOk { obligations, .. }| obligations)
484 .map_err(|_| SelectionError::Unimplemented)?,
485 );
486
487 for supertrait in tcx
490 .explicit_super_clauses_of(trait_predicate.def_id())
491 .iter_instantiated_copied(tcx, trait_predicate.trait_ref.args)
492 .map(|clause| clause.unzip().0)
493 {
494 let normalized_supertrait = normalize_with_depth_to(
495 self,
496 obligation.param_env,
497 obligation.cause.clone(),
498 obligation.recursion_depth + 1,
499 supertrait,
500 &mut nested,
501 );
502 nested.push(obligation.with(tcx, normalized_supertrait));
503 }
504
505 let assoc_types: Vec<_> = tcx
506 .associated_items(trait_predicate.def_id())
507 .in_definition_order()
508 .filter(|item| !tcx.generics_require_sized_self(item.def_id))
511 .filter_map(|item| if item.is_type() { Some(item.def_id) } else { None })
512 .collect();
513
514 for assoc_type in assoc_types {
515 let defs: &ty::Generics = tcx.generics_of(assoc_type);
516
517 if !defs.own_params.is_empty() {
518 tcx.dcx().span_delayed_bug(
519 obligation.cause.span,
520 "GATs in trait object shouldn't have been considered",
521 );
522 return Err(SelectionError::TraitDynIncompatible(trait_predicate.trait_ref.def_id));
523 }
524
525 for bound in self.tcx().item_bounds(assoc_type).transpose_iter() {
529 let normalized_bound = normalize_with_depth_to(
530 self,
531 obligation.param_env,
532 obligation.cause.clone(),
533 obligation.recursion_depth + 1,
534 bound.instantiate(tcx, trait_predicate.trait_ref.args),
535 &mut nested,
536 );
537 nested.push(obligation.with(tcx, normalized_bound));
538 }
539 }
540
541 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:541",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(541u32),
::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");
542
543 Ok(ImplSource::Builtin(BuiltinImplSource::Object(index), nested))
544 }
545
546 fn confirm_fn_pointer_candidate(
547 &mut self,
548 obligation: &PolyTraitObligation<'tcx>,
549 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
550 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:550",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(550u32),
::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");
551 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
552 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
553
554 let tcx = self.tcx();
555 let sig = self_ty.unnormalized_fn_sig(tcx);
556 let output_ty = sig.map(|sig| self.infcx.enter_forall_and_leak_universe(sig.output()));
557 let sig = sig.skip_norm_wip();
558 let trait_ref = closure_trait_ref_and_return_type(
559 tcx,
560 obligation.predicate.def_id(),
561 self_ty,
562 sig,
563 util::TupleArgumentsFlag::Yes,
564 )
565 .map_bound(|(trait_ref, _)| trait_ref);
566
567 let mut nested =
568 self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?;
569 let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
570
571 let output_ty = normalize_with_depth_to(
573 self,
574 obligation.param_env,
575 cause.clone(),
576 obligation.recursion_depth,
577 output_ty,
578 &mut nested,
579 );
580 let tr = ty::TraitRef::new(
581 self.tcx(),
582 self.tcx().require_lang_item(LangItem::Sized, cause.span),
583 [output_ty],
584 );
585 nested.push(Obligation::new(self.infcx.tcx, cause, obligation.param_env, tr));
586
587 Ok(nested)
588 }
589
590 fn confirm_trait_alias_candidate(
591 &mut self,
592 obligation: &PolyTraitObligation<'tcx>,
593 ) -> PredicateObligations<'tcx> {
594 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:594",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(594u32),
::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");
595
596 let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
597 let trait_ref = predicate.trait_ref;
598 let trait_def_id = trait_ref.def_id;
599 let args = trait_ref.args;
600
601 let trait_obligations = self.impl_or_trait_obligations(
602 &obligation.cause,
603 obligation.recursion_depth,
604 obligation.param_env,
605 trait_def_id,
606 args,
607 obligation.predicate,
608 );
609
610 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:610",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(610u32),
::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");
611
612 trait_obligations
613 }
614
615 fn confirm_coroutine_candidate(
616 &mut self,
617 obligation: &PolyTraitObligation<'tcx>,
618 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
619 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
620 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
621 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
622 ::rustc_span::macros::bug_impl(None,
format_args!("closure candidate for non-closure {0:?}", obligation),
Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
623 };
624
625 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:625",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(625u32),
::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");
626
627 let coroutine_sig = args.as_coroutine().sig();
628
629 let (trait_ref, _, _) = super::util::coroutine_trait_ref_and_outputs(
630 self.tcx(),
631 obligation.predicate.def_id(),
632 self_ty,
633 coroutine_sig,
634 );
635
636 let nested = self.equate_trait_refs(
637 obligation.with(self.tcx(), placeholder_predicate),
638 ty::Binder::dummy(trait_ref),
639 )?;
640 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:640",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(640u32),
::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");
641
642 Ok(nested)
643 }
644
645 fn confirm_future_candidate(
646 &mut self,
647 obligation: &PolyTraitObligation<'tcx>,
648 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
649 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
650 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
651 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
652 ::rustc_span::macros::bug_impl(None,
format_args!("closure candidate for non-closure {0:?}", obligation),
Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
653 };
654
655 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:655",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(655u32),
::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");
656
657 let coroutine_sig = args.as_coroutine().sig();
658
659 let (trait_ref, _) = super::util::future_trait_ref_and_outputs(
660 self.tcx(),
661 obligation.predicate.def_id(),
662 self_ty,
663 coroutine_sig,
664 );
665
666 let nested = self.equate_trait_refs(
667 obligation.with(self.tcx(), placeholder_predicate),
668 ty::Binder::dummy(trait_ref),
669 )?;
670 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:670",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(670u32),
::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");
671
672 Ok(nested)
673 }
674
675 fn confirm_iterator_candidate(
676 &mut self,
677 obligation: &PolyTraitObligation<'tcx>,
678 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
679 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
680 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
681 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
682 ::rustc_span::macros::bug_impl(None,
format_args!("closure candidate for non-closure {0:?}", obligation),
Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
683 };
684
685 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:685",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(685u32),
::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");
686
687 let gen_sig = args.as_coroutine().sig();
688
689 let (trait_ref, _) = super::util::iterator_trait_ref_and_outputs(
690 self.tcx(),
691 obligation.predicate.def_id(),
692 self_ty,
693 gen_sig,
694 );
695
696 let nested = self.equate_trait_refs(
697 obligation.with(self.tcx(), placeholder_predicate),
698 ty::Binder::dummy(trait_ref),
699 )?;
700 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:700",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(700u32),
::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");
701
702 Ok(nested)
703 }
704
705 fn confirm_async_iterator_candidate(
706 &mut self,
707 obligation: &PolyTraitObligation<'tcx>,
708 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
709 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
710 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
711 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
712 ::rustc_span::macros::bug_impl(None,
format_args!("closure candidate for non-closure {0:?}", obligation),
Location::caller());bug!("closure candidate for non-closure {:?}", obligation);
713 };
714
715 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:715",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(715u32),
::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");
716
717 let gen_sig = args.as_coroutine().sig();
718
719 let (trait_ref, _) = super::util::async_iterator_trait_ref_and_outputs(
720 self.tcx(),
721 obligation.predicate.def_id(),
722 self_ty,
723 gen_sig,
724 );
725
726 let nested = self.equate_trait_refs(
727 obligation.with(self.tcx(), placeholder_predicate),
728 ty::Binder::dummy(trait_ref),
729 )?;
730 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:730",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(730u32),
::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");
731
732 Ok(nested)
733 }
734
735 {}
#[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/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(735u32),
::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")]
736 fn confirm_closure_candidate(
737 &mut self,
738 obligation: &PolyTraitObligation<'tcx>,
739 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
740 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
741 let self_ty: Ty<'_> = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
742
743 let trait_ref = match *self_ty.kind() {
744 ty::Closure(..) => {
745 self.closure_trait_ref_unnormalized(self_ty, obligation.predicate.def_id())
746 }
747 ty::CoroutineClosure(_, args) => {
748 args.as_coroutine_closure().coroutine_closure_sig().map_bound(|sig| {
749 ty::TraitRef::new(
750 self.tcx(),
751 obligation.predicate.def_id(),
752 [self_ty, sig.tupled_inputs_ty],
753 )
754 })
755 }
756 _ => {
757 bug!("closure candidate for non-closure {:?}", obligation);
758 }
759 };
760
761 self.equate_trait_refs(obligation.with(self.tcx(), placeholder_predicate), trait_ref)
762 }
763
764 {}
#[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/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(764u32),
::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")]
765 fn confirm_async_closure_candidate(
766 &mut self,
767 obligation: &PolyTraitObligation<'tcx>,
768 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
769 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
770 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
771
772 let tcx = self.tcx();
773
774 let mut nested = PredicateObligations::new();
775 let (trait_ref, kind_ty) = match *self_ty.kind() {
776 ty::CoroutineClosure(_, args) => {
777 let args = args.as_coroutine_closure();
778 let trait_ref = args.coroutine_closure_sig().map_bound(|sig| {
779 ty::TraitRef::new(
780 self.tcx(),
781 obligation.predicate.def_id(),
782 [self_ty, sig.tupled_inputs_ty],
783 )
784 });
785
786 (trait_ref, args.kind_ty())
790 }
791 ty::FnDef(..) | ty::FnPtr(..) => {
792 let sig = self_ty.fn_sig(tcx);
793 let trait_ref = sig.map_bound(|sig| {
794 ty::TraitRef::new(
795 self.tcx(),
796 obligation.predicate.def_id(),
797 [self_ty, Ty::new_tup(tcx, sig.inputs())],
798 )
799 });
800
801 let future_trait_def_id =
803 tcx.require_lang_item(LangItem::Future, obligation.cause.span);
804 nested.push(obligation.with(
805 tcx,
806 sig.output().map_bound(|output_ty| {
807 ty::TraitRef::new(tcx, future_trait_def_id, [output_ty])
808 }),
809 ));
810 let sized_trait_def_id =
811 tcx.require_lang_item(LangItem::Sized, obligation.cause.span);
812 nested.push(obligation.with(
813 tcx,
814 sig.output().map_bound(|output_ty| {
815 ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
816 }),
817 ));
818
819 (trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn))
820 }
821 ty::Closure(_, args) => {
822 let args = args.as_closure();
823 let sig = args.sig();
824 let trait_ref = sig.map_bound(|sig| {
825 ty::TraitRef::new(
826 self.tcx(),
827 obligation.predicate.def_id(),
828 [self_ty, sig.inputs()[0]],
829 )
830 });
831
832 let future_trait_def_id =
834 tcx.require_lang_item(LangItem::Future, obligation.cause.span);
835 let placeholder_output_ty = self.infcx.enter_forall_and_leak_universe(sig.output());
836 nested.push(obligation.with(
837 tcx,
838 ty::TraitRef::new(tcx, future_trait_def_id, [placeholder_output_ty]),
839 ));
840 let sized_trait_def_id =
841 tcx.require_lang_item(LangItem::Sized, obligation.cause.span);
842 nested.push(obligation.with(
843 tcx,
844 sig.output().map_bound(|output_ty| {
845 ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
846 }),
847 ));
848
849 (trait_ref, args.kind_ty())
850 }
851 _ => bug!("expected callable type for AsyncFn candidate"),
852 };
853
854 nested.extend(
855 self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?,
856 );
857
858 let goal_kind =
859 self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
860
861 if let Some(closure_kind) = self.infcx.shallow_resolve(kind_ty).to_opt_closure_kind() {
865 if !closure_kind.extends(goal_kind) {
866 return Err(SelectionError::Unimplemented);
867 }
868 } else {
869 nested.push(Obligation::new(
870 self.tcx(),
871 obligation.derived_cause(ObligationCauseCode::BuiltinDerived),
872 obligation.param_env,
873 ty::TraitRef::new(
874 self.tcx(),
875 self.tcx()
876 .require_lang_item(LangItem::AsyncFnKindHelper, obligation.cause.span),
877 [kind_ty, Ty::from_closure_kind(self.tcx(), goal_kind)],
878 ),
879 ));
880 }
881
882 Ok(nested)
883 }
884
885 {}
#[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/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(910u32),
::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.eq_raw(&obligation.cause, obligation.param_env,
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")]
911 fn equate_trait_refs(
912 &mut self,
913 obligation: TraitObligation<'tcx>,
914 found_trait_ref: ty::PolyTraitRef<'tcx>,
915 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
916 let found_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
917 obligation.cause.span,
918 BoundRegionConversionTime::HigherRankedType,
919 found_trait_ref,
920 );
921 let Normalized { obligations: nested, value: (obligation_trait_ref, found_trait_ref) } =
923 normalize_with_depth(
924 self,
925 obligation.param_env,
926 obligation.cause.clone(),
927 obligation.recursion_depth + 1,
928 Unnormalized::new_wip((obligation.predicate.trait_ref, found_trait_ref)),
929 );
930
931 self.infcx
933 .eq_raw(
934 &obligation.cause,
935 obligation.param_env,
936 DefineOpaqueTypes::Yes,
937 obligation_trait_ref,
938 found_trait_ref,
939 )
940 .map(|InferOk { mut obligations, .. }| {
941 obligations.extend(nested);
942 obligations
943 })
944 .map_err(|terr| {
945 SelectionError::SignatureMismatch(Box::new(SignatureMismatchData {
946 expected_trait_ref: obligation_trait_ref,
947 found_trait_ref,
948 terr,
949 }))
950 })
951 }
952
953 fn confirm_trait_upcasting_unsize_candidate(
954 &mut self,
955 obligation: &PolyTraitObligation<'tcx>,
956 idx: usize,
957 ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
958 let tcx = self.tcx();
959
960 let predicate = obligation.predicate.no_bound_vars().unwrap();
963 let a_ty = self.infcx.shallow_resolve(predicate.self_ty());
964 let b_ty = self.infcx.shallow_resolve(predicate.trait_ref.args.type_at(1));
965
966 let ty::Dynamic(a_data, a_region) = *a_ty.kind() else {
967 ::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`")
968 };
969 let ty::Dynamic(b_data, b_region) = *b_ty.kind() else {
970 ::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`")
971 };
972
973 let source_principal = a_data.principal().unwrap().with_self_ty(tcx, a_ty);
974 let unnormalized_upcast_principal =
975 util::supertraits(tcx, source_principal).nth(idx).unwrap();
976
977 let nested = self
978 .match_upcast_principal(
979 obligation,
980 unnormalized_upcast_principal,
981 a_data,
982 b_data,
983 a_region,
984 b_region,
985 )?
986 .expect("did not expect ambiguity during confirmation");
987
988 Ok(ImplSource::Builtin(BuiltinImplSource::TraitUpcasting(idx), nested))
989 }
990
991 fn confirm_builtin_unsize_candidate(
992 &mut self,
993 obligation: &PolyTraitObligation<'tcx>,
994 ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
995 let tcx = self.tcx();
996
997 let source = self.infcx.shallow_resolve(obligation.self_ty().no_bound_vars().unwrap());
1000 let target = obligation.predicate.skip_binder().trait_ref.args.type_at(1);
1001 let target = self.infcx.shallow_resolve(target);
1002 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs:1002",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/5989b83b125120725b75332ca63d15fe93c912dd/compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(1002u32),
::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");
1003
1004 Ok(match (source.kind(), target.kind()) {
1005 (&ty::Dynamic(data_a, r_a), &ty::Dynamic(data_b, r_b)) => {
1007 let existential_predicates = if data_b.principal().is_some() {
1010 tcx.mk_poly_existential_predicates_from_iter(
1011 data_a
1012 .principal()
1013 .map(|b| b.map_bound(ty::ExistentialPredicate::Trait))
1014 .into_iter()
1015 .chain(
1016 data_a
1017 .projection_bounds()
1018 .map(|b| b.map_bound(ty::ExistentialPredicate::Projection)),
1019 )
1020 .chain(
1021 data_b
1022 .auto_traits()
1023 .map(ty::ExistentialPredicate::AutoTrait)
1024 .map(ty::Binder::dummy),
1025 ),
1026 )
1027 } else {
1028 tcx.mk_poly_existential_predicates_from_iter(
1033 data_b
1034 .auto_traits()
1035 .map(ty::ExistentialPredicate::AutoTrait)
1036 .map(ty::Binder::dummy),
1037 )
1038 };
1039 let source_trait = Ty::new_dynamic(tcx, existential_predicates, r_b);
1040
1041 let InferOk { mut obligations, .. } = self
1044 .infcx
1045 .sup_raw(
1046 &obligation.cause,
1047 obligation.param_env,
1048 DefineOpaqueTypes::Yes,
1049 target,
1050 source_trait,
1051 )
1052 .map_err(|_| SelectionError::Unimplemented)?;
1053
1054 let outlives = ty::OutlivesClause(r_a, r_b);
1056 obligations.push(Obligation::with_depth(
1057 tcx,
1058 obligation.cause.clone(),
1059 obligation.recursion_depth + 1,
1060 obligation.param_env,
1061 obligation.predicate.rebind(outlives),
1062 ));
1063
1064 ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1065 }
1066
1067 (_, &ty::Dynamic(data, r)) => {
1069 let mut object_dids = data.auto_traits().chain(data.principal_def_id());
1070 if let Some(did) = object_dids.find(|did| !tcx.is_dyn_compatible(*did)) {
1071 return Err(SelectionError::TraitDynIncompatible(did));
1072 }
1073
1074 let predicate_to_obligation = |predicate| {
1075 Obligation::with_depth(
1076 tcx,
1077 obligation.cause.clone(),
1078 obligation.recursion_depth + 1,
1079 obligation.param_env,
1080 predicate,
1081 )
1082 };
1083
1084 let mut nested: PredicateObligations<'_> = data
1091 .iter()
1092 .map(|predicate| predicate_to_obligation(predicate.with_self_ty(tcx, source)))
1093 .collect();
1094
1095 let tr = ty::TraitRef::new(
1097 tcx,
1098 tcx.require_lang_item(LangItem::Sized, obligation.cause.span),
1099 [source],
1100 );
1101 nested.push(predicate_to_obligation(tr.upcast(tcx)));
1102
1103 let outlives = ty::OutlivesClause(source, r);
1106 nested.push(predicate_to_obligation(
1107 ty::ClauseKind::TypeOutlives(outlives).upcast(tcx),
1108 ));
1109
1110 ImplSource::Builtin(BuiltinImplSource::Misc, nested)
1111 }
1112
1113 (&ty::Array(a, _), &ty::Slice(b)) => {
1115 let InferOk { obligations, .. } = self
1116 .infcx
1117 .eq_raw(&obligation.cause, obligation.param_env, DefineOpaqueTypes::Yes, b, a)
1118 .map_err(|_| SelectionError::Unimplemented)?;
1119
1120 ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1121 }
1122
1123 (&ty::Adt(def, args_a), &ty::Adt(_, args_b)) => {
1125 let unsizing_params = tcx.unsizing_params_for_adt(def.did());
1126 if unsizing_params.is_empty() {
1127 return Err(SelectionError::Unimplemented);
1128 }
1129
1130 let tail_field = def.non_enum_variant().tail();
1131 let tail_field_ty = tcx.type_of(tail_field.did);
1132
1133 let mut nested = PredicateObligations::new();
1134
1135 let source_tail = normalize_with_depth_to(
1139 self,
1140 obligation.param_env,
1141 obligation.cause.clone(),
1142 obligation.recursion_depth + 1,
1143 tail_field_ty.instantiate(tcx, args_a),
1144 &mut nested,
1145 );
1146 let target_tail = normalize_with_depth_to(
1147 self,
1148 obligation.param_env,
1149 obligation.cause.clone(),
1150 obligation.recursion_depth + 1,
1151 tail_field_ty.instantiate(tcx, args_b),
1152 &mut nested,
1153 );
1154
1155 let args =
1158 tcx.mk_args_from_iter(args_a.iter().enumerate().map(|(i, k)| {
1159 if unsizing_params.contains(i as u32) { args_b[i] } else { k }
1160 }));
1161 let new_struct = Ty::new_adt(tcx, def, args);
1162 let InferOk { obligations, .. } = self
1163 .infcx
1164 .eq_raw(
1165 &obligation.cause,
1166 obligation.param_env,
1167 DefineOpaqueTypes::Yes,
1168 target,
1169 new_struct,
1170 )
1171 .map_err(|_| SelectionError::Unimplemented)?;
1172 nested.extend(obligations);
1173
1174 let tail_unsize_obligation = obligation.with(
1176 tcx,
1177 ty::TraitRef::new(
1178 tcx,
1179 obligation.predicate.def_id(),
1180 [source_tail, target_tail],
1181 ),
1182 );
1183 nested.push(tail_unsize_obligation);
1184
1185 ImplSource::Builtin(BuiltinImplSource::Misc, nested)
1186 }
1187
1188 _ => ::rustc_span::macros::bug_impl(None,
format_args!("source: {0}, target: {1}", source, target),
Location::caller())bug!("source: {source}, target: {target}"),
1189 })
1190 }
1191
1192 fn confirm_bikeshed_guaranteed_no_drop_candidate(
1195 &mut self,
1196 obligation: &PolyTraitObligation<'tcx>,
1197 ) -> ImplSource<'tcx, PredicateObligation<'tcx>> {
1198 let mut obligations = ::thin_vec::ThinVec::new()thin_vec![];
1199
1200 let tcx = self.tcx();
1201 let self_ty = obligation.predicate.self_ty();
1202 match *self_ty.skip_binder().kind() {
1203 ty::Ref(..) => {}
1205 ty::Adt(def, _) if def.is_manually_drop() => {}
1207 ty::Tuple(tys) => {
1210 obligations.extend(tys.iter().map(|elem_ty| {
1211 obligation.with(
1212 tcx,
1213 self_ty.rebind(ty::TraitRef::new(
1214 tcx,
1215 obligation.predicate.def_id(),
1216 [elem_ty],
1217 )),
1218 )
1219 }));
1220 }
1221 ty::Array(elem_ty, _) => {
1222 obligations.push(obligation.with(
1223 tcx,
1224 self_ty.rebind(ty::TraitRef::new(
1225 tcx,
1226 obligation.predicate.def_id(),
1227 [elem_ty],
1228 )),
1229 ));
1230 }
1231
1232 ty::FnDef(..)
1236 | ty::FnPtr(..)
1237 | ty::Error(_)
1238 | ty::Uint(_)
1239 | ty::Int(_)
1240 | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1241 | ty::Bool
1242 | ty::Float(_)
1243 | ty::Char
1244 | ty::RawPtr(..)
1245 | ty::Never
1246 | ty::Pat(..)
1247 | ty::Dynamic(..)
1248 | ty::Str
1249 | ty::Slice(_)
1250 | ty::Foreign(..)
1251 | ty::Adt(..)
1252 | ty::Alias(..)
1253 | ty::Param(_)
1254 | ty::Placeholder(..)
1255 | ty::Closure(..)
1256 | ty::CoroutineClosure(..)
1257 | ty::Coroutine(..)
1258 | ty::UnsafeBinder(_)
1259 | ty::CoroutineWitness(..)
1260 | ty::Bound(..) => {
1261 obligations.push(obligation.with(
1262 tcx,
1263 self_ty.map_bound(|ty| {
1264 ty::TraitRef::new(
1265 tcx,
1266 tcx.require_lang_item(LangItem::Copy, obligation.cause.span),
1267 [ty],
1268 )
1269 }),
1270 ));
1271 }
1272
1273 ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1274 {
::core::panicking::panic_fmt(format_args!("unexpected type `{0:?}`",
self_ty));
}panic!("unexpected type `{self_ty:?}`")
1275 }
1276
1277 ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
1279 }
1280
1281 ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1282 }
1283
1284 fn confirm_try_as_dyn_candidate(
1285 &mut self,
1286 obligation: &PolyTraitObligation<'tcx>,
1287 ) -> ImplSource<'tcx, PredicateObligation<'tcx>> {
1288 let tcx = self.tcx();
1289
1290 let mut obligations = PredicateObligations::new();
1291
1292 let self_ty = obligation.predicate.self_ty();
1293 let ty_lifetime = obligation.predicate.map_bound(|p| p.trait_ref.args.region_at(1));
1294
1295 match *self_ty.skip_binder().kind() {
1296 ty::Dynamic(_bounds, lifetime) => {
1297 obligations.push(obligation.with(
1298 tcx,
1299 ty_lifetime.map_bound(|ty_lifetime| ty::OutlivesClause(ty_lifetime, lifetime)),
1300 ));
1301 }
1302
1303 ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1304 {
::core::panicking::panic_fmt(format_args!("unexpected type `{0:?}`",
self_ty));
}panic!("unexpected type `{self_ty:?}`")
1305 }
1306
1307 _ => {}
1308 }
1309 ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1310 }
1311}