1use std::ops::ControlFlow;
11
12use rustc_data_structures::stack::ensure_sufficient_stack;
13use rustc_hir::lang_items::LangItem;
14use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk};
15use rustc_infer::traits::ObligationCauseCode;
16use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData};
17use rustc_middle::ty::{self, GenericArgsRef, Region, SizedTraitKind, Ty, TyCtxt, Upcast};
18use rustc_middle::{bug, span_bug};
19use rustc_span::def_id::DefId;
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("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(&["obligation",
"candidate"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
as &dyn 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)
}
})
}
}
}#[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 }
141
142 fn confirm_projection_candidate(
143 &mut self,
144 obligation: &PolyTraitObligation<'tcx>,
145 idx: usize,
146 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
147 let placeholder_trait_predicate =
148 self.infcx.enter_forall_and_leak_universe(obligation.predicate).trait_ref;
149 let placeholder_self_ty = self.infcx.shallow_resolve(placeholder_trait_predicate.self_ty());
150 let candidate_predicate = self
151 .for_each_item_bound(
152 placeholder_self_ty,
153 |_, clause, clause_idx, _| {
154 if clause_idx == idx {
155 ControlFlow::Break(clause)
156 } else {
157 ControlFlow::Continue(())
158 }
159 },
160 || ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
161 )
162 .break_value()
163 .expect("expected to index into clause that exists");
164 let candidate_predicate = candidate_predicate
165 .as_trait_clause()
166 .expect("projection candidate is not a trait predicate");
167 let candidate_predicate =
168 util::lazily_elaborate_sizedness_candidate(self.infcx, obligation, candidate_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 candidate,
184 &mut obligations,
185 );
186
187 obligations.extend(
188 self.infcx
189 .at(&obligation.cause, obligation.param_env)
190 .eq(DefineOpaqueTypes::No, placeholder_trait_predicate, candidate)
191 .map(|InferOk { obligations, .. }| obligations)
192 .map_err(|_| SelectionError::Unimplemented)?,
193 );
194
195 Ok(obligations)
196 }
197
198 fn confirm_param_candidate(
199 &mut self,
200 obligation: &PolyTraitObligation<'tcx>,
201 param: ty::PolyTraitRef<'tcx>,
202 ) -> PredicateObligations<'tcx> {
203 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:203",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(203u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"obligation", "param"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("confirm_param_candidate")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&obligation)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(¶m) as
&dyn Value))])
});
} else { ; }
};debug!(?obligation, ?param, "confirm_param_candidate");
204
205 let param = util::lazily_elaborate_sizedness_candidate(
206 self.infcx,
207 obligation,
208 param.upcast(self.infcx.tcx),
209 )
210 .map_bound(|p| p.trait_ref);
211
212 match self.match_where_clause_trait_ref(obligation, param) {
217 Ok(obligations) => obligations,
218 Err(()) => {
219 ::rustc_middle::util::bug::bug_fmt(format_args!("Where clause `{0:?}` was applicable to `{1:?}` but now is not",
param, obligation));bug!(
220 "Where clause `{:?}` was applicable to `{:?}` but now is not",
221 param,
222 obligation
223 );
224 }
225 }
226 }
227
228 x;#[instrument(level = "debug", skip(self), ret)]
229 fn confirm_builtin_candidate(
230 &mut self,
231 obligation: &PolyTraitObligation<'tcx>,
232 ) -> PredicateObligations<'tcx> {
233 debug!(?obligation, "confirm_builtin_candidate");
234 let tcx = self.tcx();
235 let trait_def = obligation.predicate.def_id();
236 let self_ty = self.infcx.shallow_resolve(
237 self.infcx.enter_forall_and_leak_universe(obligation.predicate.self_ty()),
238 );
239 let types = match tcx.as_lang_item(trait_def) {
240 Some(LangItem::Sized) => self.sizedness_conditions(self_ty, SizedTraitKind::Sized),
241 Some(LangItem::MetaSized) => {
242 self.sizedness_conditions(self_ty, SizedTraitKind::MetaSized)
243 }
244 Some(LangItem::PointeeSized) => {
245 bug!("`PointeeSized` is removing during lowering");
246 }
247 Some(LangItem::Copy | LangItem::Clone | LangItem::TrivialClone) => {
248 self.copy_clone_conditions(self_ty)
249 }
250 Some(LangItem::FusedIterator) => {
251 if self.coroutine_is_gen(self_ty) {
252 ty::Binder::dummy(vec![])
253 } else {
254 unreachable!("tried to assemble `FusedIterator` for non-gen coroutine");
255 }
256 }
257 Some(
258 LangItem::Destruct
259 | LangItem::DiscriminantKind
260 | LangItem::Field
261 | LangItem::FnPtrTrait
262 | LangItem::PointeeTrait
263 | LangItem::Tuple
264 | LangItem::Unpin,
265 ) => ty::Binder::dummy(vec![]),
266 other => bug!("unexpected builtin trait {trait_def:?} ({other:?})"),
267 };
268 let types = self.infcx.enter_forall_and_leak_universe(types);
269
270 let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
271 self.collect_predicates_for_types(
272 obligation.param_env,
273 cause,
274 obligation.recursion_depth + 1,
275 trait_def,
276 types,
277 )
278 }
279
280 #[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("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(280u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["obligation"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn 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_transmute::{Answer, Assume, Condition};
#[doc =
" Flatten the `Condition` tree into a conjunction of obligations."]
fn flatten_answer_tree<'tcx>(tcx: TyCtxt<'tcx>,
obligation: &PolyTraitObligation<'tcx>,
cond: Condition<Region<'tcx>, Ty<'tcx>>, assume: Assume)
-> PredicateObligations<'tcx> {
{}
#[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("flatten_answer_tree",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(288u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["cond", "assume"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&cond)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assume)
as &dyn 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: PredicateObligations<'tcx> =
loop {};
return __tracing_attr_fake_return;
}
{
match cond {
Condition::IfAll(conds) | Condition::IfAny(conds) =>
conds.into_iter().flat_map(|cond|
flatten_answer_tree(tcx, obligation, cond,
assume)).collect(),
Condition::Immutable { ty } => {
let trait_ref =
ty::TraitRef::new(tcx,
tcx.require_lang_item(LangItem::Freeze,
obligation.cause.span), [ty::GenericArg::from(ty)]);
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(Obligation::with_depth(tcx,
obligation.cause.clone(), obligation.recursion_depth + 1,
obligation.param_env, trait_ref));
vec
}
}
Condition::Outlives { long, short } => {
let outlives = ty::OutlivesPredicate(long, short);
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(Obligation::with_depth(tcx,
obligation.cause.clone(), obligation.recursion_depth + 1,
obligation.param_env, outlives));
vec
}
}
Condition::Transmutable { src, dst } => {
let transmute_trait = obligation.predicate.def_id();
let assume =
obligation.predicate.skip_binder().trait_ref.args.const_at(2);
let trait_ref =
ty::TraitRef::new(tcx, transmute_trait,
[ty::GenericArg::from(dst), ty::GenericArg::from(src),
ty::GenericArg::from(assume)]);
{
let len = [()].len();
let mut vec = ::thin_vec::ThinVec::with_capacity(len);
vec.push(Obligation::with_depth(tcx,
obligation.cause.clone(), obligation.recursion_depth + 1,
obligation.param_env, trait_ref));
vec
}
}
}
}
}
}
}
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 compiler/rustc_trait_selection/src/traits/select/confirmation.rs:362",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(362u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["src", "dst"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&src) as
&dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&dst) as
&dyn 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(_) => Err(SelectionError::Unimplemented)?,
Answer::If(cond) =>
flatten_answer_tree(self.tcx(), obligation, cond, assume),
Answer::Yes => PredicateObligations::new(),
};
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:372",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(372u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["fully_flattened"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&fully_flattened)
as &dyn Value))])
});
} else { ; }
};
Ok(fully_flattened)
}
}
}#[instrument(level = "debug", skip(self))]
281 fn confirm_transmutability_candidate(
282 &mut self,
283 obligation: &PolyTraitObligation<'tcx>,
284 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
285 use rustc_transmute::{Answer, Assume, Condition};
286
287 #[instrument(level = "debug", skip(tcx, obligation))]
289 fn flatten_answer_tree<'tcx>(
290 tcx: TyCtxt<'tcx>,
291 obligation: &PolyTraitObligation<'tcx>,
292 cond: Condition<Region<'tcx>, Ty<'tcx>>,
293 assume: Assume,
294 ) -> PredicateObligations<'tcx> {
295 match cond {
296 Condition::IfAll(conds) | Condition::IfAny(conds) => conds
299 .into_iter()
300 .flat_map(|cond| flatten_answer_tree(tcx, obligation, cond, assume))
301 .collect(),
302 Condition::Immutable { ty } => {
303 let trait_ref = ty::TraitRef::new(
304 tcx,
305 tcx.require_lang_item(LangItem::Freeze, obligation.cause.span),
306 [ty::GenericArg::from(ty)],
307 );
308 thin_vec![Obligation::with_depth(
309 tcx,
310 obligation.cause.clone(),
311 obligation.recursion_depth + 1,
312 obligation.param_env,
313 trait_ref,
314 )]
315 }
316 Condition::Outlives { long, short } => {
317 let outlives = ty::OutlivesPredicate(long, short);
318 thin_vec![Obligation::with_depth(
319 tcx,
320 obligation.cause.clone(),
321 obligation.recursion_depth + 1,
322 obligation.param_env,
323 outlives,
324 )]
325 }
326 Condition::Transmutable { src, dst } => {
327 let transmute_trait = obligation.predicate.def_id();
328 let assume = obligation.predicate.skip_binder().trait_ref.args.const_at(2);
329 let trait_ref = ty::TraitRef::new(
330 tcx,
331 transmute_trait,
332 [
333 ty::GenericArg::from(dst),
334 ty::GenericArg::from(src),
335 ty::GenericArg::from(assume),
336 ],
337 );
338 thin_vec![Obligation::with_depth(
339 tcx,
340 obligation.cause.clone(),
341 obligation.recursion_depth + 1,
342 obligation.param_env,
343 trait_ref,
344 )]
345 }
346 }
347 }
348
349 let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
350
351 let mut assume = predicate.trait_ref.args.const_at(2);
352 if self.tcx().features().generic_const_exprs() {
353 assume = crate::traits::evaluate_const(self.infcx, assume, obligation.param_env)
354 }
355 let Some(assume) = rustc_transmute::Assume::from_const(self.infcx.tcx, assume) else {
356 return Err(SelectionError::Unimplemented);
357 };
358
359 let dst = predicate.trait_ref.args.type_at(0);
360 let src = predicate.trait_ref.args.type_at(1);
361
362 debug!(?src, ?dst);
363 let mut transmute_env = rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx);
364 let maybe_transmutable = transmute_env.is_transmutable(src, dst, assume);
365
366 let fully_flattened = match maybe_transmutable {
367 Answer::No(_) => Err(SelectionError::Unimplemented)?,
368 Answer::If(cond) => flatten_answer_tree(self.tcx(), obligation, cond, assume),
369 Answer::Yes => PredicateObligations::new(),
370 };
371
372 debug!(?fully_flattened);
373 Ok(fully_flattened)
374 }
375
376 fn confirm_auto_impl_candidate(
382 &mut self,
383 obligation: &PolyTraitObligation<'tcx>,
384 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
385 ensure_sufficient_stack(|| {
386 match (&obligation.predicate.polarity(), &ty::PredicatePolarity::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::PredicatePolarity::Positive);
387
388 let self_ty =
389 obligation.predicate.self_ty().map_bound(|ty| self.infcx.shallow_resolve(ty));
390 let self_ty = self.infcx.enter_forall_and_leak_universe(self_ty);
391
392 let constituents = self.constituent_types_for_auto_trait(self_ty)?;
393 let constituents = self.infcx.enter_forall_and_leak_universe(constituents);
394
395 let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
396 let mut obligations = self.collect_predicates_for_types(
397 obligation.param_env,
398 cause.clone(),
399 obligation.recursion_depth + 1,
400 obligation.predicate.def_id(),
401 constituents.types,
402 );
403
404 if self.tcx().sess.opts.unstable_opts.higher_ranked_assumptions {
408 for assumption in constituents.assumptions {
412 let assumption = normalize_with_depth_to(
413 self,
414 obligation.param_env,
415 cause.clone(),
416 obligation.recursion_depth + 1,
417 assumption,
418 &mut obligations,
419 );
420 self.infcx.register_region_assumption(assumption);
421 }
422 }
423
424 Ok(obligations)
425 })
426 }
427
428 fn confirm_impl_candidate(
429 &mut self,
430 obligation: &PolyTraitObligation<'tcx>,
431 impl_def_id: DefId,
432 ) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>> {
433 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:433",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(433u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"obligation", "impl_def_id"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("confirm_impl_candidate")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&obligation)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&impl_def_id)
as &dyn Value))])
});
} else { ; }
};debug!(?obligation, ?impl_def_id, "confirm_impl_candidate");
434
435 let args = self.rematch_impl(impl_def_id, obligation);
438 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:438",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(438u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message", "args"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("impl args")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&args) as
&dyn Value))])
});
} else { ; }
};debug!(?args, "impl args");
439 ensure_sufficient_stack(|| {
440 self.vtable_impl(
441 impl_def_id,
442 args,
443 &obligation.cause,
444 obligation.recursion_depth + 1,
445 obligation.param_env,
446 obligation.predicate,
447 )
448 })
449 }
450
451 fn vtable_impl(
452 &mut self,
453 impl_def_id: DefId,
454 args: Normalized<'tcx, GenericArgsRef<'tcx>>,
455 cause: &ObligationCause<'tcx>,
456 recursion_depth: usize,
457 param_env: ty::ParamEnv<'tcx>,
458 parent_trait_pred: ty::Binder<'tcx, ty::TraitPredicate<'tcx>>,
459 ) -> ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>> {
460 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:460",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(460u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"impl_def_id", "args", "recursion_depth"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("vtable_impl")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&impl_def_id)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&args) as
&dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&recursion_depth)
as &dyn Value))])
});
} else { ; }
};debug!(?impl_def_id, ?args, ?recursion_depth, "vtable_impl");
461
462 let mut impl_obligations = self.impl_or_trait_obligations(
463 cause,
464 recursion_depth,
465 param_env,
466 impl_def_id,
467 args.value,
468 parent_trait_pred,
469 );
470
471 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:471",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(471u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"impl_obligations"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("vtable_impl")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&impl_obligations)
as &dyn Value))])
});
} else { ; }
};debug!(?impl_obligations, "vtable_impl");
472
473 impl_obligations.extend(args.obligations);
479
480 ImplSourceUserDefinedData { impl_def_id, args: args.value, nested: impl_obligations }
481 }
482
483 fn confirm_object_candidate(
484 &mut self,
485 obligation: &PolyTraitObligation<'tcx>,
486 index: usize,
487 ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
488 let tcx = self.tcx();
489 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:489",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(489u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"obligation", "index"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("confirm_object_candidate")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&obligation)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&index) as
&dyn Value))])
});
} else { ; }
};debug!(?obligation, ?index, "confirm_object_candidate");
490
491 let trait_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
492 let self_ty = self.infcx.shallow_resolve(trait_predicate.self_ty());
493 let ty::Dynamic(data, ..) = *self_ty.kind() else {
494 ::rustc_middle::util::bug::span_bug_fmt(obligation.cause.span,
format_args!("object candidate with non-object"));span_bug!(obligation.cause.span, "object candidate with non-object");
495 };
496
497 let object_trait_ref = data.principal().unwrap_or_else(|| {
498 ::rustc_middle::util::bug::span_bug_fmt(obligation.cause.span,
format_args!("object candidate with no principal"))span_bug!(obligation.cause.span, "object candidate with no principal")
499 });
500 let object_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
501 obligation.cause.span,
502 BoundRegionConversionTime::HigherRankedType,
503 object_trait_ref,
504 );
505 let object_trait_ref = object_trait_ref.with_self_ty(self.tcx(), self_ty);
506
507 let mut nested = PredicateObligations::new();
508
509 let mut supertraits = util::supertraits(tcx, ty::Binder::dummy(object_trait_ref));
510 let unnormalized_upcast_trait_ref =
511 supertraits.nth(index).expect("supertraits iterator no longer has as many elements");
512
513 let upcast_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
514 obligation.cause.span,
515 BoundRegionConversionTime::HigherRankedType,
516 unnormalized_upcast_trait_ref,
517 );
518 let upcast_trait_ref = normalize_with_depth_to(
519 self,
520 obligation.param_env,
521 obligation.cause.clone(),
522 obligation.recursion_depth + 1,
523 upcast_trait_ref,
524 &mut nested,
525 );
526
527 nested.extend(
528 self.infcx
529 .at(&obligation.cause, obligation.param_env)
530 .eq(DefineOpaqueTypes::No, trait_predicate.trait_ref, upcast_trait_ref)
531 .map(|InferOk { obligations, .. }| obligations)
532 .map_err(|_| SelectionError::Unimplemented)?,
533 );
534
535 for (supertrait, _) in tcx
538 .explicit_super_predicates_of(trait_predicate.def_id())
539 .iter_instantiated_copied(tcx, trait_predicate.trait_ref.args)
540 {
541 let normalized_supertrait = normalize_with_depth_to(
542 self,
543 obligation.param_env,
544 obligation.cause.clone(),
545 obligation.recursion_depth + 1,
546 supertrait,
547 &mut nested,
548 );
549 nested.push(obligation.with(tcx, normalized_supertrait));
550 }
551
552 let assoc_types: Vec<_> = tcx
553 .associated_items(trait_predicate.def_id())
554 .in_definition_order()
555 .filter(|item| !tcx.generics_require_sized_self(item.def_id))
558 .filter_map(|item| if item.is_type() { Some(item.def_id) } else { None })
559 .collect();
560
561 for assoc_type in assoc_types {
562 let defs: &ty::Generics = tcx.generics_of(assoc_type);
563
564 if !defs.own_params.is_empty() {
565 tcx.dcx().span_delayed_bug(
566 obligation.cause.span,
567 "GATs in trait object shouldn't have been considered",
568 );
569 return Err(SelectionError::TraitDynIncompatible(trait_predicate.trait_ref.def_id));
570 }
571
572 for bound in self.tcx().item_bounds(assoc_type).transpose_iter() {
576 let normalized_bound = normalize_with_depth_to(
577 self,
578 obligation.param_env,
579 obligation.cause.clone(),
580 obligation.recursion_depth + 1,
581 bound.instantiate(tcx, trait_predicate.trait_ref.args),
582 &mut nested,
583 );
584 nested.push(obligation.with(tcx, normalized_bound));
585 }
586 }
587
588 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:588",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(588u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message", "nested"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("object nested obligations")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&nested) as
&dyn Value))])
});
} else { ; }
};debug!(?nested, "object nested obligations");
589
590 Ok(ImplSource::Builtin(BuiltinImplSource::Object(index), nested))
591 }
592
593 fn confirm_fn_pointer_candidate(
594 &mut self,
595 obligation: &PolyTraitObligation<'tcx>,
596 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
597 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:597",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(597u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"obligation"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("confirm_fn_pointer_candidate")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&obligation)
as &dyn Value))])
});
} else { ; }
};debug!(?obligation, "confirm_fn_pointer_candidate");
598 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
599 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
600
601 let tcx = self.tcx();
602 let sig = self_ty.fn_sig(tcx);
603 let trait_ref = closure_trait_ref_and_return_type(
604 tcx,
605 obligation.predicate.def_id(),
606 self_ty,
607 sig,
608 util::TupleArgumentsFlag::Yes,
609 )
610 .map_bound(|(trait_ref, _)| trait_ref);
611
612 let mut nested =
613 self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?;
614 let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
615
616 let output_ty = self.infcx.enter_forall_and_leak_universe(sig.output());
618 let output_ty = normalize_with_depth_to(
619 self,
620 obligation.param_env,
621 cause.clone(),
622 obligation.recursion_depth,
623 output_ty,
624 &mut nested,
625 );
626 let tr = ty::TraitRef::new(
627 self.tcx(),
628 self.tcx().require_lang_item(LangItem::Sized, cause.span),
629 [output_ty],
630 );
631 nested.push(Obligation::new(self.infcx.tcx, cause, obligation.param_env, tr));
632
633 Ok(nested)
634 }
635
636 fn confirm_trait_alias_candidate(
637 &mut self,
638 obligation: &PolyTraitObligation<'tcx>,
639 ) -> PredicateObligations<'tcx> {
640 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event 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("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",
"obligation"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("confirm_trait_alias_candidate")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&obligation)
as &dyn Value))])
});
} else { ; }
};debug!(?obligation, "confirm_trait_alias_candidate");
641
642 let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
643 let trait_ref = predicate.trait_ref;
644 let trait_def_id = trait_ref.def_id;
645 let args = trait_ref.args;
646
647 let trait_obligations = self.impl_or_trait_obligations(
648 &obligation.cause,
649 obligation.recursion_depth,
650 obligation.param_env,
651 trait_def_id,
652 args,
653 obligation.predicate,
654 );
655
656 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:656",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(656u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"trait_def_id", "trait_obligations"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("trait alias obligations")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&trait_def_id)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&trait_obligations)
as &dyn Value))])
});
} else { ; }
};debug!(?trait_def_id, ?trait_obligations, "trait alias obligations");
657
658 trait_obligations
659 }
660
661 fn confirm_coroutine_candidate(
662 &mut self,
663 obligation: &PolyTraitObligation<'tcx>,
664 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
665 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
666 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
667 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
668 ::rustc_middle::util::bug::bug_fmt(format_args!("closure candidate for non-closure {0:?}",
obligation));bug!("closure candidate for non-closure {:?}", obligation);
669 };
670
671 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:671",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(671u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"obligation", "coroutine_def_id", "args"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("confirm_coroutine_candidate")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&obligation)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&coroutine_def_id)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&args) as
&dyn Value))])
});
} else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_coroutine_candidate");
672
673 let coroutine_sig = args.as_coroutine().sig();
674
675 let (trait_ref, _, _) = super::util::coroutine_trait_ref_and_outputs(
676 self.tcx(),
677 obligation.predicate.def_id(),
678 self_ty,
679 coroutine_sig,
680 );
681
682 let nested = self.equate_trait_refs(
683 obligation.with(self.tcx(), placeholder_predicate),
684 ty::Binder::dummy(trait_ref),
685 )?;
686 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:686",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(686u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"trait_ref", "nested"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("coroutine candidate obligations")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&trait_ref)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&nested) as
&dyn Value))])
});
} else { ; }
};debug!(?trait_ref, ?nested, "coroutine candidate obligations");
687
688 Ok(nested)
689 }
690
691 fn confirm_future_candidate(
692 &mut self,
693 obligation: &PolyTraitObligation<'tcx>,
694 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
695 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
696 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
697 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
698 ::rustc_middle::util::bug::bug_fmt(format_args!("closure candidate for non-closure {0:?}",
obligation));bug!("closure candidate for non-closure {:?}", obligation);
699 };
700
701 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:701",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(701u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"obligation", "coroutine_def_id", "args"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("confirm_future_candidate")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&obligation)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&coroutine_def_id)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&args) as
&dyn Value))])
});
} else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_future_candidate");
702
703 let coroutine_sig = args.as_coroutine().sig();
704
705 let (trait_ref, _) = super::util::future_trait_ref_and_outputs(
706 self.tcx(),
707 obligation.predicate.def_id(),
708 self_ty,
709 coroutine_sig,
710 );
711
712 let nested = self.equate_trait_refs(
713 obligation.with(self.tcx(), placeholder_predicate),
714 ty::Binder::dummy(trait_ref),
715 )?;
716 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:716",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(716u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"trait_ref", "nested"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("future candidate obligations")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&trait_ref)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&nested) as
&dyn Value))])
});
} else { ; }
};debug!(?trait_ref, ?nested, "future candidate obligations");
717
718 Ok(nested)
719 }
720
721 fn confirm_iterator_candidate(
722 &mut self,
723 obligation: &PolyTraitObligation<'tcx>,
724 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
725 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
726 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
727 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
728 ::rustc_middle::util::bug::bug_fmt(format_args!("closure candidate for non-closure {0:?}",
obligation));bug!("closure candidate for non-closure {:?}", obligation);
729 };
730
731 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:731",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(731u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"obligation", "coroutine_def_id", "args"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("confirm_iterator_candidate")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&obligation)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&coroutine_def_id)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&args) as
&dyn Value))])
});
} else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_iterator_candidate");
732
733 let gen_sig = args.as_coroutine().sig();
734
735 let (trait_ref, _) = super::util::iterator_trait_ref_and_outputs(
736 self.tcx(),
737 obligation.predicate.def_id(),
738 self_ty,
739 gen_sig,
740 );
741
742 let nested = self.equate_trait_refs(
743 obligation.with(self.tcx(), placeholder_predicate),
744 ty::Binder::dummy(trait_ref),
745 )?;
746 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:746",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(746u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"trait_ref", "nested"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("iterator candidate obligations")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&trait_ref)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&nested) as
&dyn Value))])
});
} else { ; }
};debug!(?trait_ref, ?nested, "iterator candidate obligations");
747
748 Ok(nested)
749 }
750
751 fn confirm_async_iterator_candidate(
752 &mut self,
753 obligation: &PolyTraitObligation<'tcx>,
754 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
755 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
756 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
757 let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else {
758 ::rustc_middle::util::bug::bug_fmt(format_args!("closure candidate for non-closure {0:?}",
obligation));bug!("closure candidate for non-closure {:?}", obligation);
759 };
760
761 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:761",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(761u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"obligation", "coroutine_def_id", "args"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("confirm_async_iterator_candidate")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&obligation)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&coroutine_def_id)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&args) as
&dyn Value))])
});
} else { ; }
};debug!(?obligation, ?coroutine_def_id, ?args, "confirm_async_iterator_candidate");
762
763 let gen_sig = args.as_coroutine().sig();
764
765 let (trait_ref, _) = super::util::async_iterator_trait_ref_and_outputs(
766 self.tcx(),
767 obligation.predicate.def_id(),
768 self_ty,
769 gen_sig,
770 );
771
772 let nested = self.equate_trait_refs(
773 obligation.with(self.tcx(), placeholder_predicate),
774 ty::Binder::dummy(trait_ref),
775 )?;
776 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:776",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(776u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message",
"trait_ref", "nested"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("iterator candidate obligations")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&trait_ref)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&nested) as
&dyn Value))])
});
} else { ; }
};debug!(?trait_ref, ?nested, "iterator candidate obligations");
777
778 Ok(nested)
779 }
780
781 #[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("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(781u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["obligation"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn 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_middle::util::bug::bug_fmt(format_args!("closure candidate for non-closure {0:?}",
obligation));
}
};
self.equate_trait_refs(obligation.with(self.tcx(),
placeholder_predicate), trait_ref)
}
}
}#[instrument(skip(self), level = "debug")]
782 fn confirm_closure_candidate(
783 &mut self,
784 obligation: &PolyTraitObligation<'tcx>,
785 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
786 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
787 let self_ty: Ty<'_> = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
788
789 let trait_ref = match *self_ty.kind() {
790 ty::Closure(..) => {
791 self.closure_trait_ref_unnormalized(self_ty, obligation.predicate.def_id())
792 }
793 ty::CoroutineClosure(_, args) => {
794 args.as_coroutine_closure().coroutine_closure_sig().map_bound(|sig| {
795 ty::TraitRef::new(
796 self.tcx(),
797 obligation.predicate.def_id(),
798 [self_ty, sig.tupled_inputs_ty],
799 )
800 })
801 }
802 _ => {
803 bug!("closure candidate for non-closure {:?}", obligation);
804 }
805 };
806
807 self.equate_trait_refs(obligation.with(self.tcx(), placeholder_predicate), trait_ref)
808 }
809
810 #[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("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(810u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["obligation"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn 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_middle::util::bug::bug_fmt(format_args!("expected callable type for AsyncFn candidate")),
};
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")]
811 fn confirm_async_closure_candidate(
812 &mut self,
813 obligation: &PolyTraitObligation<'tcx>,
814 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
815 let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
816 let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty());
817
818 let tcx = self.tcx();
819
820 let mut nested = PredicateObligations::new();
821 let (trait_ref, kind_ty) = match *self_ty.kind() {
822 ty::CoroutineClosure(_, args) => {
823 let args = args.as_coroutine_closure();
824 let trait_ref = args.coroutine_closure_sig().map_bound(|sig| {
825 ty::TraitRef::new(
826 self.tcx(),
827 obligation.predicate.def_id(),
828 [self_ty, sig.tupled_inputs_ty],
829 )
830 });
831
832 (trait_ref, args.kind_ty())
836 }
837 ty::FnDef(..) | ty::FnPtr(..) => {
838 let sig = self_ty.fn_sig(tcx);
839 let trait_ref = sig.map_bound(|sig| {
840 ty::TraitRef::new(
841 self.tcx(),
842 obligation.predicate.def_id(),
843 [self_ty, Ty::new_tup(tcx, sig.inputs())],
844 )
845 });
846
847 let future_trait_def_id =
849 tcx.require_lang_item(LangItem::Future, obligation.cause.span);
850 nested.push(obligation.with(
851 tcx,
852 sig.output().map_bound(|output_ty| {
853 ty::TraitRef::new(tcx, future_trait_def_id, [output_ty])
854 }),
855 ));
856 let sized_trait_def_id =
857 tcx.require_lang_item(LangItem::Sized, obligation.cause.span);
858 nested.push(obligation.with(
859 tcx,
860 sig.output().map_bound(|output_ty| {
861 ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
862 }),
863 ));
864
865 (trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn))
866 }
867 ty::Closure(_, args) => {
868 let args = args.as_closure();
869 let sig = args.sig();
870 let trait_ref = sig.map_bound(|sig| {
871 ty::TraitRef::new(
872 self.tcx(),
873 obligation.predicate.def_id(),
874 [self_ty, sig.inputs()[0]],
875 )
876 });
877
878 let future_trait_def_id =
880 tcx.require_lang_item(LangItem::Future, obligation.cause.span);
881 let placeholder_output_ty = self.infcx.enter_forall_and_leak_universe(sig.output());
882 nested.push(obligation.with(
883 tcx,
884 ty::TraitRef::new(tcx, future_trait_def_id, [placeholder_output_ty]),
885 ));
886 let sized_trait_def_id =
887 tcx.require_lang_item(LangItem::Sized, obligation.cause.span);
888 nested.push(obligation.with(
889 tcx,
890 sig.output().map_bound(|output_ty| {
891 ty::TraitRef::new(tcx, sized_trait_def_id, [output_ty])
892 }),
893 ));
894
895 (trait_ref, args.kind_ty())
896 }
897 _ => bug!("expected callable type for AsyncFn candidate"),
898 };
899
900 nested.extend(
901 self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?,
902 );
903
904 let goal_kind =
905 self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap();
906
907 if let Some(closure_kind) = self.infcx.shallow_resolve(kind_ty).to_opt_closure_kind() {
911 if !closure_kind.extends(goal_kind) {
912 return Err(SelectionError::Unimplemented);
913 }
914 } else {
915 nested.push(Obligation::new(
916 self.tcx(),
917 obligation.derived_cause(ObligationCauseCode::BuiltinDerived),
918 obligation.param_env,
919 ty::TraitRef::new(
920 self.tcx(),
921 self.tcx()
922 .require_lang_item(LangItem::AsyncFnKindHelper, obligation.cause.span),
923 [kind_ty, Ty::from_closure_kind(self.tcx(), goal_kind)],
924 ),
925 ));
926 }
927
928 Ok(nested)
929 }
930
931 #[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("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(956u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["obligation",
"found_trait_ref"],
::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};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&found_trait_ref)
as &dyn 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) } =
ensure_sufficient_stack(||
{
normalize_with_depth(self, obligation.param_env,
obligation.cause.clone(), obligation.recursion_depth + 1,
(obligation.predicate.trait_ref, found_trait_ref))
});
self.infcx.at(&obligation.cause,
obligation.param_env).eq(DefineOpaqueTypes::Yes,
obligation_trait_ref,
found_trait_ref).map(|InferOk { mut obligations, .. }|
{
obligations.extend(nested);
obligations
}).map_err(|terr|
{
SelectionError::SignatureMismatch(Box::new(SignatureMismatchData {
expected_trait_ref: obligation_trait_ref,
found_trait_ref,
terr,
}))
})
}
}
}#[instrument(skip(self), level = "trace")]
957 fn equate_trait_refs(
958 &mut self,
959 obligation: TraitObligation<'tcx>,
960 found_trait_ref: ty::PolyTraitRef<'tcx>,
961 ) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
962 let found_trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
963 obligation.cause.span,
964 BoundRegionConversionTime::HigherRankedType,
965 found_trait_ref,
966 );
967 let Normalized { obligations: nested, value: (obligation_trait_ref, found_trait_ref) } =
969 ensure_sufficient_stack(|| {
970 normalize_with_depth(
971 self,
972 obligation.param_env,
973 obligation.cause.clone(),
974 obligation.recursion_depth + 1,
975 (obligation.predicate.trait_ref, found_trait_ref),
976 )
977 });
978
979 self.infcx
981 .at(&obligation.cause, obligation.param_env)
982 .eq(DefineOpaqueTypes::Yes, obligation_trait_ref, found_trait_ref)
983 .map(|InferOk { mut obligations, .. }| {
984 obligations.extend(nested);
985 obligations
986 })
987 .map_err(|terr| {
988 SelectionError::SignatureMismatch(Box::new(SignatureMismatchData {
989 expected_trait_ref: obligation_trait_ref,
990 found_trait_ref,
991 terr,
992 }))
993 })
994 }
995
996 fn confirm_trait_upcasting_unsize_candidate(
997 &mut self,
998 obligation: &PolyTraitObligation<'tcx>,
999 idx: usize,
1000 ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
1001 let tcx = self.tcx();
1002
1003 let predicate = obligation.predicate.no_bound_vars().unwrap();
1006 let a_ty = self.infcx.shallow_resolve(predicate.self_ty());
1007 let b_ty = self.infcx.shallow_resolve(predicate.trait_ref.args.type_at(1));
1008
1009 let ty::Dynamic(a_data, a_region) = *a_ty.kind() else {
1010 ::rustc_middle::util::bug::bug_fmt(format_args!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`"))bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
1011 };
1012 let ty::Dynamic(b_data, b_region) = *b_ty.kind() else {
1013 ::rustc_middle::util::bug::bug_fmt(format_args!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`"))bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
1014 };
1015
1016 let source_principal = a_data.principal().unwrap().with_self_ty(tcx, a_ty);
1017 let unnormalized_upcast_principal =
1018 util::supertraits(tcx, source_principal).nth(idx).unwrap();
1019
1020 let nested = self
1021 .match_upcast_principal(
1022 obligation,
1023 unnormalized_upcast_principal,
1024 a_data,
1025 b_data,
1026 a_region,
1027 b_region,
1028 )?
1029 .expect("did not expect ambiguity during confirmation");
1030
1031 Ok(ImplSource::Builtin(BuiltinImplSource::TraitUpcasting(idx), nested))
1032 }
1033
1034 fn confirm_builtin_unsize_candidate(
1035 &mut self,
1036 obligation: &PolyTraitObligation<'tcx>,
1037 ) -> Result<ImplSource<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
1038 let tcx = self.tcx();
1039
1040 let source = self.infcx.shallow_resolve(obligation.self_ty().no_bound_vars().unwrap());
1043 let target = obligation.predicate.skip_binder().trait_ref.args.type_at(1);
1044 let target = self.infcx.shallow_resolve(target);
1045 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/traits/select/confirmation.rs:1045",
"rustc_trait_selection::traits::select::confirmation",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/traits/select/confirmation.rs"),
::tracing_core::__macro_support::Option::Some(1045u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select::confirmation"),
::tracing_core::field::FieldSet::new(&["message", "source",
"target"],
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("confirm_builtin_unsize_candidate")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&source) as
&dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&target) as
&dyn Value))])
});
} else { ; }
};debug!(?source, ?target, "confirm_builtin_unsize_candidate");
1046
1047 Ok(match (source.kind(), target.kind()) {
1048 (&ty::Dynamic(data_a, r_a), &ty::Dynamic(data_b, r_b)) => {
1050 let existential_predicates = if data_b.principal().is_some() {
1053 tcx.mk_poly_existential_predicates_from_iter(
1054 data_a
1055 .principal()
1056 .map(|b| b.map_bound(ty::ExistentialPredicate::Trait))
1057 .into_iter()
1058 .chain(
1059 data_a
1060 .projection_bounds()
1061 .map(|b| b.map_bound(ty::ExistentialPredicate::Projection)),
1062 )
1063 .chain(
1064 data_b
1065 .auto_traits()
1066 .map(ty::ExistentialPredicate::AutoTrait)
1067 .map(ty::Binder::dummy),
1068 ),
1069 )
1070 } else {
1071 tcx.mk_poly_existential_predicates_from_iter(
1076 data_b
1077 .auto_traits()
1078 .map(ty::ExistentialPredicate::AutoTrait)
1079 .map(ty::Binder::dummy),
1080 )
1081 };
1082 let source_trait = Ty::new_dynamic(tcx, existential_predicates, r_b);
1083
1084 let InferOk { mut obligations, .. } = self
1087 .infcx
1088 .at(&obligation.cause, obligation.param_env)
1089 .sup(DefineOpaqueTypes::Yes, target, source_trait)
1090 .map_err(|_| SelectionError::Unimplemented)?;
1091
1092 let outlives = ty::OutlivesPredicate(r_a, r_b);
1094 obligations.push(Obligation::with_depth(
1095 tcx,
1096 obligation.cause.clone(),
1097 obligation.recursion_depth + 1,
1098 obligation.param_env,
1099 obligation.predicate.rebind(outlives),
1100 ));
1101
1102 ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1103 }
1104
1105 (_, &ty::Dynamic(data, r)) => {
1107 let mut object_dids = data.auto_traits().chain(data.principal_def_id());
1108 if let Some(did) = object_dids.find(|did| !tcx.is_dyn_compatible(*did)) {
1109 return Err(SelectionError::TraitDynIncompatible(did));
1110 }
1111
1112 let predicate_to_obligation = |predicate| {
1113 Obligation::with_depth(
1114 tcx,
1115 obligation.cause.clone(),
1116 obligation.recursion_depth + 1,
1117 obligation.param_env,
1118 predicate,
1119 )
1120 };
1121
1122 let mut nested: PredicateObligations<'_> = data
1129 .iter()
1130 .map(|predicate| predicate_to_obligation(predicate.with_self_ty(tcx, source)))
1131 .collect();
1132
1133 let tr = ty::TraitRef::new(
1135 tcx,
1136 tcx.require_lang_item(LangItem::Sized, obligation.cause.span),
1137 [source],
1138 );
1139 nested.push(predicate_to_obligation(tr.upcast(tcx)));
1140
1141 let outlives = ty::OutlivesPredicate(source, r);
1144 nested.push(predicate_to_obligation(
1145 ty::ClauseKind::TypeOutlives(outlives).upcast(tcx),
1146 ));
1147
1148 ImplSource::Builtin(BuiltinImplSource::Misc, nested)
1149 }
1150
1151 (&ty::Array(a, _), &ty::Slice(b)) => {
1153 let InferOk { obligations, .. } = self
1154 .infcx
1155 .at(&obligation.cause, obligation.param_env)
1156 .eq(DefineOpaqueTypes::Yes, b, a)
1157 .map_err(|_| SelectionError::Unimplemented)?;
1158
1159 ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1160 }
1161
1162 (&ty::Adt(def, args_a), &ty::Adt(_, args_b)) => {
1164 let unsizing_params = tcx.unsizing_params_for_adt(def.did());
1165 if unsizing_params.is_empty() {
1166 return Err(SelectionError::Unimplemented);
1167 }
1168
1169 let tail_field = def.non_enum_variant().tail();
1170 let tail_field_ty = tcx.type_of(tail_field.did);
1171
1172 let mut nested = PredicateObligations::new();
1173
1174 let source_tail = normalize_with_depth_to(
1178 self,
1179 obligation.param_env,
1180 obligation.cause.clone(),
1181 obligation.recursion_depth + 1,
1182 tail_field_ty.instantiate(tcx, args_a),
1183 &mut nested,
1184 );
1185 let target_tail = normalize_with_depth_to(
1186 self,
1187 obligation.param_env,
1188 obligation.cause.clone(),
1189 obligation.recursion_depth + 1,
1190 tail_field_ty.instantiate(tcx, args_b),
1191 &mut nested,
1192 );
1193
1194 let args =
1197 tcx.mk_args_from_iter(args_a.iter().enumerate().map(|(i, k)| {
1198 if unsizing_params.contains(i as u32) { args_b[i] } else { k }
1199 }));
1200 let new_struct = Ty::new_adt(tcx, def, args);
1201 let InferOk { obligations, .. } = self
1202 .infcx
1203 .at(&obligation.cause, obligation.param_env)
1204 .eq(DefineOpaqueTypes::Yes, target, new_struct)
1205 .map_err(|_| SelectionError::Unimplemented)?;
1206 nested.extend(obligations);
1207
1208 let tail_unsize_obligation = obligation.with(
1210 tcx,
1211 ty::TraitRef::new(
1212 tcx,
1213 obligation.predicate.def_id(),
1214 [source_tail, target_tail],
1215 ),
1216 );
1217 nested.push(tail_unsize_obligation);
1218
1219 ImplSource::Builtin(BuiltinImplSource::Misc, nested)
1220 }
1221
1222 _ => ::rustc_middle::util::bug::bug_fmt(format_args!("source: {0}, target: {1}",
source, target))bug!("source: {source}, target: {target}"),
1223 })
1224 }
1225
1226 fn confirm_bikeshed_guaranteed_no_drop_candidate(
1229 &mut self,
1230 obligation: &PolyTraitObligation<'tcx>,
1231 ) -> ImplSource<'tcx, PredicateObligation<'tcx>> {
1232 let mut obligations = ::thin_vec::ThinVec::new()thin_vec![];
1233
1234 let tcx = self.tcx();
1235 let self_ty = obligation.predicate.self_ty();
1236 match *self_ty.skip_binder().kind() {
1237 ty::Ref(..) => {}
1239 ty::Adt(def, _) if def.is_manually_drop() => {}
1241 ty::Tuple(tys) => {
1244 obligations.extend(tys.iter().map(|elem_ty| {
1245 obligation.with(
1246 tcx,
1247 self_ty.rebind(ty::TraitRef::new(
1248 tcx,
1249 obligation.predicate.def_id(),
1250 [elem_ty],
1251 )),
1252 )
1253 }));
1254 }
1255 ty::Array(elem_ty, _) => {
1256 obligations.push(obligation.with(
1257 tcx,
1258 self_ty.rebind(ty::TraitRef::new(
1259 tcx,
1260 obligation.predicate.def_id(),
1261 [elem_ty],
1262 )),
1263 ));
1264 }
1265
1266 ty::FnDef(..)
1270 | ty::FnPtr(..)
1271 | ty::Error(_)
1272 | ty::Uint(_)
1273 | ty::Int(_)
1274 | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
1275 | ty::Bool
1276 | ty::Float(_)
1277 | ty::Char
1278 | ty::RawPtr(..)
1279 | ty::Never
1280 | ty::Pat(..)
1281 | ty::Dynamic(..)
1282 | ty::Str
1283 | ty::Slice(_)
1284 | ty::Foreign(..)
1285 | ty::Adt(..)
1286 | ty::Alias(..)
1287 | ty::Param(_)
1288 | ty::Placeholder(..)
1289 | ty::Closure(..)
1290 | ty::CoroutineClosure(..)
1291 | ty::Coroutine(..)
1292 | ty::UnsafeBinder(_)
1293 | ty::CoroutineWitness(..)
1294 | ty::Bound(..) => {
1295 obligations.push(obligation.with(
1296 tcx,
1297 self_ty.map_bound(|ty| {
1298 ty::TraitRef::new(
1299 tcx,
1300 tcx.require_lang_item(LangItem::Copy, obligation.cause.span),
1301 [ty],
1302 )
1303 }),
1304 ));
1305 }
1306
1307 ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
1308 {
::core::panicking::panic_fmt(format_args!("unexpected type `{0:?}`",
self_ty));
}panic!("unexpected type `{self_ty:?}`")
1309 }
1310 }
1311
1312 ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
1313 }
1314}