1use std::cell::{Cell, RefCell};
6use std::cmp;
7use std::fmt::{self, Display};
8use std::ops::ControlFlow;
9
10use hir::def::DefKind;
11use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
12use rustc_errors::{Diag, EmissionGuarantee};
13use rustc_hir as hir;
14use rustc_hir::attrs::lang_items::LangItem;
15use rustc_hir::def_id::DefId;
16use rustc_infer::infer::BoundRegionConversionTime::{self, HigherRankedType};
17use rustc_infer::infer::DefineOpaqueTypes;
18use rustc_infer::infer::at::ToTrace;
19use rustc_infer::infer::relate::TypeRelation;
20use rustc_infer::traits::{ImplSource, PredicateObligations, TraitObligation};
21use rustc_macros::{TypeFoldable, TypeVisitable};
22use rustc_middle::bug;
23use rustc_middle::dep_graph::{DepKind, DepNodeIndex};
24pub use rustc_middle::traits::select::*;
25use rustc_middle::ty::abstract_const::NotConstEvaluatable;
26use rustc_middle::ty::error::TypeErrorToStringExt;
27use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths};
28use rustc_middle::ty::{
29 self, CandidatePreferenceMode, CantBeErased, DeepRejectCtxt, GenericArgsRef,
30 PolyProjectionClause, SizedTraitKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, TypingMode,
31 Unnormalized, Upcast, elaborate, may_use_unstable_feature,
32};
33use rustc_next_trait_solver::solve::AliasBoundKind;
34use tracing::{debug, instrument, trace};
35
36use self::EvaluationResult::*;
37use self::SelectionCandidate::*;
38use super::coherence::{self, Conflict};
39use super::project::ProjectionTermObligation;
40use super::util::closure_trait_ref_and_return_type;
41use super::{
42 ImplDerivedCause, Normalized, Obligation, ObligationCause, ObligationCauseCode,
43 PolyTraitObligation, PredicateObligation, Selection, SelectionError, SelectionResult,
44 TraitQueryMode, const_evaluatable, project, util, wf,
45};
46use crate::error_reporting::InferCtxtErrorExt;
47use crate::infer::{InferCtxt, InferOk, TypeFreshener};
48use crate::solve::InferCtxtSelectExt as _;
49use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to};
50use crate::traits::project::{ProjectAndUnifyResult, ProjectionCacheKeyExt};
51use crate::traits::{EvaluateConstErr, ProjectionCacheKey, effects, sizedness_fast_path};
52
53mod _match;
54mod candidate_assembly;
55mod confirmation;
56
57#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for IntercrateAmbiguityCause<'tcx> {
#[inline]
fn clone(&self) -> IntercrateAmbiguityCause<'tcx> {
match self {
IntercrateAmbiguityCause::DownstreamCrate {
trait_ref: __self_0, self_ty: __self_1 } =>
IntercrateAmbiguityCause::DownstreamCrate {
trait_ref: ::core::clone::Clone::clone(__self_0),
self_ty: ::core::clone::Clone::clone(__self_1),
},
IntercrateAmbiguityCause::UpstreamCrateUpdate {
trait_ref: __self_0, self_ty: __self_1 } =>
IntercrateAmbiguityCause::UpstreamCrateUpdate {
trait_ref: ::core::clone::Clone::clone(__self_0),
self_ty: ::core::clone::Clone::clone(__self_1),
},
}
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for IntercrateAmbiguityCause<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
IntercrateAmbiguityCause::DownstreamCrate {
trait_ref: __self_0, self_ty: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DownstreamCrate", "trait_ref", __self_0, "self_ty",
&__self_1),
IntercrateAmbiguityCause::UpstreamCrateUpdate {
trait_ref: __self_0, self_ty: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"UpstreamCrateUpdate", "trait_ref", __self_0, "self_ty",
&__self_1),
}
}
}Debug, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for IntercrateAmbiguityCause<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<ty::TraitRef<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<Option<Ty<'tcx>>>;
let _: ::core::cmp::AssertParamIsEq<ty::TraitRef<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<Option<Ty<'tcx>>>;
}
}Eq, #[automatically_derived]
impl<'tcx> ::core::marker::StructuralPartialEq for
IntercrateAmbiguityCause<'tcx> {
}
#[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for IntercrateAmbiguityCause<'tcx> {
#[inline]
fn eq(&self, other: &IntercrateAmbiguityCause<'tcx>) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(IntercrateAmbiguityCause::DownstreamCrate {
trait_ref: __self_0, self_ty: __self_1 },
IntercrateAmbiguityCause::DownstreamCrate {
trait_ref: __arg1_0, self_ty: __arg1_1 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(IntercrateAmbiguityCause::UpstreamCrateUpdate {
trait_ref: __self_0, self_ty: __self_1 },
IntercrateAmbiguityCause::UpstreamCrateUpdate {
trait_ref: __arg1_0, self_ty: __arg1_1 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::hash::Hash for IntercrateAmbiguityCause<'tcx> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
IntercrateAmbiguityCause::DownstreamCrate {
trait_ref: __self_0, self_ty: __self_1 } => {
::core::hash::Hash::hash(__self_0, state);
::core::hash::Hash::hash(__self_1, state)
}
IntercrateAmbiguityCause::UpstreamCrateUpdate {
trait_ref: __self_0, self_ty: __self_1 } => {
::core::hash::Hash::hash(__self_0, state);
::core::hash::Hash::hash(__self_1, state)
}
}
}
}Hash)]
58pub enum IntercrateAmbiguityCause<'tcx> {
59 DownstreamCrate { trait_ref: ty::TraitRef<'tcx>, self_ty: Option<Ty<'tcx>> },
60 UpstreamCrateUpdate { trait_ref: ty::TraitRef<'tcx>, self_ty: Option<Ty<'tcx>> },
61}
62
63impl<'tcx> IntercrateAmbiguityCause<'tcx> {
64 pub fn add_intercrate_ambiguity_hint<G: EmissionGuarantee>(&self, err: &mut Diag<'_, G>) {
67 err.note(self.intercrate_ambiguity_hint());
68 }
69
70 pub fn intercrate_ambiguity_hint(&self) -> String {
71 {
let _guard = NoTrimmedGuard::new();
match self {
IntercrateAmbiguityCause::DownstreamCrate { trait_ref, self_ty } => {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("downstream crates may implement trait `{0}`{1}",
trait_ref.print_trait_sugared(),
if let Some(self_ty) = self_ty {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" for type `{0}`",
self_ty))
})
} else { String::new() }))
})
}
IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_ref, self_ty }
=> {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("upstream crates may add a new impl of trait `{0}`{1} in future versions",
trait_ref.print_trait_sugared(),
if let Some(self_ty) = self_ty {
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(" for type `{0}`",
self_ty))
})
} else { String::new() }))
})
}
}
}with_no_trimmed_paths!(match self {
72 IntercrateAmbiguityCause::DownstreamCrate { trait_ref, self_ty } => {
73 format!(
74 "downstream crates may implement trait `{trait_desc}`{self_desc}",
75 trait_desc = trait_ref.print_trait_sugared(),
76 self_desc = if let Some(self_ty) = self_ty {
77 format!(" for type `{self_ty}`")
78 } else {
79 String::new()
80 }
81 )
82 }
83 IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_ref, self_ty } => {
84 format!(
85 "upstream crates may add a new impl of trait `{trait_desc}`{self_desc} \
86 in future versions",
87 trait_desc = trait_ref.print_trait_sugared(),
88 self_desc = if let Some(self_ty) = self_ty {
89 format!(" for type `{self_ty}`")
90 } else {
91 String::new()
92 }
93 )
94 }
95 })
96 }
97}
98
99pub struct SelectionContext<'cx, 'tcx> {
100 pub infcx: &'cx InferCtxt<'tcx>,
101
102 freshener: TypeFreshener<'cx, 'tcx>,
108
109 intercrate_ambiguity_causes: Option<FxIndexSet<IntercrateAmbiguityCause<'tcx>>>,
116
117 query_mode: TraitQueryMode,
121}
122
123struct TraitObligationStack<'prev, 'tcx> {
125 obligation: &'prev PolyTraitObligation<'tcx>,
126
127 fresh_trait_pred: ty::PolyTraitClause<'tcx>,
130
131 reached_depth: Cell<usize>,
160
161 previous: TraitObligationStackList<'prev, 'tcx>,
162
163 depth: usize,
165
166 dfn: usize,
169}
170
171struct SelectionCandidateSet<'tcx> {
172 vec: Vec<SelectionCandidate<'tcx>>,
175
176 ambiguous: bool,
181}
182
183#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::StructuralPartialEq for EvaluatedCandidate<'tcx> {
}
#[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for EvaluatedCandidate<'tcx> {
#[inline]
fn eq(&self, other: &EvaluatedCandidate<'tcx>) -> bool {
self.candidate == other.candidate &&
self.evaluation == other.evaluation
}
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for EvaluatedCandidate<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<SelectionCandidate<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<EvaluationResult>;
}
}Eq, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for EvaluatedCandidate<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"EvaluatedCandidate", "candidate", &self.candidate, "evaluation",
&&self.evaluation)
}
}Debug, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for EvaluatedCandidate<'tcx> {
#[inline]
fn clone(&self) -> EvaluatedCandidate<'tcx> {
EvaluatedCandidate {
candidate: ::core::clone::Clone::clone(&self.candidate),
evaluation: ::core::clone::Clone::clone(&self.evaluation),
}
}
}Clone)]
184struct EvaluatedCandidate<'tcx> {
185 candidate: SelectionCandidate<'tcx>,
186 evaluation: EvaluationResult,
187}
188
189impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
190 pub fn new(infcx: &'cx InferCtxt<'tcx>) -> SelectionContext<'cx, 'tcx> {
191 SelectionContext {
192 infcx,
193 freshener: TypeFreshener::new(infcx),
194 intercrate_ambiguity_causes: None,
195 query_mode: TraitQueryMode::Standard,
196 }
197 }
198
199 pub fn typing_mode(&self) -> TypingMode<'tcx, CantBeErased> {
200 self.infcx.typing_mode_raw().assert_not_erased()
201 }
202
203 pub fn with_query_mode(
204 infcx: &'cx InferCtxt<'tcx>,
205 query_mode: TraitQueryMode,
206 ) -> SelectionContext<'cx, 'tcx> {
207 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:207",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(207u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("query_mode")
}> =
::tracing::__macro_support::FieldName::new("query_mode");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("with_query_mode")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&query_mode)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?query_mode, "with_query_mode");
208 SelectionContext { query_mode, ..SelectionContext::new(infcx) }
209 }
210
211 pub fn enable_tracking_intercrate_ambiguity_causes(&mut self) {
214 if !self.typing_mode().is_coherence() {
::core::panicking::panic("assertion failed: self.typing_mode().is_coherence()")
};assert!(self.typing_mode().is_coherence());
215 if !self.intercrate_ambiguity_causes.is_none() {
::core::panicking::panic("assertion failed: self.intercrate_ambiguity_causes.is_none()")
};assert!(self.intercrate_ambiguity_causes.is_none());
216
217 self.intercrate_ambiguity_causes = Some(FxIndexSet::default());
218 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:218",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(218u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("selcx: enable_tracking_intercrate_ambiguity_causes")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("selcx: enable_tracking_intercrate_ambiguity_causes");
219 }
220
221 pub fn take_intercrate_ambiguity_causes(
225 &mut self,
226 ) -> FxIndexSet<IntercrateAmbiguityCause<'tcx>> {
227 if !self.typing_mode().is_coherence() {
::core::panicking::panic("assertion failed: self.typing_mode().is_coherence()")
};assert!(self.typing_mode().is_coherence());
228
229 self.intercrate_ambiguity_causes.take().unwrap_or_default()
230 }
231
232 pub fn tcx(&self) -> TyCtxt<'tcx> {
233 self.infcx.tcx
234 }
235
236 {}
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("poly_select",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(253u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
SelectionResult<'tcx, Selection<'tcx>> = loop {};
return __tracing_attr_fake_return;
}
{
if self.infcx.next_trait_solver() {
return self.infcx.select_in_new_trait_solver(obligation);
}
let candidate =
match self.select_from_obligation(obligation) {
Err(SelectionError::Overflow(OverflowError::Canonical)) => {
if !(self.query_mode == TraitQueryMode::Canonical) {
::core::panicking::panic("assertion failed: self.query_mode == TraitQueryMode::Canonical")
};
return Err(SelectionError::Overflow(OverflowError::Canonical));
}
Err(e) => { return Err(e); }
Ok(None) => { return Ok(None); }
Ok(Some(candidate)) => candidate,
};
match self.confirm_candidate(obligation, candidate) {
Err(SelectionError::Overflow(OverflowError::Canonical)) => {
if !(self.query_mode == TraitQueryMode::Canonical) {
::core::panicking::panic("assertion failed: self.query_mode == TraitQueryMode::Canonical")
};
Err(SelectionError::Overflow(OverflowError::Canonical))
}
Err(e) => Err(e),
Ok(ImplSource::Builtin(..)) if
self.typing_mode().is_reflection() => {
Err(SelectionError::Unimplemented)
}
Ok(candidate) => Ok(Some(candidate)),
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:253",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(253u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
254 pub fn poly_select(
255 &mut self,
256 obligation: &PolyTraitObligation<'tcx>,
257 ) -> SelectionResult<'tcx, Selection<'tcx>> {
258 if self.infcx.next_trait_solver() {
259 return self.infcx.select_in_new_trait_solver(obligation);
260 }
261
262 let candidate = match self.select_from_obligation(obligation) {
263 Err(SelectionError::Overflow(OverflowError::Canonical)) => {
264 assert!(self.query_mode == TraitQueryMode::Canonical);
267 return Err(SelectionError::Overflow(OverflowError::Canonical));
268 }
269 Err(e) => {
270 return Err(e);
271 }
272 Ok(None) => {
273 return Ok(None);
274 }
275 Ok(Some(candidate)) => candidate,
276 };
277
278 match self.confirm_candidate(obligation, candidate) {
279 Err(SelectionError::Overflow(OverflowError::Canonical)) => {
280 assert!(self.query_mode == TraitQueryMode::Canonical);
281 Err(SelectionError::Overflow(OverflowError::Canonical))
282 }
283 Err(e) => Err(e),
284 Ok(ImplSource::Builtin(..)) if self.typing_mode().is_reflection() => {
285 Err(SelectionError::Unimplemented)
288 }
289 Ok(candidate) => Ok(Some(candidate)),
290 }
291 }
292
293 pub fn select(
294 &mut self,
295 obligation: &TraitObligation<'tcx>,
296 ) -> SelectionResult<'tcx, Selection<'tcx>> {
297 self.poly_select(&Obligation {
298 cause: obligation.cause.clone(),
299 param_env: obligation.param_env,
300 predicate: ty::Binder::dummy(obligation.predicate),
301 recursion_depth: obligation.recursion_depth,
302 })
303 }
304
305 fn select_from_obligation(
306 &mut self,
307 obligation: &PolyTraitObligation<'tcx>,
308 ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
309 if true {
if !!obligation.predicate.has_escaping_bound_vars() {
::core::panicking::panic("assertion failed: !obligation.predicate.has_escaping_bound_vars()")
};
};debug_assert!(!obligation.predicate.has_escaping_bound_vars());
310
311 let pec = &ProvisionalEvaluationCache::default();
312 let stack = self.push_stack(TraitObligationStackList::empty(pec), obligation);
313
314 self.candidate_from_obligation(&stack)
315 }
316
317 {}
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("candidate_from_obligation",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(317u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("stack")
}> =
::tracing::__macro_support::FieldName::new("stack");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&stack)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
SelectionResult<'tcx, SelectionCandidate<'tcx>> = loop {};
return __tracing_attr_fake_return;
}
{
if true {
if !!self.infcx.next_trait_solver() {
::core::panicking::panic("assertion failed: !self.infcx.next_trait_solver()")
};
};
self.check_recursion_limit(stack.obligation,
stack.obligation)?;
let cache_fresh_trait_pred =
stack.obligation.predicate.fold_with(&mut TypeFreshener::new(self.infcx));
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:333",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(333u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("cache_fresh_trait_pred")
}> =
::tracing::__macro_support::FieldName::new("cache_fresh_trait_pred");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&cache_fresh_trait_pred)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
if true {
if !!stack.obligation.predicate.has_escaping_bound_vars() {
::core::panicking::panic("assertion failed: !stack.obligation.predicate.has_escaping_bound_vars()")
};
};
if let Some(c) =
self.check_candidate_cache(stack.obligation.param_env,
cache_fresh_trait_pred) {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:339",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(339u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("CACHE HIT")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
return c;
}
let (candidate, dep_node) =
self.in_task(|this|
this.candidate_from_obligation_no_cache(stack));
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:352",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(352u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("CACHE MISS")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.insert_candidate_cache(stack.obligation.param_env,
cache_fresh_trait_pred, dep_node, candidate.clone());
candidate
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:317",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(317u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
318 fn candidate_from_obligation<'o>(
319 &mut self,
320 stack: &TraitObligationStack<'o, 'tcx>,
321 ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
322 debug_assert!(!self.infcx.next_trait_solver());
323 self.check_recursion_limit(stack.obligation, stack.obligation)?;
326
327 let cache_fresh_trait_pred =
332 stack.obligation.predicate.fold_with(&mut TypeFreshener::new(self.infcx));
333 debug!(?cache_fresh_trait_pred);
334 debug_assert!(!stack.obligation.predicate.has_escaping_bound_vars());
335
336 if let Some(c) =
337 self.check_candidate_cache(stack.obligation.param_env, cache_fresh_trait_pred)
338 {
339 debug!("CACHE HIT");
340 return c;
341 }
342
343 let (candidate, dep_node) =
350 self.in_task(|this| this.candidate_from_obligation_no_cache(stack));
351
352 debug!("CACHE MISS");
353 self.insert_candidate_cache(
354 stack.obligation.param_env,
355 cache_fresh_trait_pred,
356 dep_node,
357 candidate.clone(),
358 );
359 candidate
360 }
361
362 fn candidate_from_obligation_no_cache<'o>(
363 &mut self,
364 stack: &TraitObligationStack<'o, 'tcx>,
365 ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
366 if let Err(conflict) = self.is_knowable(stack) {
367 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:367",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(367u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("coherence stage: not knowable")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("coherence stage: not knowable");
368 if self.intercrate_ambiguity_causes.is_some() {
369 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:369",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(369u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("evaluate_stack: intercrate_ambiguity_causes is some")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("evaluate_stack: intercrate_ambiguity_causes is some");
370 if let Ok(candidate_set) = self.assemble_candidates(stack) {
372 let mut no_candidates_apply = true;
373
374 for c in candidate_set.vec.iter() {
375 if self.evaluate_candidate(stack, c)?.may_apply() {
376 no_candidates_apply = false;
377 break;
378 }
379 }
380
381 if !candidate_set.ambiguous && no_candidates_apply {
382 let trait_ref = self.infcx.deeply_resolve_ignoring_regions(
383 stack.obligation.predicate.skip_binder().trait_ref,
384 );
385 if !trait_ref.references_error() {
386 let self_ty = trait_ref.self_ty();
387 let self_ty = self_ty.has_concrete_skeleton().then(|| self_ty);
388 let cause = if let Conflict::Upstream = conflict {
389 IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_ref, self_ty }
390 } else {
391 IntercrateAmbiguityCause::DownstreamCrate { trait_ref, self_ty }
392 };
393 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:393",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(393u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("cause")
}> =
::tracing::__macro_support::FieldName::new("cause");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("evaluate_stack: pushing cause")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&cause)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?cause, "evaluate_stack: pushing cause");
394 self.intercrate_ambiguity_causes.as_mut().unwrap().insert(cause);
395 }
396 }
397 }
398 }
399 return Ok(None);
400 }
401
402 let candidate_set = self.assemble_candidates(stack)?;
403
404 if candidate_set.ambiguous {
405 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:405",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(405u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("candidate set contains ambig")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("candidate set contains ambig");
406 return Ok(None);
407 }
408
409 let candidates = candidate_set.vec;
410
411 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:411",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(411u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("stack")
}> =
::tracing::__macro_support::FieldName::new("stack");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidates")
}> =
::tracing::__macro_support::FieldName::new("candidates");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("assembled {0} candidates",
candidates.len()) as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&stack)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidates)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?stack, ?candidates, "assembled {} candidates", candidates.len());
412
413 let mut candidates = self.filter_impls(candidates, stack.obligation);
423
424 if candidates.len() == 1 {
439 return Ok(candidates.pop());
440 }
441
442 let candidates = candidates
445 .into_iter()
446 .map(|c| match self.evaluate_candidate(stack, &c) {
447 Ok(eval) if eval.may_apply() => {
448 Ok(Some(EvaluatedCandidate { candidate: c, evaluation: eval }))
449 }
450 Ok(_) => Ok(None),
451 Err(OverflowError::Canonical) => {
452 Err(SelectionError::Overflow(OverflowError::Canonical))
453 }
454 Err(OverflowError::Error(e)) => {
455 Err(SelectionError::Overflow(OverflowError::Error(e)))
456 }
457 })
458 .flat_map(Result::transpose)
459 .collect::<Result<Vec<_>, _>>()?;
460
461 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:461",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(461u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("stack")
}> =
::tracing::__macro_support::FieldName::new("stack");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidates")
}> =
::tracing::__macro_support::FieldName::new("candidates");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("{0} potentially applicable candidates",
candidates.len()) as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&stack)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidates)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?stack, ?candidates, "{} potentially applicable candidates", candidates.len());
462 if candidates.is_empty() {
472 if stack.obligation.predicate.references_error() {
477 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:477",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(477u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("stack.obligation.predicate")
}> =
::tracing::__macro_support::FieldName::new("stack.obligation.predicate");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("found error type in predicate, treating as ambiguous")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&stack.obligation.predicate)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?stack.obligation.predicate, "found error type in predicate, treating as ambiguous");
478 Ok(None)
479 } else {
480 Err(SelectionError::Unimplemented)
481 }
482 } else {
483 let has_non_region_infer = stack.obligation.predicate.has_non_region_infer();
484 let candidate_preference_mode =
485 CandidatePreferenceMode::compute(self.tcx(), stack.obligation.predicate.def_id());
486 Ok(self.winnow_candidates(has_non_region_infer, candidate_preference_mode, candidates))
487 }
488 }
489
490 pub fn evaluate_root_obligation(
506 &mut self,
507 obligation: &PredicateObligation<'tcx>,
508 ) -> Result<EvaluationResult, OverflowError> {
509 if true {
if !!self.infcx.next_trait_solver() {
::core::panicking::panic("assertion failed: !self.infcx.next_trait_solver()")
};
};debug_assert!(!self.infcx.next_trait_solver());
510 self.evaluation_probe(|this| {
511 let goal = this
512 .infcx
513 .deeply_resolve_ignoring_regions((obligation.predicate, obligation.param_env));
514 let mut result = this.evaluate_predicate_recursively(
515 TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
516 obligation.clone(),
517 )?;
518 if this.infcx.deeply_resolve_ignoring_regions(goal) != goal {
521 result = result.max(EvaluatedToAmbig);
522 }
523 Ok(result)
524 })
525 }
526
527 fn evaluation_probe(
533 &mut self,
534 op: impl FnOnce(&mut Self) -> Result<EvaluationResult, OverflowError>,
535 ) -> Result<EvaluationResult, OverflowError> {
536 self.infcx.probe(|snapshot| -> Result<EvaluationResult, OverflowError> {
537 let outer_universe = self.infcx.universe();
538 let result = op(self)?;
539
540 match self.infcx.leak_check(outer_universe, Some(snapshot)) {
541 Ok(()) => {}
542 Err(_) => return Ok(EvaluatedToErr),
543 }
544
545 if self.infcx.opaque_types_added_in_snapshot(snapshot) {
546 return Ok(result.max(EvaluatedToOkModuloOpaqueTypes));
547 }
548
549 if self.infcx.region_constraints_added_in_snapshot(snapshot) {
550 Ok(result.max(EvaluatedToOkModuloRegions))
551 } else {
552 Ok(result)
553 }
554 })
555 }
556
557 {}
#[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("evaluate_predicates_recursively",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(561u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("predicates")
}> =
::tracing::__macro_support::FieldName::new("predicates");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&predicates)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<EvaluationResult, OverflowError> = loop {};
return __tracing_attr_fake_return;
}
{
let mut result = EvaluatedToOk;
for mut obligation in predicates {
obligation.set_depth_from_parent(stack.depth());
let eval =
self.evaluate_predicate_recursively(stack,
obligation.clone())?;
if let EvaluatedToErr = eval {
return Ok(EvaluatedToErr);
} else { result = cmp::max(result, eval); }
}
Ok(result)
}
}
}#[instrument(skip(self, stack), level = "debug")]
562 fn evaluate_predicates_recursively<'o, I>(
563 &mut self,
564 stack: TraitObligationStackList<'o, 'tcx>,
565 predicates: I,
566 ) -> Result<EvaluationResult, OverflowError>
567 where
568 I: IntoIterator<Item = PredicateObligation<'tcx>> + std::fmt::Debug,
569 {
570 let mut result = EvaluatedToOk;
571 for mut obligation in predicates {
572 obligation.set_depth_from_parent(stack.depth());
573 let eval = self.evaluate_predicate_recursively(stack, obligation.clone())?;
574 if let EvaluatedToErr = eval {
575 return Ok(EvaluatedToErr);
578 } else {
579 result = cmp::max(result, eval);
580 }
581 }
582 Ok(result)
583 }
584
585 {}
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("evaluate_predicate_recursively",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(585u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("previous_stack")
}> =
::tracing::__macro_support::FieldName::new("previous_stack");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&previous_stack.head())
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<EvaluationResult, OverflowError> = loop {};
return __tracing_attr_fake_return;
}
{
if true {
if !!self.infcx.next_trait_solver() {
::core::panicking::panic("assertion failed: !self.infcx.next_trait_solver()")
};
};
match previous_stack.head() {
Some(h) =>
self.check_recursion_limit(&obligation, h.obligation)?,
None =>
self.check_recursion_limit(&obligation, &obligation)?,
}
if !self.infcx.disable_trait_solver_fast_paths() &&
sizedness_fast_path(self.tcx(), obligation.predicate,
obligation.param_env) {
return Ok(EvaluatedToOk);
}
let bound_predicate = obligation.predicate.kind();
match bound_predicate.skip_binder() {
ty::PredicateKind::Clause(ty::ClauseKind::Trait(t)) => {
let t = bound_predicate.rebind(t);
if true {
if !!t.has_escaping_bound_vars() {
::core::panicking::panic("assertion failed: !t.has_escaping_bound_vars()")
};
};
let obligation = obligation.with(self.tcx(), t);
self.evaluate_trait_predicate_recursively(previous_stack,
obligation)
}
ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(data))
=> {
self.infcx.enter_forall(bound_predicate.rebind(data),
|data|
{
match effects::evaluate_host_effect_obligation(self,
&obligation.with(self.tcx(), data)) {
Ok(nested) =>
self.evaluate_predicates_recursively(previous_stack,
nested),
Err(effects::EvaluationFailure::Ambiguous) =>
Ok(EvaluatedToAmbig),
Err(effects::EvaluationFailure::NoSolution) =>
Ok(EvaluatedToErr),
}
})
}
ty::PredicateKind::Subtype(p) => {
let p = bound_predicate.rebind(p);
match self.infcx.subtype_predicate(&obligation.cause,
obligation.param_env, p) {
Ok(Ok(InferOk { obligations, .. })) => {
self.evaluate_predicates_recursively(previous_stack,
obligations)
}
Ok(Err(_)) => Ok(EvaluatedToErr),
Err(..) => Ok(EvaluatedToAmbig),
}
}
ty::PredicateKind::Coerce(p) => {
let p = bound_predicate.rebind(p);
match self.infcx.coerce_predicate(&obligation.cause,
obligation.param_env, p) {
Ok(Ok(InferOk { obligations, .. })) => {
self.evaluate_predicates_recursively(previous_stack,
obligations)
}
Ok(Err(_)) => Ok(EvaluatedToErr),
Err(..) => Ok(EvaluatedToAmbig),
}
}
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term))
=> {
if term.is_trivially_wf(self.tcx()) {
return Ok(EvaluatedToOk);
}
let cache = previous_stack.cache;
let dfn = cache.next_dfn();
for stack_term in
previous_stack.cache.wf_args.borrow().iter().rev() {
if stack_term.0 != term { continue; }
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:690",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(690u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("WellFormed({0:?}) on stack",
term) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
if let Some(stack) = previous_stack.head {
let cycle =
stack.iter().take_while(|s| s.depth > stack_term.1);
let tcx = self.tcx();
let cycle =
cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
if self.coinductive_match(cycle) {
stack.update_reached_depth(stack_term.1);
return Ok(EvaluatedToOk);
} else { return Ok(EvaluatedToAmbigStackDependent); }
}
return Ok(EvaluatedToOk);
}
match wf::obligations(self.infcx, obligation.param_env,
obligation.cause.body_def_id,
obligation.recursion_depth + 1, term, obligation.cause.span)
{
Some(obligations) => {
cache.wf_args.borrow_mut().push((term,
previous_stack.depth()));
let result =
self.evaluate_predicates_recursively(previous_stack,
obligations);
cache.wf_args.borrow_mut().pop();
let result = result?;
if !result.must_apply_modulo_regions() {
cache.on_failure(dfn);
}
cache.on_completion(dfn);
Ok(result)
}
None => Ok(EvaluatedToAmbig),
}
}
ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(pred))
=> {
if pred.0.has_free_regions() || pred.0.has_bound_regions()
|| pred.0.has_non_region_infer() ||
pred.0.has_non_region_param() {
Ok(EvaluatedToOkModuloRegions)
} else { Ok(EvaluatedToOk) }
}
ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..))
=> {
Ok(EvaluatedToOkModuloRegions)
}
ty::PredicateKind::DynCompatible(trait_def_id) => {
if self.tcx().is_dyn_compatible(trait_def_id) {
Ok(EvaluatedToOk)
} else { Ok(EvaluatedToErr) }
}
ty::PredicateKind::Clause(ty::ClauseKind::Projection(data))
=> {
let data = bound_predicate.rebind(data);
let project_obligation = obligation.with(self.tcx(), data);
match project::poly_project_and_unify_term(self,
&project_obligation) {
ProjectAndUnifyResult::Holds(mut subobligations) => {
'compute_res:
{
if let Some(key) =
ProjectionCacheKey::from_poly_projection_obligation(self,
&project_obligation) &&
let Some(cached_res) =
self.infcx.inner.borrow_mut().projection_cache().is_complete(key)
{
break 'compute_res Ok(cached_res);
}
for subobligation in subobligations.iter_mut() {
subobligation.set_depth_from_parent(obligation.recursion_depth);
}
let res =
self.evaluate_predicates_recursively(previous_stack,
subobligations);
if let Ok(eval_rslt) = res &&
(eval_rslt == EvaluatedToOk ||
eval_rslt == EvaluatedToOkModuloRegions) &&
let Some(key) =
ProjectionCacheKey::from_poly_projection_obligation(self,
&project_obligation) {
self.infcx.inner.borrow_mut().projection_cache().complete(key,
eval_rslt);
}
res
}
}
ProjectAndUnifyResult::FailedNormalization =>
Ok(EvaluatedToAmbig),
ProjectAndUnifyResult::Recursive =>
Ok(EvaluatedToAmbigStackDependent),
ProjectAndUnifyResult::MismatchedProjectionTypes(_) =>
Ok(EvaluatedToErr),
}
}
ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol))
=> {
if may_use_unstable_feature(self.infcx,
obligation.param_env, symbol) {
Ok(EvaluatedToOk)
} else { Ok(EvaluatedToAmbig) }
}
ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(alias_const))
=> {
match const_evaluatable::is_const_evaluatable(self.infcx,
alias_const, obligation.param_env, obligation.cause.span) {
Ok(()) => Ok(EvaluatedToOk),
Err(NotConstEvaluatable::MentionsInfer) =>
Ok(EvaluatedToAmbig),
Err(NotConstEvaluatable::MentionsParam) =>
Ok(EvaluatedToErr),
Err(_) => Ok(EvaluatedToErr),
}
}
ty::PredicateKind::ConstEquate(c1, c2) => {
let tcx = self.tcx();
if !tcx.features().generic_const_exprs() {
{
::core::panicking::panic_fmt(format_args!("`ConstEquate` without a feature gate: {0:?} {1:?}",
c1, c2));
}
};
{
let c1 = tcx.expand_abstract_consts(c1);
let c2 = tcx.expand_abstract_consts(c2);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:867",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(867u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("evaluate_predicate_recursively: equating consts:\nc1= {0:?}\nc2= {1:?}",
c1, c2) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
match (c1.kind(), c2.kind()) {
(ty::ConstKind::Alias(_, a), ty::ConstKind::Alias(_, b)) if
a.kind == b.kind &&
#[allow(non_exhaustive_omitted_patterns)] match a.kind {
ty::AliasConstKind::Projection { .. } |
ty::AliasConstKind::InherentSelf { .. } |
ty::AliasConstKind::InherentImpl { .. } => true,
_ => false,
} => {
if let Ok(InferOk { obligations, value: () }) =
self.infcx.at(&obligation.cause,
obligation.param_env).eq(DefineOpaqueTypes::Yes,
ty::AliasTerm::from(a), ty::AliasTerm::from(b)) {
return self.evaluate_predicates_recursively(previous_stack,
obligations);
}
}
(_, ty::ConstKind::Alias(_, _)) |
(ty::ConstKind::Alias(_, _), _) => (),
(_, _) => {
if let Ok(InferOk { obligations, value: () }) =
self.infcx.at(&obligation.cause,
obligation.param_env).eq(DefineOpaqueTypes::Yes, c1, c2) {
return self.evaluate_predicates_recursively(previous_stack,
obligations);
}
}
}
}
let evaluate =
|c: ty::Const<'tcx>|
{
if let ty::ConstKind::Alias(_, _) = c.kind() {
crate::traits::try_evaluate_const(self.infcx, c,
obligation.param_env, |v| Ok::<_, !>(v.skip_norm_wip()))
} else { Ok(c) }
};
match (evaluate(c1), evaluate(c2)) {
(Ok(c1), Ok(c2)) => {
match self.infcx.at(&obligation.cause,
obligation.param_env).eq(DefineOpaqueTypes::Yes, c1, c2) {
Ok(inf_ok) =>
self.evaluate_predicates_recursively(previous_stack,
inf_ok.into_obligations()),
Err(_) => Ok(EvaluatedToErr),
}
}
(Err(EvaluateConstErr::InvalidConstParamTy(..)), _) |
(_, Err(EvaluateConstErr::InvalidConstParamTy(..))) =>
Ok(EvaluatedToErr),
(Err(EvaluateConstErr::EvaluationFailure(..)), _) |
(_, Err(EvaluateConstErr::EvaluationFailure(..))) =>
Ok(EvaluatedToErr),
(Err(EvaluateConstErr::HasGenericsOrInfers), _) |
(_, Err(EvaluateConstErr::HasGenericsOrInfers)) => {
if c1.has_non_region_infer() || c2.has_non_region_infer() {
Ok(EvaluatedToAmbig)
} else { Ok(EvaluatedToErr) }
}
}
}
ty::PredicateKind::NormalizesTo(..) => {
::rustc_middle::util::bug::bug_fmt(format_args!("NormalizesTo is only used by the new solver"))
}
ty::PredicateKind::Ambiguous => Ok(EvaluatedToAmbig),
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct,
ty)) => {
let ct = self.infcx.shallow_resolve_const(ct);
let ct_ty =
match ct.kind() {
ty::ConstKind::Infer(_) => { return Ok(EvaluatedToAmbig); }
ty::ConstKind::Error(_) => return Ok(EvaluatedToOk),
ty::ConstKind::Value(cv) => cv.ty,
ty::ConstKind::Alias(_, alias_const) => {
alias_const.type_of(self.tcx()).skip_norm_wip()
}
ty::ConstKind::Expr(_) => return Ok(EvaluatedToOk),
ty::ConstKind::Placeholder(_) => {
::rustc_middle::util::bug::bug_fmt(format_args!("placeholder const {0:?} in old solver",
ct))
}
ty::ConstKind::Bound(_, _) =>
::rustc_middle::util::bug::bug_fmt(format_args!("escaping bound vars in {0:?}",
ct)),
ty::ConstKind::Param(param_ct) => {
param_ct.find_const_ty_from_env(obligation.param_env)
}
};
match self.infcx.at(&obligation.cause,
obligation.param_env).eq(DefineOpaqueTypes::Yes, ct_ty, ty)
{
Ok(inf_ok) =>
self.evaluate_predicates_recursively(previous_stack,
inf_ok.into_obligations()),
Err(_) => Ok(EvaluatedToErr),
}
}
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:585",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(585u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(
586 level = "debug",
587 skip(self, previous_stack),
588 fields(previous_stack = ?previous_stack.head())
589 ret,
590 )]
591 fn evaluate_predicate_recursively<'o>(
592 &mut self,
593 previous_stack: TraitObligationStackList<'o, 'tcx>,
594 obligation: PredicateObligation<'tcx>,
595 ) -> Result<EvaluationResult, OverflowError> {
596 debug_assert!(!self.infcx.next_trait_solver());
597 match previous_stack.head() {
602 Some(h) => self.check_recursion_limit(&obligation, h.obligation)?,
603 None => self.check_recursion_limit(&obligation, &obligation)?,
604 }
605
606 if !self.infcx.disable_trait_solver_fast_paths()
607 && sizedness_fast_path(self.tcx(), obligation.predicate, obligation.param_env)
608 {
609 return Ok(EvaluatedToOk);
610 }
611
612 let bound_predicate = obligation.predicate.kind();
613 match bound_predicate.skip_binder() {
614 ty::PredicateKind::Clause(ty::ClauseKind::Trait(t)) => {
615 let t = bound_predicate.rebind(t);
616 debug_assert!(!t.has_escaping_bound_vars());
617 let obligation = obligation.with(self.tcx(), t);
618 self.evaluate_trait_predicate_recursively(previous_stack, obligation)
619 }
620
621 ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(data)) => {
622 self.infcx.enter_forall(bound_predicate.rebind(data), |data| {
623 match effects::evaluate_host_effect_obligation(
624 self,
625 &obligation.with(self.tcx(), data),
626 ) {
627 Ok(nested) => self.evaluate_predicates_recursively(previous_stack, nested),
628 Err(effects::EvaluationFailure::Ambiguous) => Ok(EvaluatedToAmbig),
629 Err(effects::EvaluationFailure::NoSolution) => Ok(EvaluatedToErr),
630 }
631 })
632 }
633
634 ty::PredicateKind::Subtype(p) => {
635 let p = bound_predicate.rebind(p);
636 match self.infcx.subtype_predicate(&obligation.cause, obligation.param_env, p) {
638 Ok(Ok(InferOk { obligations, .. })) => {
639 self.evaluate_predicates_recursively(previous_stack, obligations)
640 }
641 Ok(Err(_)) => Ok(EvaluatedToErr),
642 Err(..) => Ok(EvaluatedToAmbig),
643 }
644 }
645
646 ty::PredicateKind::Coerce(p) => {
647 let p = bound_predicate.rebind(p);
648 match self.infcx.coerce_predicate(&obligation.cause, obligation.param_env, p) {
650 Ok(Ok(InferOk { obligations, .. })) => {
651 self.evaluate_predicates_recursively(previous_stack, obligations)
652 }
653 Ok(Err(_)) => Ok(EvaluatedToErr),
654 Err(..) => Ok(EvaluatedToAmbig),
655 }
656 }
657
658 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
659 if term.is_trivially_wf(self.tcx()) {
660 return Ok(EvaluatedToOk);
661 }
662
663 let cache = previous_stack.cache;
684 let dfn = cache.next_dfn();
685
686 for stack_term in previous_stack.cache.wf_args.borrow().iter().rev() {
687 if stack_term.0 != term {
688 continue;
689 }
690 debug!("WellFormed({:?}) on stack", term);
691 if let Some(stack) = previous_stack.head {
692 let cycle = stack.iter().take_while(|s| s.depth > stack_term.1);
707 let tcx = self.tcx();
708 let cycle = cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
709 if self.coinductive_match(cycle) {
710 stack.update_reached_depth(stack_term.1);
711 return Ok(EvaluatedToOk);
712 } else {
713 return Ok(EvaluatedToAmbigStackDependent);
714 }
715 }
716 return Ok(EvaluatedToOk);
717 }
718
719 match wf::obligations(
720 self.infcx,
721 obligation.param_env,
722 obligation.cause.body_def_id,
723 obligation.recursion_depth + 1,
724 term,
725 obligation.cause.span,
726 ) {
727 Some(obligations) => {
728 cache.wf_args.borrow_mut().push((term, previous_stack.depth()));
729 let result =
730 self.evaluate_predicates_recursively(previous_stack, obligations);
731 cache.wf_args.borrow_mut().pop();
732
733 let result = result?;
734
735 if !result.must_apply_modulo_regions() {
736 cache.on_failure(dfn);
737 }
738
739 cache.on_completion(dfn);
740
741 Ok(result)
742 }
743 None => Ok(EvaluatedToAmbig),
744 }
745 }
746
747 ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(pred)) => {
748 if pred.0.has_free_regions()
751 || pred.0.has_bound_regions()
752 || pred.0.has_non_region_infer()
753 || pred.0.has_non_region_param()
754 {
755 Ok(EvaluatedToOkModuloRegions)
756 } else {
757 Ok(EvaluatedToOk)
758 }
759 }
760
761 ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..)) => {
762 Ok(EvaluatedToOkModuloRegions)
764 }
765
766 ty::PredicateKind::DynCompatible(trait_def_id) => {
767 if self.tcx().is_dyn_compatible(trait_def_id) {
772 Ok(EvaluatedToOk)
773 } else {
774 Ok(EvaluatedToErr)
775 }
776 }
777
778 ty::PredicateKind::Clause(ty::ClauseKind::Projection(data)) => {
779 let data = bound_predicate.rebind(data);
780 let project_obligation = obligation.with(self.tcx(), data);
781 match project::poly_project_and_unify_term(self, &project_obligation) {
782 ProjectAndUnifyResult::Holds(mut subobligations) => {
783 'compute_res: {
784 if let Some(key) = ProjectionCacheKey::from_poly_projection_obligation(
789 self,
790 &project_obligation,
791 ) && let Some(cached_res) =
792 self.infcx.inner.borrow_mut().projection_cache().is_complete(key)
793 {
794 break 'compute_res Ok(cached_res);
795 }
796
797 for subobligation in subobligations.iter_mut() {
803 subobligation.set_depth_from_parent(obligation.recursion_depth);
804 }
805 let res = self
806 .evaluate_predicates_recursively(previous_stack, subobligations);
807 if let Ok(eval_rslt) = res
808 && (eval_rslt == EvaluatedToOk
809 || eval_rslt == EvaluatedToOkModuloRegions)
810 && let Some(key) =
811 ProjectionCacheKey::from_poly_projection_obligation(
812 self,
813 &project_obligation,
814 )
815 {
816 self.infcx
821 .inner
822 .borrow_mut()
823 .projection_cache()
824 .complete(key, eval_rslt);
825 }
826 res
827 }
828 }
829 ProjectAndUnifyResult::FailedNormalization => Ok(EvaluatedToAmbig),
830 ProjectAndUnifyResult::Recursive => Ok(EvaluatedToAmbigStackDependent),
831 ProjectAndUnifyResult::MismatchedProjectionTypes(_) => Ok(EvaluatedToErr),
832 }
833 }
834
835 ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
836 if may_use_unstable_feature(self.infcx, obligation.param_env, symbol) {
837 Ok(EvaluatedToOk)
838 } else {
839 Ok(EvaluatedToAmbig)
840 }
841 }
842
843 ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(alias_const)) => {
844 match const_evaluatable::is_const_evaluatable(
845 self.infcx,
846 alias_const,
847 obligation.param_env,
848 obligation.cause.span,
849 ) {
850 Ok(()) => Ok(EvaluatedToOk),
851 Err(NotConstEvaluatable::MentionsInfer) => Ok(EvaluatedToAmbig),
852 Err(NotConstEvaluatable::MentionsParam) => Ok(EvaluatedToErr),
853 Err(_) => Ok(EvaluatedToErr),
854 }
855 }
856
857 ty::PredicateKind::ConstEquate(c1, c2) => {
858 let tcx = self.tcx();
859 assert!(
860 tcx.features().generic_const_exprs(),
861 "`ConstEquate` without a feature gate: {c1:?} {c2:?}",
862 );
863
864 {
865 let c1 = tcx.expand_abstract_consts(c1);
866 let c2 = tcx.expand_abstract_consts(c2);
867 debug!(
868 "evaluate_predicate_recursively: equating consts:\nc1= {:?}\nc2= {:?}",
869 c1, c2
870 );
871
872 match (c1.kind(), c2.kind()) {
873 (ty::ConstKind::Alias(_, a), ty::ConstKind::Alias(_, b))
874 if a.kind == b.kind
875 && matches!(
876 a.kind,
877 ty::AliasConstKind::Projection { .. }
878 | ty::AliasConstKind::InherentSelf { .. }
879 | ty::AliasConstKind::InherentImpl { .. }
880 ) =>
881 {
882 if let Ok(InferOk { obligations, value: () }) = self
883 .infcx
884 .at(&obligation.cause, obligation.param_env)
885 .eq(
888 DefineOpaqueTypes::Yes,
889 ty::AliasTerm::from(a),
890 ty::AliasTerm::from(b),
891 )
892 {
893 return self
894 .evaluate_predicates_recursively(previous_stack, obligations);
895 }
896 }
897 (_, ty::ConstKind::Alias(_, _)) | (ty::ConstKind::Alias(_, _), _) => (),
898 (_, _) => {
899 if let Ok(InferOk { obligations, value: () }) = self
900 .infcx
901 .at(&obligation.cause, obligation.param_env)
902 .eq(DefineOpaqueTypes::Yes, c1, c2)
905 {
906 return self
907 .evaluate_predicates_recursively(previous_stack, obligations);
908 }
909 }
910 }
911 }
912
913 let evaluate = |c: ty::Const<'tcx>| {
914 if let ty::ConstKind::Alias(_, _) = c.kind() {
915 crate::traits::try_evaluate_const(
916 self.infcx,
917 c,
918 obligation.param_env,
919 |v| Ok::<_, !>(v.skip_norm_wip()),
920 )
921 } else {
922 Ok(c)
923 }
924 };
925
926 match (evaluate(c1), evaluate(c2)) {
927 (Ok(c1), Ok(c2)) => {
928 match self.infcx.at(&obligation.cause, obligation.param_env).eq(
929 DefineOpaqueTypes::Yes,
932 c1,
933 c2,
934 ) {
935 Ok(inf_ok) => self.evaluate_predicates_recursively(
936 previous_stack,
937 inf_ok.into_obligations(),
938 ),
939 Err(_) => Ok(EvaluatedToErr),
940 }
941 }
942 (Err(EvaluateConstErr::InvalidConstParamTy(..)), _)
943 | (_, Err(EvaluateConstErr::InvalidConstParamTy(..))) => Ok(EvaluatedToErr),
944 (Err(EvaluateConstErr::EvaluationFailure(..)), _)
945 | (_, Err(EvaluateConstErr::EvaluationFailure(..))) => Ok(EvaluatedToErr),
946 (Err(EvaluateConstErr::HasGenericsOrInfers), _)
947 | (_, Err(EvaluateConstErr::HasGenericsOrInfers)) => {
948 if c1.has_non_region_infer() || c2.has_non_region_infer() {
949 Ok(EvaluatedToAmbig)
950 } else {
951 Ok(EvaluatedToErr)
953 }
954 }
955 }
956 }
957 ty::PredicateKind::NormalizesTo(..) => {
958 bug!("NormalizesTo is only used by the new solver")
959 }
960 ty::PredicateKind::Ambiguous => Ok(EvaluatedToAmbig),
961 ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
962 let ct = self.infcx.shallow_resolve_const(ct);
963 let ct_ty = match ct.kind() {
964 ty::ConstKind::Infer(_) => {
965 return Ok(EvaluatedToAmbig);
966 }
967 ty::ConstKind::Error(_) => return Ok(EvaluatedToOk),
968 ty::ConstKind::Value(cv) => cv.ty,
969 ty::ConstKind::Alias(_, alias_const) => {
970 alias_const.type_of(self.tcx()).skip_norm_wip()
971 }
972 ty::ConstKind::Expr(_) => return Ok(EvaluatedToOk),
974 ty::ConstKind::Placeholder(_) => {
975 bug!("placeholder const {:?} in old solver", ct)
976 }
977 ty::ConstKind::Bound(_, _) => bug!("escaping bound vars in {:?}", ct),
978 ty::ConstKind::Param(param_ct) => {
979 param_ct.find_const_ty_from_env(obligation.param_env)
980 }
981 };
982
983 match self.infcx.at(&obligation.cause, obligation.param_env).eq(
984 DefineOpaqueTypes::Yes,
986 ct_ty,
987 ty,
988 ) {
989 Ok(inf_ok) => self
990 .evaluate_predicates_recursively(previous_stack, inf_ok.into_obligations()),
991 Err(_) => Ok(EvaluatedToErr),
992 }
993 }
994 }
995 }
996
997 {}
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("evaluate_trait_predicate_recursively",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(997u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<EvaluationResult, OverflowError> = loop {};
return __tracing_attr_fake_return;
}
{
if !self.typing_mode().is_coherence() &&
obligation.is_global() &&
obligation.param_env.caller_bounds().all(|bound|
bound.has_param()) {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1010",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1010u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("in global")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
obligation.param_env = ty::ParamEnv::empty();
}
let stack = self.push_stack(previous_stack, &obligation);
let fresh_trait_pred = stack.fresh_trait_pred;
let param_env = obligation.param_env;
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1018",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1018u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fresh_trait_pred")
}> =
::tracing::__macro_support::FieldName::new("fresh_trait_pred");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fresh_trait_pred)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
if let Some(result) =
self.check_evaluation_cache(param_env, fresh_trait_pred) {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1023",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1023u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("CACHE HIT")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
return Ok(result);
}
if let Some(result) =
stack.cache().get_provisional(fresh_trait_pred) {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1028",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1028u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("PROVISIONAL CACHE HIT")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
stack.update_reached_depth(result.reached_depth);
return Ok(result.result);
}
if let Some(cycle_result) =
self.check_evaluation_cycle(&stack) {
return Ok(cycle_result);
}
let (result, dep_node) =
self.in_task(|this|
{
let mut result = this.evaluate_stack(&stack)?;
if EvaluationResult::EvaluatedToErr == result &&
fresh_trait_pred.has_aliases() &&
fresh_trait_pred.is_global() {
let mut nested_obligations = PredicateObligations::new();
let predicate =
normalize_with_depth_to(this, param_env,
obligation.cause.clone(), obligation.recursion_depth + 1,
Unnormalized::new_wip(obligation.predicate),
&mut nested_obligations);
if predicate != obligation.predicate {
let mut nested_result = EvaluationResult::EvaluatedToOk;
for obligation in nested_obligations {
nested_result =
cmp::max(this.evaluate_predicate_recursively(previous_stack,
obligation)?, nested_result);
}
if nested_result.must_apply_modulo_regions() {
let obligation = obligation.with(this.tcx(), predicate);
result =
cmp::max(nested_result,
this.evaluate_trait_predicate_recursively(previous_stack,
obligation)?);
}
}
}
Ok::<_, OverflowError>(result)
});
let result = result?;
if !result.must_apply_modulo_regions() {
stack.cache().on_failure(stack.dfn);
}
let reached_depth = stack.reached_depth.get();
if reached_depth >= stack.depth {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1095",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1095u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("CACHE MISS")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.insert_evaluation_cache(param_env, fresh_trait_pred,
dep_node, result);
stack.cache().on_completion(stack.dfn);
} else if let Some(_guar) = self.infcx.tainted_by_errors() {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1103",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1103u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("CACHE MISS (tainted by errors)")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.insert_evaluation_cache(param_env, fresh_trait_pred,
dep_node, result);
stack.cache().on_completion(stack.dfn);
} else {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1107",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1107u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("PROVISIONAL")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1108",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1108u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("caching provisionally because {0:?} is a cycle participant (at depth {1}, reached depth {2})",
fresh_trait_pred, stack.depth, reached_depth) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};
stack.cache().insert_provisional(stack.dfn, reached_depth,
fresh_trait_pred, result);
}
Ok(result)
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:997",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(997u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(skip(self, previous_stack), level = "debug", ret)]
998 fn evaluate_trait_predicate_recursively<'o>(
999 &mut self,
1000 previous_stack: TraitObligationStackList<'o, 'tcx>,
1001 mut obligation: PolyTraitObligation<'tcx>,
1002 ) -> Result<EvaluationResult, OverflowError> {
1003 if !self.typing_mode().is_coherence()
1004 && obligation.is_global()
1005 && obligation.param_env.caller_bounds().all(|bound| bound.has_param())
1006 {
1007 debug!("in global");
1011 obligation.param_env = ty::ParamEnv::empty();
1012 }
1013
1014 let stack = self.push_stack(previous_stack, &obligation);
1015 let fresh_trait_pred = stack.fresh_trait_pred;
1016 let param_env = obligation.param_env;
1017
1018 debug!(?fresh_trait_pred);
1019
1020 if let Some(result) = self.check_evaluation_cache(param_env, fresh_trait_pred) {
1023 debug!("CACHE HIT");
1024 return Ok(result);
1025 }
1026
1027 if let Some(result) = stack.cache().get_provisional(fresh_trait_pred) {
1028 debug!("PROVISIONAL CACHE HIT");
1029 stack.update_reached_depth(result.reached_depth);
1030 return Ok(result.result);
1031 }
1032
1033 if let Some(cycle_result) = self.check_evaluation_cycle(&stack) {
1039 return Ok(cycle_result);
1040 }
1041
1042 let (result, dep_node) = self.in_task(|this| {
1043 let mut result = this.evaluate_stack(&stack)?;
1044
1045 if EvaluationResult::EvaluatedToErr == result
1053 && fresh_trait_pred.has_aliases()
1054 && fresh_trait_pred.is_global()
1055 {
1056 let mut nested_obligations = PredicateObligations::new();
1057 let predicate = normalize_with_depth_to(
1058 this,
1059 param_env,
1060 obligation.cause.clone(),
1061 obligation.recursion_depth + 1,
1062 Unnormalized::new_wip(obligation.predicate),
1063 &mut nested_obligations,
1064 );
1065 if predicate != obligation.predicate {
1066 let mut nested_result = EvaluationResult::EvaluatedToOk;
1067 for obligation in nested_obligations {
1068 nested_result = cmp::max(
1069 this.evaluate_predicate_recursively(previous_stack, obligation)?,
1070 nested_result,
1071 );
1072 }
1073
1074 if nested_result.must_apply_modulo_regions() {
1075 let obligation = obligation.with(this.tcx(), predicate);
1076 result = cmp::max(
1077 nested_result,
1078 this.evaluate_trait_predicate_recursively(previous_stack, obligation)?,
1079 );
1080 }
1081 }
1082 }
1083
1084 Ok::<_, OverflowError>(result)
1085 });
1086
1087 let result = result?;
1088
1089 if !result.must_apply_modulo_regions() {
1090 stack.cache().on_failure(stack.dfn);
1091 }
1092
1093 let reached_depth = stack.reached_depth.get();
1094 if reached_depth >= stack.depth {
1095 debug!("CACHE MISS");
1096 self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
1097 stack.cache().on_completion(stack.dfn);
1098 } else if let Some(_guar) = self.infcx.tainted_by_errors() {
1099 debug!("CACHE MISS (tainted by errors)");
1104 self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
1105 stack.cache().on_completion(stack.dfn);
1106 } else {
1107 debug!("PROVISIONAL");
1108 debug!(
1109 "caching provisionally because {:?} \
1110 is a cycle participant (at depth {}, reached depth {})",
1111 fresh_trait_pred, stack.depth, reached_depth,
1112 );
1113
1114 stack.cache().insert_provisional(stack.dfn, reached_depth, fresh_trait_pred, result);
1115 }
1116
1117 Ok(result)
1118 }
1119
1120 fn check_evaluation_cycle(
1140 &mut self,
1141 stack: &TraitObligationStack<'_, 'tcx>,
1142 ) -> Option<EvaluationResult> {
1143 if let Some(cycle_depth) = stack
1144 .iter()
1145 .skip(1) .find(|prev| {
1147 stack.obligation.param_env == prev.obligation.param_env
1148 && stack.fresh_trait_pred == prev.fresh_trait_pred
1149 })
1150 .map(|stack| stack.depth)
1151 {
1152 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1152",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1152u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("evaluate_stack --> recursive at depth {0}",
cycle_depth) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("evaluate_stack --> recursive at depth {}", cycle_depth);
1153
1154 stack.update_reached_depth(cycle_depth);
1161
1162 let cycle = stack.iter().skip(1).take_while(|s| s.depth >= cycle_depth);
1168 let tcx = self.tcx();
1169 let cycle = cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
1170 if self.coinductive_match(cycle) {
1171 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1171",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1171u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("evaluate_stack --> recursive, coinductive")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("evaluate_stack --> recursive, coinductive");
1172 Some(EvaluatedToOk)
1173 } else {
1174 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1174",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1174u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("evaluate_stack --> recursive, inductive")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("evaluate_stack --> recursive, inductive");
1175 Some(EvaluatedToAmbigStackDependent)
1176 }
1177 } else {
1178 None
1179 }
1180 }
1181
1182 fn evaluate_stack<'o>(
1183 &mut self,
1184 stack: &TraitObligationStack<'o, 'tcx>,
1185 ) -> Result<EvaluationResult, OverflowError> {
1186 if true {
if !!self.infcx.next_trait_solver() {
::core::panicking::panic("assertion failed: !self.infcx.next_trait_solver()")
};
};debug_assert!(!self.infcx.next_trait_solver());
1187 let unbound_input_types =
1214 stack.fresh_trait_pred.skip_binder().trait_ref.args.types().any(|ty| ty.is_fresh());
1215
1216 if unbound_input_types
1217 && stack.iter().skip(1).any(|prev| {
1218 stack.obligation.param_env == prev.obligation.param_env
1219 && self.match_fresh_trait_preds(stack.fresh_trait_pred, prev.fresh_trait_pred)
1220 })
1221 {
1222 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1222",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1222u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("evaluate_stack --> unbound argument, recursive --> giving up")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("evaluate_stack --> unbound argument, recursive --> giving up");
1223 return Ok(EvaluatedToAmbigStackDependent);
1224 }
1225
1226 match self.candidate_from_obligation(stack) {
1227 Ok(Some(c)) => self.evaluate_candidate(stack, &c),
1228 Ok(None) => Ok(EvaluatedToAmbig),
1229 Err(SelectionError::Overflow(OverflowError::Canonical)) => {
1230 Err(OverflowError::Canonical)
1231 }
1232 Err(..) => Ok(EvaluatedToErr),
1233 }
1234 }
1235
1236 pub(crate) fn coinductive_match<I>(&mut self, mut cycle: I) -> bool
1245 where
1246 I: Iterator<Item = ty::Predicate<'tcx>>,
1247 {
1248 cycle.all(|p| match p.kind().skip_binder() {
1249 ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
1250 self.infcx.tcx.trait_is_coinductive(data.def_id())
1251 }
1252 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => {
1253 self.infcx.tcx.features().generic_const_exprs()
1257 }
1258 _ => false,
1259 })
1260 }
1261
1262 {}
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("evaluate_candidate",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1265u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidate")
}> =
::tracing::__macro_support::FieldName::new("candidate");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("depth")
}> =
::tracing::__macro_support::FieldName::new("depth");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&stack.obligation.recursion_depth
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<EvaluationResult, OverflowError> = loop {};
return __tracing_attr_fake_return;
}
{
let mut result =
self.evaluation_probe(|this|
{
match this.confirm_candidate(stack.obligation,
candidate.clone()) {
Ok(selection) => {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1279",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1279u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("selection")
}> =
::tracing::__macro_support::FieldName::new("selection");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&selection)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
if let ImplSource::Builtin(..) = selection &&
this.typing_mode().is_reflection() {
return Ok(EvaluatedToErr);
}
this.evaluate_predicates_recursively(stack.list(),
selection.nested_obligations().into_iter())
}
Err(..) => Ok(EvaluatedToErr),
}
})?;
if stack.fresh_trait_pred.has_erased_regions() {
result = result.max(EvaluatedToOkModuloRegions);
}
Ok(result)
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1265",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1265u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(
1266 level = "debug",
1267 skip(self, stack),
1268 fields(depth = stack.obligation.recursion_depth),
1269 ret
1270 )]
1271 fn evaluate_candidate<'o>(
1272 &mut self,
1273 stack: &TraitObligationStack<'o, 'tcx>,
1274 candidate: &SelectionCandidate<'tcx>,
1275 ) -> Result<EvaluationResult, OverflowError> {
1276 let mut result = self.evaluation_probe(|this| {
1277 match this.confirm_candidate(stack.obligation, candidate.clone()) {
1278 Ok(selection) => {
1279 debug!(?selection);
1280 if let ImplSource::Builtin(..) = selection
1281 && this.typing_mode().is_reflection()
1282 {
1283 return Ok(EvaluatedToErr);
1284 }
1285 this.evaluate_predicates_recursively(
1286 stack.list(),
1287 selection.nested_obligations().into_iter(),
1288 )
1289 }
1290 Err(..) => Ok(EvaluatedToErr),
1291 }
1292 })?;
1293
1294 if stack.fresh_trait_pred.has_erased_regions() {
1303 result = result.max(EvaluatedToOkModuloRegions);
1304 }
1305
1306 Ok(result)
1307 }
1308
1309 fn check_evaluation_cache(
1310 &self,
1311 param_env: ty::ParamEnv<'tcx>,
1312 trait_pred: ty::PolyTraitClause<'tcx>,
1313 ) -> Option<EvaluationResult> {
1314 let infcx = self.infcx;
1315 let tcx = infcx.tcx;
1316 if self.can_use_global_caches(param_env, trait_pred) {
1317 let key = (infcx.typing_env(param_env), trait_pred);
1318 if let Some(res) = tcx.caches.evaluation_cache.get(&key, tcx) {
1319 Some(res)
1320 } else {
1321 if true {
{
match (&infcx.evaluation_cache.get(&(param_env, trait_pred), tcx),
&None) {
(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);
}
}
}
};
};debug_assert_eq!(infcx.evaluation_cache.get(&(param_env, trait_pred), tcx), None);
1322 None
1323 }
1324 } else {
1325 self.infcx.evaluation_cache.get(&(param_env, trait_pred), tcx)
1326 }
1327 }
1328
1329 fn insert_evaluation_cache(
1330 &mut self,
1331 param_env: ty::ParamEnv<'tcx>,
1332 trait_pred: ty::PolyTraitClause<'tcx>,
1333 dep_node: DepNodeIndex,
1334 result: EvaluationResult,
1335 ) {
1336 if result.is_stack_dependent() {
1339 return;
1340 }
1341
1342 let infcx = self.infcx;
1343 let tcx = infcx.tcx;
1344 if self.can_use_global_caches(param_env, trait_pred) {
1345 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1345",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1345u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("trait_pred")
}> =
::tracing::__macro_support::FieldName::new("trait_pred");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("result")
}> =
::tracing::__macro_support::FieldName::new("result");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("insert_evaluation_cache global")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_pred)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&result)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?trait_pred, ?result, "insert_evaluation_cache global");
1346 tcx.caches.evaluation_cache.insert(
1348 (infcx.typing_env(param_env), trait_pred),
1349 dep_node,
1350 result,
1351 );
1352 return;
1353 } else {
1354 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1354",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1354u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("trait_pred")
}> =
::tracing::__macro_support::FieldName::new("trait_pred");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("result")
}> =
::tracing::__macro_support::FieldName::new("result");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("insert_evaluation_cache local")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_pred)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&result)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?trait_pred, ?result, "insert_evaluation_cache local");
1355 self.infcx.evaluation_cache.insert((param_env, trait_pred), dep_node, result);
1356 }
1357 }
1358
1359 fn check_recursion_depth<T>(
1360 &self,
1361 depth: usize,
1362 error_obligation: &Obligation<'tcx, T>,
1363 ) -> Result<(), OverflowError>
1364 where
1365 T: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + Clone,
1366 {
1367 if !self.infcx.tcx.recursion_limit().value_within_limit(depth) {
1368 match self.query_mode {
1369 TraitQueryMode::Standard => {
1370 if let Some(e) = self.infcx.tainted_by_errors() {
1371 return Err(OverflowError::Error(e));
1372 }
1373 self.infcx.err_ctxt().report_overflow_obligation(error_obligation, true);
1374 }
1375 TraitQueryMode::Canonical => {
1376 return Err(OverflowError::Canonical);
1377 }
1378 }
1379 }
1380 Ok(())
1381 }
1382
1383 #[inline(always)]
1388 fn check_recursion_limit<T: Display + TypeFoldable<TyCtxt<'tcx>>, V>(
1389 &self,
1390 obligation: &Obligation<'tcx, T>,
1391 error_obligation: &Obligation<'tcx, V>,
1392 ) -> Result<(), OverflowError>
1393 where
1394 V: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + Clone,
1395 {
1396 self.check_recursion_depth(obligation.recursion_depth, error_obligation)
1397 }
1398
1399 fn in_task<OP, R>(&mut self, op: OP) -> (R, DepNodeIndex)
1400 where
1401 OP: FnOnce(&mut Self) -> R,
1402 {
1403 self.tcx().dep_graph.with_anon_task(self.tcx(), DepKind::TraitSelect, || op(self))
1404 }
1405
1406 {}
#[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("filter_impls",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1408u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: Vec<SelectionCandidate<'tcx>> =
loop {};
return __tracing_attr_fake_return;
}
{
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1414",
"rustc_trait_selection::traits::select",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1414u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("{0:#?}",
candidates) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let tcx = self.tcx();
candidates.retain(|candidate|
{
if let &ImplCandidate(def_id) = candidate {
match (tcx.impl_polarity(def_id), obligation.polarity()) {
(ty::ImplPolarity::Positive, ty::ClausePolarity::Positive) |
(ty::ImplPolarity::Negative, ty::ClausePolarity::Negative)
=> true,
_ => false,
}
} else { true }
});
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1431",
"rustc_trait_selection::traits::select",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1431u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("{0:#?}",
candidates) as &dyn ::tracing::field::Value))])
});
} else { ; }
};
candidates
}
}
}#[instrument(level = "debug", skip(self, candidates))]
1409 fn filter_impls(
1410 &mut self,
1411 mut candidates: Vec<SelectionCandidate<'tcx>>,
1412 obligation: &PolyTraitObligation<'tcx>,
1413 ) -> Vec<SelectionCandidate<'tcx>> {
1414 trace!("{candidates:#?}");
1415 let tcx = self.tcx();
1416
1417 candidates.retain(|candidate| {
1418 if let &ImplCandidate(def_id) = candidate {
1419 match (tcx.impl_polarity(def_id), obligation.polarity()) {
1420 (ty::ImplPolarity::Positive, ty::ClausePolarity::Positive)
1421 | (ty::ImplPolarity::Negative, ty::ClausePolarity::Negative) => true,
1422
1423 _ => false,
1425 }
1426 } else {
1427 true
1428 }
1429 });
1430
1431 trace!("{candidates:#?}");
1432 candidates
1433 }
1434
1435 fn is_knowable<'o>(&mut self, stack: &TraitObligationStack<'o, 'tcx>) -> Result<(), Conflict> {
1436 let obligation = &stack.obligation;
1437 match self.typing_mode() {
1438 TypingMode::Coherence => {}
1439 TypingMode::Typeck { .. }
1440 | TypingMode::PostTypeckUntilBorrowck { .. }
1441 | TypingMode::Reflection
1442 | TypingMode::PostBorrowck { .. }
1443 | TypingMode::PostAnalysis
1444 | TypingMode::Codegen => return Ok(()),
1445 }
1446
1447 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1447",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1447u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("is_knowable()")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("is_knowable()");
1448
1449 let predicate = self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
1450
1451 let trait_ref = predicate.skip_binder().trait_ref;
1455
1456 coherence::trait_ref_is_knowable(self.infcx, trait_ref, |ty| Ok::<_, !>(ty)).into_ok()
1457 }
1458
1459 fn can_use_global_caches(
1461 &self,
1462 param_env: ty::ParamEnv<'tcx>,
1463 pred: ty::PolyTraitClause<'tcx>,
1464 ) -> bool {
1465 if param_env.has_infer() || pred.has_infer() {
1469 return false;
1470 }
1471
1472 match self.typing_mode() {
1473 TypingMode::Coherence => false,
1480 TypingMode::Typeck { defining_opaque_types_and_generators: defining_opaque_types }
1489 | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types } => {
1490 defining_opaque_types.is_empty()
1491 || (!pred.has_opaque_types() && !pred.has_coroutines())
1492 }
1493 TypingMode::Reflection => false,
1496 TypingMode::PostBorrowck { .. } => true,
1499 TypingMode::PostAnalysis | TypingMode::Codegen => true,
1505 }
1506 }
1507
1508 fn check_candidate_cache(
1509 &mut self,
1510 param_env: ty::ParamEnv<'tcx>,
1511 cache_fresh_trait_pred: ty::PolyTraitClause<'tcx>,
1512 ) -> Option<SelectionResult<'tcx, SelectionCandidate<'tcx>>> {
1513 let infcx = self.infcx;
1514 let tcx = infcx.tcx;
1515 let pred = cache_fresh_trait_pred.skip_binder();
1516
1517 if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
1518 if let Some(res) =
1519 tcx.caches.selection_cache.get(&(infcx.typing_env(param_env), pred), tcx)
1520 {
1521 return Some(res);
1522 } else if truecfg!(debug_assertions) {
1523 match infcx.selection_cache.get(&(param_env, pred), tcx) {
1524 None | Some(Err(SelectionError::Overflow(OverflowError::Canonical))) => {}
1525 res => ::rustc_middle::util::bug::bug_fmt(format_args!("unexpected local cache result: {0:?}",
res))bug!("unexpected local cache result: {res:?}"),
1526 }
1527 }
1528 }
1529
1530 infcx.selection_cache.get(&(param_env, pred), tcx)
1534 }
1535
1536 fn can_cache_candidate(
1553 &self,
1554 result: &SelectionResult<'tcx, SelectionCandidate<'tcx>>,
1555 ) -> bool {
1556 match result {
1557 Ok(Some(SelectionCandidate::ParamCandidate(trait_ref))) => !trait_ref.has_infer(),
1558 _ => true,
1559 }
1560 }
1561
1562 {}
#[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("insert_candidate_cache",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1562u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidate")
}> =
::tracing::__macro_support::FieldName::new("candidate");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
let infcx = self.infcx;
let tcx = infcx.tcx;
let pred = cache_fresh_trait_pred.skip_binder();
if !self.can_cache_candidate(&candidate) {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1575",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1575u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("pred")
}> =
::tracing::__macro_support::FieldName::new("pred");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidate")
}> =
::tracing::__macro_support::FieldName::new("candidate");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("insert_candidate_cache - candidate is not cacheable")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&pred)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
return;
}
if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
if let Err(SelectionError::Overflow(OverflowError::Canonical))
= candidate
{} else {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1583",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1583u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("pred")
}> =
::tracing::__macro_support::FieldName::new("pred");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidate")
}> =
::tracing::__macro_support::FieldName::new("candidate");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("insert_candidate_cache global")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&pred)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
if true {
if !!candidate.has_infer() {
::core::panicking::panic("assertion failed: !candidate.has_infer()")
};
};
tcx.caches.selection_cache.insert((infcx.typing_env(param_env),
pred), dep_node, candidate);
return;
}
}
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1596",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1596u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("pred")
}> =
::tracing::__macro_support::FieldName::new("pred");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidate")
}> =
::tracing::__macro_support::FieldName::new("candidate");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("insert_candidate_cache local")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&pred)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
self.infcx.selection_cache.insert((param_env, pred), dep_node,
candidate);
}
}
}#[instrument(skip(self, param_env, cache_fresh_trait_pred, dep_node), level = "debug")]
1563 fn insert_candidate_cache(
1564 &mut self,
1565 param_env: ty::ParamEnv<'tcx>,
1566 cache_fresh_trait_pred: ty::PolyTraitClause<'tcx>,
1567 dep_node: DepNodeIndex,
1568 candidate: SelectionResult<'tcx, SelectionCandidate<'tcx>>,
1569 ) {
1570 let infcx = self.infcx;
1571 let tcx = infcx.tcx;
1572 let pred = cache_fresh_trait_pred.skip_binder();
1573
1574 if !self.can_cache_candidate(&candidate) {
1575 debug!(?pred, ?candidate, "insert_candidate_cache - candidate is not cacheable");
1576 return;
1577 }
1578
1579 if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
1580 if let Err(SelectionError::Overflow(OverflowError::Canonical)) = candidate {
1581 } else {
1583 debug!(?pred, ?candidate, "insert_candidate_cache global");
1584 debug_assert!(!candidate.has_infer());
1585
1586 tcx.caches.selection_cache.insert(
1588 (infcx.typing_env(param_env), pred),
1589 dep_node,
1590 candidate,
1591 );
1592 return;
1593 }
1594 }
1595
1596 debug!(?pred, ?candidate, "insert_candidate_cache local");
1597 self.infcx.selection_cache.insert((param_env, pred), dep_node, candidate);
1598 }
1599
1600 pub(super) fn for_each_item_bound<T>(
1606 &mut self,
1607 mut self_ty: Ty<'tcx>,
1608 mut for_each: impl FnMut(
1609 &mut Self,
1610 ty::Clause<'tcx>,
1611 usize,
1612 AliasBoundKind,
1613 ) -> ControlFlow<T, ()>,
1614 on_ambiguity: impl FnOnce(),
1615 ) -> ControlFlow<T, ()> {
1616 let mut idx = 0;
1617 let mut alias_bound_kind = AliasBoundKind::SelfBounds;
1618
1619 loop {
1620 let (alias_ty, def_id) = match *self_ty.kind() {
1621 ty::Alias(
1622 _,
1623 alias_ty @ ty::AliasTy {
1624 kind: ty::Projection { def_id } | ty::Opaque { def_id },
1625 ..
1626 },
1627 ) => (alias_ty, def_id),
1628 ty::Infer(ty::TyVar(_)) => {
1629 on_ambiguity();
1630 return ControlFlow::Continue(());
1631 }
1632 _ => return ControlFlow::Continue(()),
1633 };
1634
1635 let relevant_bounds = if alias_bound_kind == AliasBoundKind::NonSelfBounds {
1640 self.tcx().item_non_self_bounds(def_id)
1641 } else {
1642 self.tcx().item_self_bounds(def_id)
1643 };
1644
1645 for bound in relevant_bounds.instantiate(self.tcx(), alias_ty.args).skip_norm_wip() {
1646 for_each(self, bound, idx, alias_bound_kind)?;
1647 idx += 1;
1648 }
1649
1650 if #[allow(non_exhaustive_omitted_patterns)] match alias_ty.kind {
ty::Projection { .. } => true,
_ => false,
}matches!(alias_ty.kind, ty::Projection { .. }) {
1651 self_ty = alias_ty.self_ty();
1652 } else {
1653 return ControlFlow::Continue(());
1654 }
1655
1656 alias_bound_kind = AliasBoundKind::NonSelfBounds;
1657 }
1658 }
1659
1660 fn match_normalize_trait_ref(
1664 &mut self,
1665 obligation: &PolyTraitObligation<'tcx>,
1666 placeholder_trait_ref: ty::TraitRef<'tcx>,
1667 trait_bound: ty::PolyTraitRef<'tcx>,
1668 ) -> Result<Option<ty::TraitRef<'tcx>>, ()> {
1669 if true {
if !!placeholder_trait_ref.has_escaping_bound_vars() {
::core::panicking::panic("assertion failed: !placeholder_trait_ref.has_escaping_bound_vars()")
};
};debug_assert!(!placeholder_trait_ref.has_escaping_bound_vars());
1670 if placeholder_trait_ref.def_id != trait_bound.def_id() {
1671 return Err(());
1673 }
1674
1675 let drcx = DeepRejectCtxt::relate_rigid_rigid(self.infcx.tcx);
1676 let obligation_args = obligation.predicate.skip_binder().trait_ref.args;
1677 if !drcx.args_may_unify(obligation_args, trait_bound.skip_binder().args) {
1678 return Err(());
1679 }
1680
1681 let trait_bound = self.infcx.instantiate_binder_with_fresh_vars(
1682 obligation.cause.span,
1683 HigherRankedType,
1684 trait_bound,
1685 );
1686 let Normalized { value: trait_bound, obligations: _ } = normalize_with_depth(
1687 self,
1688 obligation.param_env,
1689 obligation.cause.clone(),
1690 obligation.recursion_depth + 1,
1691 ty::Unnormalized::new_wip(trait_bound),
1692 );
1693 self.infcx
1694 .at(&obligation.cause, obligation.param_env)
1695 .eq(DefineOpaqueTypes::No, placeholder_trait_ref, trait_bound)
1696 .map(|InferOk { obligations: _, value: () }| {
1697 if !trait_bound.has_infer() && !trait_bound.has_placeholders() {
1700 Some(trait_bound)
1701 } else {
1702 None
1703 }
1704 })
1705 .map_err(|_| ())
1706 }
1707
1708 fn where_clause_may_apply<'o>(
1709 &mut self,
1710 stack: &TraitObligationStack<'o, 'tcx>,
1711 where_clause_trait_ref: ty::PolyTraitRef<'tcx>,
1712 ) -> Result<EvaluationResult, OverflowError> {
1713 self.evaluation_probe(|this| {
1714 match this.match_where_clause_trait_ref(stack.obligation, where_clause_trait_ref) {
1715 Ok(obligations) => this.evaluate_predicates_recursively(stack.list(), obligations),
1716 Err(()) => Ok(EvaluatedToErr),
1717 }
1718 })
1719 }
1720
1721 pub(super) fn match_projection_projections(
1728 &mut self,
1729 obligation: &ProjectionTermObligation<'tcx>,
1730 env_predicate: PolyProjectionClause<'tcx>,
1731 potentially_unnormalized_candidates: bool,
1732 ) -> ProjectionMatchesProjection {
1733 let def_id = obligation.predicate.expect_projection_def_id();
1734 if true {
{
match (&def_id, &env_predicate.item_def_id()) {
(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);
}
}
}
};
};debug_assert_eq!(def_id, env_predicate.item_def_id());
1735
1736 let mut nested_obligations = PredicateObligations::new();
1737 let infer_predicate = self.infcx.instantiate_binder_with_fresh_vars(
1738 obligation.cause.span,
1739 BoundRegionConversionTime::HigherRankedType,
1740 env_predicate,
1741 );
1742 let mut infer_projection = infer_predicate.projection_term;
1743 if potentially_unnormalized_candidates {
1744 infer_projection = normalize_with_depth_to(
1745 self,
1746 obligation.param_env,
1747 obligation.cause.clone(),
1748 obligation.recursion_depth + 1,
1749 ty::Unnormalized::new_wip(infer_projection),
1750 &mut nested_obligations,
1751 )
1752 }
1753
1754 let is_match = self
1755 .infcx
1756 .at(&obligation.cause, obligation.param_env)
1757 .eq(DefineOpaqueTypes::No, obligation.predicate, infer_projection)
1758 .is_ok_and(|InferOk { obligations, value: () }| {
1759 self.evaluate_predicates_recursively(
1760 TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
1761 nested_obligations.into_iter().chain(obligations),
1762 )
1763 .is_ok_and(|res| res.may_apply())
1764 });
1765
1766 if is_match {
1767 let generics = self.tcx().generics_of(def_id);
1768 if !generics.is_own_empty()
1777 && obligation.predicate.args[generics.parent_count..].iter().any(|&p| {
1778 p.has_non_region_infer()
1779 && match p.kind() {
1780 ty::GenericArgKind::Const(ct) => {
1781 self.infcx.shallow_resolve_const(ct) != ct
1782 }
1783 ty::GenericArgKind::Type(ty) => self.infcx.shallow_resolve(ty) != ty,
1784 ty::GenericArgKind::Lifetime(_) => false,
1785 }
1786 })
1787 {
1788 ProjectionMatchesProjection::Ambiguous
1789 } else {
1790 ProjectionMatchesProjection::Yes
1791 }
1792 } else {
1793 ProjectionMatchesProjection::No
1794 }
1795 }
1796}
1797
1798impl<'tcx> SelectionContext<'_, 'tcx> {
1805 {}
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("winnow_candidates",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1809u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("has_non_region_infer")
}> =
::tracing::__macro_support::FieldName::new("has_non_region_infer");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidate_preference_mode")
}> =
::tracing::__macro_support::FieldName::new("candidate_preference_mode");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidates")
}> =
::tracing::__macro_support::FieldName::new("candidates");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&has_non_region_infer
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate_preference_mode)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidates)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Option<SelectionCandidate<'tcx>> = loop {};
return __tracing_attr_fake_return;
}
{
if candidates.len() == 1 {
return Some(candidates.pop().unwrap().candidate);
}
let mut sized_candidates =
candidates.iter().filter(|c|
#[allow(non_exhaustive_omitted_patterns)] match c.candidate
{
SizedCandidate => true,
_ => false,
});
if let Some(sized_candidate) = sized_candidates.next() {
if true {
{
match (&sized_candidates.next(), &None) {
(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);
}
}
}
};
};
if sized_candidate.evaluation.must_apply_modulo_regions() {
return Some(sized_candidate.candidate.clone());
} else { return None; }
}
'search_victim: loop {
for (i, this) in candidates.iter().enumerate() {
let ParamCandidate(this) = this.candidate else { continue };
for (j, other) in candidates.iter().enumerate() {
if i == j { continue; }
let ParamCandidate(other) =
other.candidate else { continue };
if this == other {
candidates.remove(j);
continue 'search_victim;
}
if this.skip_binder().trait_ref ==
other.skip_binder().trait_ref &&
this.skip_binder().polarity == other.skip_binder().polarity
&& !this.skip_binder().trait_ref.has_escaping_bound_vars() {
candidates.remove(j);
continue 'search_victim;
}
}
}
break;
}
let mut alias_bounds =
candidates.iter().filter_map(|c|
{
if let ProjectionCandidate { idx, kind } = c.candidate {
Some((idx, kind))
} else { None }
});
if #[allow(non_exhaustive_omitted_patterns)] match candidate_preference_mode
{
CandidatePreferenceMode::Marker => true,
_ => false,
} {
match alias_bounds.clone().filter_map(|(idx, kind)|
(kind ==
AliasBoundKind::SelfBounds).then_some(idx)).try_reduce(|c1,
c2|
if has_non_region_infer { None } else { Some(c1.min(c2)) })
{
Some(Some(idx)) => {
return Some(ProjectionCandidate {
idx,
kind: AliasBoundKind::SelfBounds,
});
}
Some(None) => {}
None => return None,
}
}
let is_global =
|c: ty::PolyTraitClause<'tcx>|
c.is_global() && !c.has_bound_vars();
let param_candidates =
candidates.iter().filter_map(|c|
if let ParamCandidate(p) = c.candidate {
Some(p)
} else { None });
let mut has_global_bounds = false;
let mut param_candidate = None;
for c in param_candidates {
if is_global(c) {
has_global_bounds = true;
} else if param_candidate.replace(c).is_some() {
return None;
}
}
if let Some(predicate) = param_candidate {
if has_global_bounds {
return None;
} else { return Some(ParamCandidate(predicate)); }
}
match alias_bounds.try_reduce(|(c1, k1), (c2, k2)|
{
if has_non_region_infer {
None
} else if c1 < c2 { Some((c1, k1)) } else { Some((c2, k2)) }
}) {
Some(Some((idx, kind))) =>
return Some(ProjectionCandidate { idx, kind }),
Some(None) => {}
None => return None,
}
let object_bound =
candidates.iter().filter_map(|c|
if let ObjectCandidate(i) = c.candidate {
Some(i)
} else {
None
}).try_reduce(|c1, c2|
if has_non_region_infer { None } else { Some(c1.min(c2)) });
match object_bound {
Some(Some(index)) => {
return if has_non_region_infer &&
candidates.iter().any(|c|
#[allow(non_exhaustive_omitted_patterns)] match c.candidate
{
ImplCandidate(_) => true,
_ => false,
}) {
None
} else { Some(ObjectCandidate(index)) };
}
Some(None) => {}
None => return None,
}
let upcast_bound =
candidates.iter().filter_map(|c|
{
if let TraitUpcastingUnsizeCandidate(i) = c.candidate {
Some(i)
} else { None }
}).try_reduce(|c1, c2|
if has_non_region_infer { None } else { Some(c1.min(c2)) });
match upcast_bound {
Some(Some(index)) =>
return Some(TraitUpcastingUnsizeCandidate(index)),
Some(None) => {}
None => return None,
}
let impls =
candidates.iter().filter_map(|c|
{
if let ImplCandidate(def_id) = c.candidate {
Some((def_id, c.evaluation))
} else { None }
});
let mut impl_candidate = None;
for c in impls {
if let Some(prev) = impl_candidate.replace(c) {
if self.prefer_lhs_over_victim(has_non_region_infer, c,
prev.0)
{} else if self.prefer_lhs_over_victim(has_non_region_infer,
prev, c.0) {
impl_candidate = Some(prev);
} else { return None; }
}
}
if let Some((def_id, _evaluation)) = impl_candidate {
if candidates.iter().all(|c|
match c.candidate {
SizedCandidate | BuiltinCandidate | TransmutabilityCandidate
| AutoImplCandidate | ClosureCandidate { .. } |
AsyncClosureCandidate | AsyncFnKindHelperCandidate |
CoroutineCandidate | FutureCandidate | IteratorCandidate |
AsyncIteratorCandidate | FnPointerCandidate |
TraitAliasCandidate | TraitUpcastingUnsizeCandidate(_) |
BuiltinObjectCandidate | BuiltinUnsizeCandidate |
TryAsDynCandidate | BikeshedGuaranteedNoDropCandidate =>
false,
ParamCandidate(_) | ImplCandidate(_) => true,
ProjectionCandidate { .. } | ObjectCandidate(_) =>
::core::panicking::panic("internal error: entered unreachable code"),
}) {
return Some(ImplCandidate(def_id));
} else { return None; }
}
if candidates.len() == 1 {
Some(candidates.pop().unwrap().candidate)
} else {
let mut not_a_global_where_bound =
candidates.into_iter().filter(|c|
!#[allow(non_exhaustive_omitted_patterns)] match c.candidate
{
ParamCandidate(p) if is_global(p) => true,
_ => false,
});
not_a_global_where_bound.next().map(|c|
c.candidate).filter(|_|
not_a_global_where_bound.next().is_none())
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:1809",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1809u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
1810 fn winnow_candidates(
1811 &mut self,
1812 has_non_region_infer: bool,
1813 candidate_preference_mode: CandidatePreferenceMode,
1814 mut candidates: Vec<EvaluatedCandidate<'tcx>>,
1815 ) -> Option<SelectionCandidate<'tcx>> {
1816 if candidates.len() == 1 {
1817 return Some(candidates.pop().unwrap().candidate);
1818 }
1819
1820 let mut sized_candidates =
1822 candidates.iter().filter(|c| matches!(c.candidate, SizedCandidate));
1823 if let Some(sized_candidate) = sized_candidates.next() {
1824 debug_assert_eq!(sized_candidates.next(), None);
1827 if sized_candidate.evaluation.must_apply_modulo_regions() {
1831 return Some(sized_candidate.candidate.clone());
1832 } else {
1833 return None;
1834 }
1835 }
1836
1837 'search_victim: loop {
1841 for (i, this) in candidates.iter().enumerate() {
1842 let ParamCandidate(this) = this.candidate else { continue };
1843 for (j, other) in candidates.iter().enumerate() {
1844 if i == j {
1845 continue;
1846 }
1847
1848 let ParamCandidate(other) = other.candidate else { continue };
1849 if this == other {
1850 candidates.remove(j);
1851 continue 'search_victim;
1852 }
1853
1854 if this.skip_binder().trait_ref == other.skip_binder().trait_ref
1855 && this.skip_binder().polarity == other.skip_binder().polarity
1856 && !this.skip_binder().trait_ref.has_escaping_bound_vars()
1857 {
1858 candidates.remove(j);
1859 continue 'search_victim;
1860 }
1861 }
1862 }
1863
1864 break;
1865 }
1866
1867 let mut alias_bounds = candidates.iter().filter_map(|c| {
1868 if let ProjectionCandidate { idx, kind } = c.candidate {
1869 Some((idx, kind))
1870 } else {
1871 None
1872 }
1873 });
1874 if matches!(candidate_preference_mode, CandidatePreferenceMode::Marker) {
1877 match alias_bounds
1878 .clone()
1879 .filter_map(|(idx, kind)| (kind == AliasBoundKind::SelfBounds).then_some(idx))
1880 .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) })
1881 {
1882 Some(Some(idx)) => {
1883 return Some(ProjectionCandidate { idx, kind: AliasBoundKind::SelfBounds });
1884 }
1885 Some(None) => {}
1886 None => return None,
1887 }
1888 }
1889
1890 let is_global = |c: ty::PolyTraitClause<'tcx>| c.is_global() && !c.has_bound_vars();
1897 let param_candidates = candidates
1898 .iter()
1899 .filter_map(|c| if let ParamCandidate(p) = c.candidate { Some(p) } else { None });
1900 let mut has_global_bounds = false;
1901 let mut param_candidate = None;
1902 for c in param_candidates {
1903 if is_global(c) {
1904 has_global_bounds = true;
1905 } else if param_candidate.replace(c).is_some() {
1906 return None;
1908 }
1909 }
1910 if let Some(predicate) = param_candidate {
1911 if has_global_bounds {
1913 return None;
1914 } else {
1915 return Some(ParamCandidate(predicate));
1916 }
1917 }
1918
1919 match alias_bounds.try_reduce(|(c1, k1), (c2, k2)| {
1924 if has_non_region_infer {
1925 None
1926 } else if c1 < c2 {
1927 Some((c1, k1))
1928 } else {
1929 Some((c2, k2))
1930 }
1931 }) {
1932 Some(Some((idx, kind))) => return Some(ProjectionCandidate { idx, kind }),
1933 Some(None) => {}
1934 None => return None,
1935 }
1936
1937 let object_bound = candidates
1946 .iter()
1947 .filter_map(|c| if let ObjectCandidate(i) = c.candidate { Some(i) } else { None })
1948 .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) });
1949 match object_bound {
1950 Some(Some(index)) => {
1951 return if has_non_region_infer
1952 && candidates.iter().any(|c| matches!(c.candidate, ImplCandidate(_)))
1953 {
1954 None
1955 } else {
1956 Some(ObjectCandidate(index))
1957 };
1958 }
1959 Some(None) => {}
1960 None => return None,
1961 }
1962 let upcast_bound = candidates
1964 .iter()
1965 .filter_map(|c| {
1966 if let TraitUpcastingUnsizeCandidate(i) = c.candidate { Some(i) } else { None }
1967 })
1968 .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) });
1969 match upcast_bound {
1970 Some(Some(index)) => return Some(TraitUpcastingUnsizeCandidate(index)),
1971 Some(None) => {}
1972 None => return None,
1973 }
1974
1975 let impls = candidates.iter().filter_map(|c| {
1977 if let ImplCandidate(def_id) = c.candidate {
1978 Some((def_id, c.evaluation))
1979 } else {
1980 None
1981 }
1982 });
1983 let mut impl_candidate = None;
1984 for c in impls {
1985 if let Some(prev) = impl_candidate.replace(c) {
1986 if self.prefer_lhs_over_victim(has_non_region_infer, c, prev.0) {
1987 } else if self.prefer_lhs_over_victim(has_non_region_infer, prev, c.0) {
1989 impl_candidate = Some(prev);
1991 } else {
1992 return None;
1994 }
1995 }
1996 }
1997 if let Some((def_id, _evaluation)) = impl_candidate {
1998 if candidates.iter().all(|c| match c.candidate {
2001 SizedCandidate
2002 | BuiltinCandidate
2003 | TransmutabilityCandidate
2004 | AutoImplCandidate
2005 | ClosureCandidate { .. }
2006 | AsyncClosureCandidate
2007 | AsyncFnKindHelperCandidate
2008 | CoroutineCandidate
2009 | FutureCandidate
2010 | IteratorCandidate
2011 | AsyncIteratorCandidate
2012 | FnPointerCandidate
2013 | TraitAliasCandidate
2014 | TraitUpcastingUnsizeCandidate(_)
2015 | BuiltinObjectCandidate
2016 | BuiltinUnsizeCandidate
2017 | TryAsDynCandidate
2018 | BikeshedGuaranteedNoDropCandidate => false,
2019 ParamCandidate(_) | ImplCandidate(_) => true,
2022 ProjectionCandidate { .. } | ObjectCandidate(_) => unreachable!(),
2023 }) {
2024 return Some(ImplCandidate(def_id));
2025 } else {
2026 return None;
2027 }
2028 }
2029
2030 if candidates.len() == 1 {
2031 Some(candidates.pop().unwrap().candidate)
2032 } else {
2033 let mut not_a_global_where_bound = candidates
2036 .into_iter()
2037 .filter(|c| !matches!(c.candidate, ParamCandidate(p) if is_global(p)));
2038 not_a_global_where_bound
2039 .next()
2040 .map(|c| c.candidate)
2041 .filter(|_| not_a_global_where_bound.next().is_none())
2042 }
2043 }
2044
2045 fn prefer_lhs_over_victim(
2046 &self,
2047 has_non_region_infer: bool,
2048 (lhs, lhs_evaluation): (DefId, EvaluationResult),
2049 victim: DefId,
2050 ) -> bool {
2051 let tcx = self.tcx();
2052 if lhs_evaluation.must_apply_modulo_regions() {
2059 if tcx.specializes((lhs, victim)) {
2060 return true;
2061 }
2062 }
2063
2064 match tcx.impls_are_allowed_to_overlap(lhs, victim) {
2065 Some(ty::ImplOverlapKind::Permitted { marker: false }) => {
2068 lhs_evaluation.must_apply_considering_regions()
2069 }
2070 Some(ty::ImplOverlapKind::Permitted { marker: true }) => {
2071 !has_non_region_infer && lhs_evaluation.must_apply_considering_regions()
2111 }
2112 None => false,
2113 }
2114 }
2115}
2116
2117impl<'tcx> SelectionContext<'_, 'tcx> {
2118 fn sizedness_conditions(
2119 &mut self,
2120 self_ty: Ty<'tcx>,
2121 sizedness: SizedTraitKind,
2122 ) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
2123 match self_ty.kind() {
2124 ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2125 | ty::Uint(_)
2126 | ty::Int(_)
2127 | ty::Bool
2128 | ty::Float(_)
2129 | ty::FnDef(..)
2130 | ty::FnPtr(..)
2131 | ty::RawPtr(..)
2132 | ty::Char
2133 | ty::Ref(..)
2134 | ty::Coroutine(..)
2135 | ty::CoroutineWitness(..)
2136 | ty::Array(..)
2137 | ty::Closure(..)
2138 | ty::CoroutineClosure(..)
2139 | ty::Never
2140 | ty::Error(_) => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2141
2142 ty::Str | ty::Slice(_) | ty::Dynamic(..) => match sizedness {
2143 SizedTraitKind::Sized => {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("tried to assemble `Sized` for unsized type")));
}unreachable!("tried to assemble `Sized` for unsized type"),
2144 SizedTraitKind::MetaSized => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2145 },
2146
2147 ty::Foreign(..) => {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("tried to assemble `Sized` for unsized type")));
}unreachable!("tried to assemble `Sized` for unsized type"),
2148
2149 ty::Tuple(tys) => {
2150 ty::Binder::dummy(tys.last().map_or_else(Vec::new, |&last| ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[last]))vec![last]))
2151 }
2152
2153 ty::Pat(ty, _) => ty::Binder::dummy(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[*ty]))vec![*ty]),
2154
2155 ty::Adt(def, args) => {
2156 if let Some(crit) = def.sizedness_constraint(self.tcx(), sizedness) {
2157 ty::Binder::dummy(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[crit.instantiate(self.tcx(), args).skip_norm_wip()]))vec![crit.instantiate(self.tcx(), args).skip_norm_wip()])
2158 } else {
2159 ty::Binder::dummy(::alloc::vec::Vec::new()vec![])
2160 }
2161 }
2162
2163 ty::UnsafeBinder(binder_ty) => binder_ty.map_bound(|ty| ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[ty]))vec![ty]),
2164
2165 ty::Alias(..)
2166 | ty::Param(_)
2167 | ty::Placeholder(..)
2168 | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_))
2169 | ty::Bound(..) => {
2170 ::rustc_middle::util::bug::bug_fmt(format_args!("asked to assemble `Sized` of unexpected type: {0:?}",
self_ty));bug!("asked to assemble `Sized` of unexpected type: {:?}", self_ty);
2171 }
2172 }
2173 }
2174
2175 fn copy_clone_conditions(&mut self, self_ty: Ty<'tcx>) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
2176 match *self_ty.kind() {
2177 ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2178
2179 ty::Uint(_)
2180 | ty::Int(_)
2181 | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2182 | ty::Bool
2183 | ty::Float(_)
2184 | ty::Char
2185 | ty::RawPtr(..)
2186 | ty::Never
2187 | ty::Ref(_, _, hir::Mutability::Not)
2188 | ty::Array(..) => {
2189 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("tried to assemble `Sized` for type with libcore-provided impl")));
}unreachable!("tried to assemble `Sized` for type with libcore-provided impl")
2190 }
2191
2192 ty::UnsafeBinder(_) => {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("tried to assemble `Sized` for unsafe binder")));
}unreachable!("tried to assemble `Sized` for unsafe binder"),
2195
2196 ty::Tuple(tys) => {
2197 ty::Binder::dummy(tys.iter().collect())
2199 }
2200
2201 ty::Pat(ty, _) => {
2202 ty::Binder::dummy(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[ty]))vec![ty])
2204 }
2205
2206 ty::Coroutine(def_id, args) => match self.tcx().coroutine_movability(def_id) {
2207 hir::Movability::Static => {
2208 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("tried to assemble `Clone` for static coroutine")));
}unreachable!("tried to assemble `Clone` for static coroutine")
2209 }
2210 hir::Movability::Movable => {
2211 if self.tcx().features().coroutine_clone() {
2212 ty::Binder::dummy(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[args.as_coroutine().tupled_upvars_ty(),
Ty::new_coroutine_witness_for_coroutine(self.tcx(), def_id,
args)]))vec![
2213 args.as_coroutine().tupled_upvars_ty(),
2214 Ty::new_coroutine_witness_for_coroutine(self.tcx(), def_id, args),
2215 ])
2216 } else {
2217 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("tried to assemble `Clone` for coroutine without enabled feature")));
}unreachable!(
2218 "tried to assemble `Clone` for coroutine without enabled feature"
2219 )
2220 }
2221 }
2222 },
2223
2224 ty::CoroutineWitness(def_id, args) => self
2225 .infcx
2226 .tcx
2227 .coroutine_hidden_types(def_id)
2228 .instantiate(self.infcx.tcx, args)
2229 .skip_norm_wip()
2230 .map_bound(|witness| witness.types.to_vec()),
2231
2232 ty::Closure(_, args) => ty::Binder::dummy(args.as_closure().upvar_tys().to_vec()),
2233
2234 ty::CoroutineClosure(_, args) => {
2235 ty::Binder::dummy(args.as_coroutine_closure().upvar_tys().to_vec())
2236 }
2237
2238 ty::Foreign(..)
2239 | ty::Str
2240 | ty::Slice(_)
2241 | ty::Dynamic(..)
2242 | ty::Adt(..)
2243 | ty::Alias(..)
2244 | ty::Param(..)
2245 | ty::Placeholder(..)
2246 | ty::Bound(..)
2247 | ty::Ref(_, _, ty::Mutability::Mut)
2248 | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2249 ::rustc_middle::util::bug::bug_fmt(format_args!("asked to assemble builtin bounds of unexpected type: {0:?}",
self_ty));bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
2250 }
2251 }
2252 }
2253
2254 fn coroutine_is_gen(&mut self, self_ty: Ty<'tcx>) -> bool {
2255 #[allow(non_exhaustive_omitted_patterns)] match *self_ty.kind() {
ty::Coroutine(did, ..) if self.tcx().coroutine_is_gen(did) => true,
_ => false,
}matches!(*self_ty.kind(), ty::Coroutine(did, ..)
2256 if self.tcx().coroutine_is_gen(did))
2257 }
2258
2259 {}
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("constituent_types_for_auto_trait",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2270u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("t")
}> =
::tracing::__macro_support::FieldName::new("t");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&t)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<ty::Binder<'tcx, AutoImplConstituents<'tcx>>,
SelectionError<'tcx>> = loop {};
return __tracing_attr_fake_return;
}
{
Ok(match *t.kind() {
ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) |
ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) |
ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) | ty::Never |
ty::Char => {
ty::Binder::dummy(AutoImplConstituents {
types: ::alloc::vec::Vec::new(),
assumptions: ::alloc::vec::Vec::new(),
})
}
ty::Foreign(..) => {
ty::Binder::dummy(AutoImplConstituents {
types: ::alloc::vec::Vec::new(),
assumptions: ::alloc::vec::Vec::new(),
})
}
ty::UnsafeBinder(ty) => {
ty.map_bound(|ty|
AutoImplConstituents {
types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[ty])),
assumptions: ::alloc::vec::Vec::new(),
})
}
ty::Str =>
ty::Binder::dummy(AutoImplConstituents {
types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[Ty::new_slice(self.tcx(), self.tcx().types.u8)])),
assumptions: ::alloc::vec::Vec::new(),
}),
ty::Placeholder(..) | ty::Dynamic(..) | ty::Param(..) |
ty::Alias(_, ty::AliasTy {
kind: ty::Projection { .. } | ty::Inherent { .. } |
ty::Free { .. }, .. }) | ty::Bound(..) |
ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_)
| ty::FreshFloatTy(_)) => {
::rustc_middle::util::bug::bug_fmt(format_args!("asked to assemble constituent types of unexpected type: {0:?}",
t));
}
ty::RawPtr(element_ty, _) | ty::Ref(_, element_ty, _) => {
ty::Binder::dummy(AutoImplConstituents {
types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[element_ty])),
assumptions: ::alloc::vec::Vec::new(),
})
}
ty::Pat(ty, _) | ty::Array(ty, _) | ty::Slice(ty) => {
ty::Binder::dummy(AutoImplConstituents {
types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[ty])),
assumptions: ::alloc::vec::Vec::new(),
})
}
ty::Tuple(tys) => {
ty::Binder::dummy(AutoImplConstituents {
types: tys.iter().collect(),
assumptions: ::alloc::vec::Vec::new(),
})
}
ty::Closure(_, args) => {
let ty =
self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
ty::Binder::dummy(AutoImplConstituents {
types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[ty])),
assumptions: ::alloc::vec::Vec::new(),
})
}
ty::CoroutineClosure(_, args) => {
let ty =
self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
ty::Binder::dummy(AutoImplConstituents {
types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[ty])),
assumptions: ::alloc::vec::Vec::new(),
})
}
ty::Coroutine(def_id, args) => {
let ty =
self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
let tcx = self.tcx();
let witness =
Ty::new_coroutine_witness_for_coroutine(tcx, def_id, args);
ty::Binder::dummy(AutoImplConstituents {
types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[ty, witness])),
assumptions: ::alloc::vec::Vec::new(),
})
}
ty::CoroutineWitness(def_id, args) =>
self.infcx.tcx.coroutine_hidden_types(def_id).instantiate(self.infcx.tcx,
args).skip_norm_wip().map_bound(|witness|
AutoImplConstituents {
types: witness.types.to_vec(),
assumptions: witness.assumptions.to_vec(),
}),
ty::Adt(def, args) if def.is_phantom_data() => {
ty::Binder::dummy(AutoImplConstituents {
types: args.types().collect(),
assumptions: ::alloc::vec::Vec::new(),
})
}
ty::Adt(def, args) =>
ty::Binder::dummy(AutoImplConstituents {
types: def.all_fields().map(|f|
f.ty(self.tcx(), args).skip_norm_wip()).collect(),
assumptions: ::alloc::vec::Vec::new(),
}),
ty::Alias(_, ty::AliasTy {
kind: ty::Opaque { def_id }, args, .. }) => {
if self.infcx.can_define_opaque_ty(def_id) {
::core::panicking::panic("internal error: entered unreachable code")
} else {
let ty = self.tcx().type_of_opaque(def_id);
ty::Binder::dummy(AutoImplConstituents {
types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[ty.instantiate(self.tcx(), args).skip_norm_wip()])),
assumptions: ::alloc::vec::Vec::new(),
})
}
}
})
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2270",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2270u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
2271 fn constituent_types_for_auto_trait(
2272 &self,
2273 t: Ty<'tcx>,
2274 ) -> Result<ty::Binder<'tcx, AutoImplConstituents<'tcx>>, SelectionError<'tcx>> {
2275 Ok(match *t.kind() {
2276 ty::Uint(_)
2277 | ty::Int(_)
2278 | ty::Bool
2279 | ty::Float(_)
2280 | ty::FnDef(..)
2281 | ty::FnPtr(..)
2282 | ty::Error(_)
2283 | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2284 | ty::Never
2285 | ty::Char => {
2286 ty::Binder::dummy(AutoImplConstituents { types: vec![], assumptions: vec![] })
2287 }
2288
2289 ty::Foreign(..) => {
2293 ty::Binder::dummy(AutoImplConstituents { types: vec![], assumptions: vec![] })
2294 }
2295
2296 ty::UnsafeBinder(ty) => {
2297 ty.map_bound(|ty| AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2298 }
2299
2300 ty::Str => ty::Binder::dummy(AutoImplConstituents {
2302 types: vec![Ty::new_slice(self.tcx(), self.tcx().types.u8)],
2303 assumptions: vec![],
2304 }),
2305
2306 ty::Placeholder(..)
2307 | ty::Dynamic(..)
2308 | ty::Param(..)
2309 | ty::Alias(
2310 _,
2311 ty::AliasTy {
2312 kind: ty::Projection { .. } | ty::Inherent { .. } | ty::Free { .. },
2313 ..
2314 },
2315 )
2316 | ty::Bound(..)
2317 | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2318 bug!("asked to assemble constituent types of unexpected type: {:?}", t);
2319 }
2320
2321 ty::RawPtr(element_ty, _) | ty::Ref(_, element_ty, _) => {
2322 ty::Binder::dummy(AutoImplConstituents {
2323 types: vec![element_ty],
2324 assumptions: vec![],
2325 })
2326 }
2327
2328 ty::Pat(ty, _) | ty::Array(ty, _) | ty::Slice(ty) => {
2329 ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2330 }
2331
2332 ty::Tuple(tys) => {
2333 ty::Binder::dummy(AutoImplConstituents {
2335 types: tys.iter().collect(),
2336 assumptions: vec![],
2337 })
2338 }
2339
2340 ty::Closure(_, args) => {
2341 let ty = self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
2342 ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2343 }
2344
2345 ty::CoroutineClosure(_, args) => {
2346 let ty = self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
2347 ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2348 }
2349
2350 ty::Coroutine(def_id, args) => {
2351 let ty = self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
2352 let tcx = self.tcx();
2353 let witness = Ty::new_coroutine_witness_for_coroutine(tcx, def_id, args);
2354 ty::Binder::dummy(AutoImplConstituents {
2355 types: vec![ty, witness],
2356 assumptions: vec![],
2357 })
2358 }
2359
2360 ty::CoroutineWitness(def_id, args) => self
2361 .infcx
2362 .tcx
2363 .coroutine_hidden_types(def_id)
2364 .instantiate(self.infcx.tcx, args)
2365 .skip_norm_wip()
2366 .map_bound(|witness| AutoImplConstituents {
2367 types: witness.types.to_vec(),
2368 assumptions: witness.assumptions.to_vec(),
2369 }),
2370
2371 ty::Adt(def, args) if def.is_phantom_data() => {
2373 ty::Binder::dummy(AutoImplConstituents {
2374 types: args.types().collect(),
2375 assumptions: vec![],
2376 })
2377 }
2378
2379 ty::Adt(def, args) => ty::Binder::dummy(AutoImplConstituents {
2380 types: def.all_fields().map(|f| f.ty(self.tcx(), args).skip_norm_wip()).collect(),
2381 assumptions: vec![],
2382 }),
2383
2384 ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) => {
2385 if self.infcx.can_define_opaque_ty(def_id) {
2386 unreachable!()
2387 } else {
2388 let ty = self.tcx().type_of_opaque(def_id);
2392 ty::Binder::dummy(AutoImplConstituents {
2393 types: vec![ty.instantiate(self.tcx(), args).skip_norm_wip()],
2394 assumptions: vec![],
2395 })
2396 }
2397 }
2398 })
2399 }
2400
2401 fn collect_predicates_for_types(
2402 &mut self,
2403 param_env: ty::ParamEnv<'tcx>,
2404 cause: ObligationCause<'tcx>,
2405 recursion_depth: usize,
2406 trait_def_id: DefId,
2407 types: Vec<Ty<'tcx>>,
2408 ) -> PredicateObligations<'tcx> {
2409 types
2424 .into_iter()
2425 .flat_map(|placeholder_ty| {
2426 let Normalized { value: normalized_ty, mut obligations } = normalize_with_depth(
2427 self,
2428 param_env,
2429 cause.clone(),
2430 recursion_depth,
2431 Unnormalized::new_wip(placeholder_ty),
2432 );
2433
2434 let tcx = self.tcx();
2435 let trait_ref = if tcx.generics_of(trait_def_id).own_params.len() == 1 {
2436 ty::TraitRef::new(tcx, trait_def_id, [normalized_ty])
2437 } else {
2438 let err_args = ty::GenericArgs::extend_with_error(
2441 tcx,
2442 trait_def_id,
2443 &[normalized_ty.into()],
2444 );
2445 ty::TraitRef::new_from_args(tcx, trait_def_id, err_args)
2446 };
2447
2448 let obligation = Obligation::new(self.tcx(), cause.clone(), param_env, trait_ref);
2449 obligations.push(obligation);
2450 obligations
2451 })
2452 .collect()
2453 }
2454
2455 fn rematch_impl(
2466 &mut self,
2467 impl_def_id: DefId,
2468 obligation: &PolyTraitObligation<'tcx>,
2469 ) -> Normalized<'tcx, GenericArgsRef<'tcx>> {
2470 let impl_trait_header = self.tcx().impl_trait_header(impl_def_id);
2471 match self.match_impl(impl_def_id, impl_trait_header, obligation) {
2472 Ok(args) => args,
2473 Err(()) => {
2474 let predicate = self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
2475 ::rustc_middle::util::bug::bug_fmt(format_args!("impl {0:?} was matchable against {1:?} but now is not",
impl_def_id, predicate))bug!("impl {impl_def_id:?} was matchable against {predicate:?} but now is not")
2476 }
2477 }
2478 }
2479
2480 {}
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("match_impl",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2480u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("impl_def_id")
}> =
::tracing::__macro_support::FieldName::new("impl_def_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("impl_trait_header")
}> =
::tracing::__macro_support::FieldName::new("impl_trait_header");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_def_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_trait_header)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<Normalized<'tcx, GenericArgsRef<'tcx>>, ()> =
loop {};
return __tracing_attr_fake_return;
}
{
let placeholder_obligation =
self.infcx.enter_forall_and_leak_universe(obligation.predicate);
let placeholder_obligation_trait_ref =
placeholder_obligation.trait_ref;
let impl_args =
self.infcx.fresh_args_for_item(obligation.cause.span,
impl_def_id);
let trait_ref =
impl_trait_header.trait_ref.instantiate(self.tcx(),
impl_args);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2494",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2494u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("impl_trait_header")
}> =
::tracing::__macro_support::FieldName::new("impl_trait_header");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_trait_header)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let mut nested_obligations = PredicateObligations::new();
let impl_trait_ref =
normalize_with_depth_to(self, obligation.param_env,
obligation.cause.clone(), obligation.recursion_depth + 1,
trait_ref, &mut nested_obligations);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2506",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2506u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("impl_trait_ref")
}> =
::tracing::__macro_support::FieldName::new("impl_trait_ref");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("placeholder_obligation_trait_ref")
}> =
::tracing::__macro_support::FieldName::new("placeholder_obligation_trait_ref");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_trait_ref)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&placeholder_obligation_trait_ref)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
let cause =
ObligationCause::new(obligation.cause.span,
obligation.cause.body_def_id,
ObligationCauseCode::MatchImpl(obligation.cause.clone(),
impl_def_id));
let InferOk { obligations, .. } =
self.infcx.at(&cause,
obligation.param_env).eq(DefineOpaqueTypes::No,
placeholder_obligation_trait_ref,
impl_trait_ref).map_err(|e|
{
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2519",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2519u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("match_impl: failed eq_trait_refs due to `{0}`",
e.to_string(self.tcx())) as &dyn ::tracing::field::Value))])
});
} else { ; }
}
})?;
nested_obligations.extend(obligations);
match self.typing_mode() {
TypingMode::Reflection if
!self.tcx().impl_is_fully_generic_for_reflection(impl_def_id)
=> {
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2527",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2527u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("reflection mode only allows fully generic impls")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
return Err(());
}
TypingMode::Coherence | TypingMode::Typeck { .. } |
TypingMode::PostTypeckUntilBorrowck { .. } |
TypingMode::PostBorrowck { .. } | TypingMode::Codegen |
TypingMode::ErasedNotCoherence(_) | TypingMode::Reflection |
TypingMode::PostAnalysis => {}
}
Ok(Normalized {
value: impl_args,
obligations: nested_obligations,
})
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2480",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2480u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
2481 fn match_impl(
2482 &mut self,
2483 impl_def_id: DefId,
2484 impl_trait_header: ty::ImplTraitHeader<'tcx>,
2485 obligation: &PolyTraitObligation<'tcx>,
2486 ) -> Result<Normalized<'tcx, GenericArgsRef<'tcx>>, ()> {
2487 let placeholder_obligation =
2488 self.infcx.enter_forall_and_leak_universe(obligation.predicate);
2489 let placeholder_obligation_trait_ref = placeholder_obligation.trait_ref;
2490
2491 let impl_args = self.infcx.fresh_args_for_item(obligation.cause.span, impl_def_id);
2492
2493 let trait_ref = impl_trait_header.trait_ref.instantiate(self.tcx(), impl_args);
2494 debug!(?impl_trait_header);
2495
2496 let mut nested_obligations = PredicateObligations::new();
2497 let impl_trait_ref = normalize_with_depth_to(
2498 self,
2499 obligation.param_env,
2500 obligation.cause.clone(),
2501 obligation.recursion_depth + 1,
2502 trait_ref,
2503 &mut nested_obligations,
2504 );
2505
2506 debug!(?impl_trait_ref, ?placeholder_obligation_trait_ref);
2507
2508 let cause = ObligationCause::new(
2509 obligation.cause.span,
2510 obligation.cause.body_def_id,
2511 ObligationCauseCode::MatchImpl(obligation.cause.clone(), impl_def_id),
2512 );
2513
2514 let InferOk { obligations, .. } = self
2515 .infcx
2516 .at(&cause, obligation.param_env)
2517 .eq(DefineOpaqueTypes::No, placeholder_obligation_trait_ref, impl_trait_ref)
2518 .map_err(|e| {
2519 debug!("match_impl: failed eq_trait_refs due to `{}`", e.to_string(self.tcx()))
2520 })?;
2521 nested_obligations.extend(obligations);
2522
2523 match self.typing_mode() {
2524 TypingMode::Reflection
2525 if !self.tcx().impl_is_fully_generic_for_reflection(impl_def_id) =>
2526 {
2527 debug!("reflection mode only allows fully generic impls");
2528 return Err(());
2529 }
2530
2531 TypingMode::Coherence
2532 | TypingMode::Typeck { .. }
2533 | TypingMode::PostTypeckUntilBorrowck { .. }
2534 | TypingMode::PostBorrowck { .. }
2535 | TypingMode::Codegen
2536 | TypingMode::ErasedNotCoherence(_)
2537 | TypingMode::Reflection
2538 | TypingMode::PostAnalysis => {}
2539 }
2540
2541 Ok(Normalized { value: impl_args, obligations: nested_obligations })
2542 }
2543
2544 fn match_upcast_principal(
2545 &mut self,
2546 obligation: &PolyTraitObligation<'tcx>,
2547 unnormalized_upcast_principal: ty::Unnormalized<'tcx, ty::PolyTraitRef<'tcx>>,
2548 a_data: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
2549 b_data: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
2550 a_region: ty::Region<'tcx>,
2551 b_region: ty::Region<'tcx>,
2552 ) -> SelectionResult<'tcx, PredicateObligations<'tcx>> {
2553 let tcx = self.tcx();
2554 let mut nested = PredicateObligations::new();
2555
2556 let a_auto_traits: FxIndexSet<DefId> = a_data
2560 .auto_traits()
2561 .chain(
2562 a_data
2563 .principal_def_id()
2564 .map(|principal_def_id| {
2565 elaborate::supertrait_def_ids(tcx, principal_def_id)
2566 .filter(|def_id| tcx.trait_is_auto(*def_id))
2567 })
2568 .into_flat_iter(),
2569 )
2570 .collect();
2571
2572 let upcast_principal = normalize_with_depth_to(
2573 self,
2574 obligation.param_env,
2575 obligation.cause.clone(),
2576 obligation.recursion_depth + 1,
2577 unnormalized_upcast_principal,
2578 &mut nested,
2579 );
2580
2581 for bound in b_data {
2582 match bound.skip_binder() {
2583 ty::ExistentialPredicate::Trait(target_principal) => {
2586 let hr_source_principal = upcast_principal.map_bound(|trait_ref| {
2587 ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
2588 });
2589 let hr_target_principal = bound.rebind(target_principal);
2590
2591 nested.extend(
2592 self.infcx
2593 .enter_forall(hr_target_principal, |target_principal| {
2594 let source_principal =
2595 self.infcx.instantiate_binder_with_fresh_vars(
2596 obligation.cause.span,
2597 HigherRankedType,
2598 hr_source_principal,
2599 );
2600 self.infcx.at(&obligation.cause, obligation.param_env).eq_trace(
2601 DefineOpaqueTypes::Yes,
2602 ToTrace::to_trace(
2603 &obligation.cause,
2604 hr_target_principal,
2605 hr_source_principal,
2606 ),
2607 target_principal,
2608 source_principal,
2609 )
2610 })
2611 .map_err(|_| SelectionError::Unimplemented)?
2612 .into_obligations(),
2613 );
2614 }
2615 ty::ExistentialPredicate::Projection(target_projection) => {
2621 let hr_target_projection = bound.rebind(target_projection);
2622
2623 let mut matching_projections =
2624 a_data.projection_bounds().filter(|&hr_source_projection| {
2625 hr_source_projection.item_def_id() == hr_target_projection.item_def_id()
2628 && self.infcx.probe(|_| {
2629 self.infcx
2630 .enter_forall(hr_target_projection, |target_projection| {
2631 let source_projection =
2632 self.infcx.instantiate_binder_with_fresh_vars(
2633 obligation.cause.span,
2634 HigherRankedType,
2635 hr_source_projection,
2636 );
2637 self.infcx
2638 .at(&obligation.cause, obligation.param_env)
2639 .eq_trace(
2640 DefineOpaqueTypes::Yes,
2641 ToTrace::to_trace(
2642 &obligation.cause,
2643 hr_target_projection,
2644 hr_source_projection,
2645 ),
2646 target_projection,
2647 source_projection,
2648 )
2649 })
2650 .is_ok()
2651 })
2652 });
2653
2654 let Some(hr_source_projection) = matching_projections.next() else {
2655 return Err(SelectionError::Unimplemented);
2656 };
2657 if matching_projections.next().is_some() {
2658 return Ok(None);
2659 }
2660 nested.extend(
2661 self.infcx
2662 .enter_forall(hr_target_projection, |target_projection| {
2663 let source_projection =
2664 self.infcx.instantiate_binder_with_fresh_vars(
2665 obligation.cause.span,
2666 HigherRankedType,
2667 hr_source_projection,
2668 );
2669 self.infcx.at(&obligation.cause, obligation.param_env).eq_trace(
2670 DefineOpaqueTypes::Yes,
2671 ToTrace::to_trace(
2672 &obligation.cause,
2673 hr_target_projection,
2674 hr_source_projection,
2675 ),
2676 target_projection,
2677 source_projection,
2678 )
2679 })
2680 .map_err(|_| SelectionError::Unimplemented)?
2681 .into_obligations(),
2682 );
2683 }
2684 ty::ExistentialPredicate::AutoTrait(def_id) => {
2686 if !a_auto_traits.contains(&def_id) {
2687 return Err(SelectionError::Unimplemented);
2688 }
2689 }
2690 }
2691 }
2692
2693 nested.push(Obligation::with_depth(
2694 tcx,
2695 obligation.cause.clone(),
2696 obligation.recursion_depth + 1,
2697 obligation.param_env,
2698 ty::Binder::dummy(ty::OutlivesClause(a_region, b_region)),
2699 ));
2700
2701 Ok(Some(nested))
2702 }
2703
2704 fn match_where_clause_trait_ref(
2708 &mut self,
2709 obligation: &PolyTraitObligation<'tcx>,
2710 where_clause_trait_ref: ty::PolyTraitRef<'tcx>,
2711 ) -> Result<PredicateObligations<'tcx>, ()> {
2712 self.match_poly_trait_ref(obligation, where_clause_trait_ref)
2713 }
2714
2715 {}
#[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("match_poly_trait_ref",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2717u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("poly_trait_ref")
}> =
::tracing::__macro_support::FieldName::new("poly_trait_ref");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&poly_trait_ref)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<PredicateObligations<'tcx>, ()> = loop {};
return __tracing_attr_fake_return;
}
{
let predicate =
self.infcx.enter_forall_and_leak_universe(obligation.predicate);
let trait_ref =
self.infcx.instantiate_binder_with_fresh_vars(obligation.cause.span,
HigherRankedType, poly_trait_ref);
self.infcx.at(&obligation.cause,
obligation.param_env).eq(DefineOpaqueTypes::No,
predicate.trait_ref,
trait_ref).map(|InferOk { obligations, .. }|
obligations).map_err(|_| ())
}
}
}#[instrument(skip(self), level = "debug")]
2718 fn match_poly_trait_ref(
2719 &mut self,
2720 obligation: &PolyTraitObligation<'tcx>,
2721 poly_trait_ref: ty::PolyTraitRef<'tcx>,
2722 ) -> Result<PredicateObligations<'tcx>, ()> {
2723 let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
2724 let trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
2725 obligation.cause.span,
2726 HigherRankedType,
2727 poly_trait_ref,
2728 );
2729 self.infcx
2730 .at(&obligation.cause, obligation.param_env)
2731 .eq(DefineOpaqueTypes::No, predicate.trait_ref, trait_ref)
2732 .map(|InferOk { obligations, .. }| obligations)
2733 .map_err(|_| ())
2734 }
2735
2736 fn match_fresh_trait_preds(
2740 &self,
2741 previous: ty::PolyTraitClause<'tcx>,
2742 current: ty::PolyTraitClause<'tcx>,
2743 ) -> bool {
2744 let mut matcher = _match::MatchAgainstFreshVars::new(self.tcx());
2745 matcher.relate(previous, current).is_ok()
2746 }
2747
2748 fn push_stack<'o>(
2749 &mut self,
2750 previous_stack: TraitObligationStackList<'o, 'tcx>,
2751 obligation: &'o PolyTraitObligation<'tcx>,
2752 ) -> TraitObligationStack<'o, 'tcx> {
2753 let fresh_trait_pred = obligation.predicate.fold_with(&mut self.freshener);
2754
2755 let dfn = previous_stack.cache.next_dfn();
2756 let depth = previous_stack.depth() + 1;
2757 TraitObligationStack {
2758 obligation,
2759 fresh_trait_pred,
2760 reached_depth: Cell::new(depth),
2761 previous: previous_stack,
2762 dfn,
2763 depth,
2764 }
2765 }
2766
2767 {}
#[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("closure_trait_ref_unnormalized",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2767u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("self_ty")
}> =
::tracing::__macro_support::FieldName::new("self_ty");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fn_trait_def_id")
}> =
::tracing::__macro_support::FieldName::new("fn_trait_def_id");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_trait_def_id)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: ty::PolyTraitRef<'tcx> = loop {};
return __tracing_attr_fake_return;
}
{
let ty::Closure(_, args) =
*self_ty.kind() else {
::rustc_middle::util::bug::bug_fmt(format_args!("expected closure, found {0}",
self_ty));
};
let closure_sig = args.as_closure().sig();
closure_trait_ref_and_return_type(self.tcx(), fn_trait_def_id,
self_ty, closure_sig,
util::TupleArgumentsFlag::No).map_bound(|(trait_ref, _)|
trait_ref)
}
}
}#[instrument(skip(self), level = "debug")]
2768 fn closure_trait_ref_unnormalized(
2769 &mut self,
2770 self_ty: Ty<'tcx>,
2771 fn_trait_def_id: DefId,
2772 ) -> ty::PolyTraitRef<'tcx> {
2773 let ty::Closure(_, args) = *self_ty.kind() else {
2774 bug!("expected closure, found {self_ty}");
2775 };
2776 let closure_sig = args.as_closure().sig();
2777
2778 closure_trait_ref_and_return_type(
2779 self.tcx(),
2780 fn_trait_def_id,
2781 self_ty,
2782 closure_sig,
2783 util::TupleArgumentsFlag::No,
2784 )
2785 .map_bound(|(trait_ref, _)| trait_ref)
2786 }
2787
2788 {}
#[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("impl_or_trait_obligations",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2792u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("recursion_depth")
}> =
::tracing::__macro_support::FieldName::new("recursion_depth");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("def_id")
}> =
::tracing::__macro_support::FieldName::new("def_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("args")
}> =
::tracing::__macro_support::FieldName::new("args");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("parent_trait_pred")
}> =
::tracing::__macro_support::FieldName::new("parent_trait_pred");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&recursion_depth
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&def_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&parent_trait_pred)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: PredicateObligations<'tcx> =
loop {};
return __tracing_attr_fake_return;
}
{
let tcx = self.tcx();
let clauses = tcx.clauses_of(def_id);
{
match (&clauses.parent, &None) {
(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);
}
}
}
};
let clauses = clauses.instantiate_own(tcx, args);
let mut obligations =
PredicateObligations::with_capacity(clauses.len());
for (index, (clause, span)) in clauses.into_iter().enumerate() {
let cause =
if tcx.is_lang_item(parent_trait_pred.def_id(),
LangItem::CoerceUnsized) {
cause.clone()
} else {
cause.clone().derived_cause(parent_trait_pred,
|derived|
{
ObligationCauseCode::ImplDerived(Box::new(ImplDerivedCause {
derived,
impl_or_alias_def_id: def_id,
impl_def_clause_index: Some(index),
span,
}))
})
};
let clause =
normalize_with_depth_to(self, param_env, cause.clone(),
recursion_depth, clause, &mut obligations);
obligations.push(Obligation {
cause,
recursion_depth,
param_env,
predicate: clause.as_predicate(),
});
}
if tcx.def_kind(def_id) == (DefKind::Impl { of_trait: true }) {
for clause in
tcx.impl_super_outlives(def_id).iter_instantiated(tcx, args)
{
let clause =
normalize_with_depth_to(self, param_env, cause.clone(),
recursion_depth, clause, &mut obligations);
obligations.push(Obligation {
cause: cause.clone(),
recursion_depth,
param_env,
predicate: clause.as_predicate(),
});
}
}
obligations
}
}
}#[instrument(level = "debug", skip(self, cause, param_env))]
2793 fn impl_or_trait_obligations(
2794 &mut self,
2795 cause: &ObligationCause<'tcx>,
2796 recursion_depth: usize,
2797 param_env: ty::ParamEnv<'tcx>,
2798 def_id: DefId, args: GenericArgsRef<'tcx>, parent_trait_pred: ty::Binder<'tcx, ty::TraitClause<'tcx>>,
2801 ) -> PredicateObligations<'tcx> {
2802 let tcx = self.tcx();
2803
2804 let clauses = tcx.clauses_of(def_id);
2819 assert_eq!(clauses.parent, None);
2820 let clauses = clauses.instantiate_own(tcx, args);
2821 let mut obligations = PredicateObligations::with_capacity(clauses.len());
2822 for (index, (clause, span)) in clauses.into_iter().enumerate() {
2823 let cause = if tcx.is_lang_item(parent_trait_pred.def_id(), LangItem::CoerceUnsized) {
2824 cause.clone()
2825 } else {
2826 cause.clone().derived_cause(parent_trait_pred, |derived| {
2827 ObligationCauseCode::ImplDerived(Box::new(ImplDerivedCause {
2828 derived,
2829 impl_or_alias_def_id: def_id,
2830 impl_def_clause_index: Some(index),
2831 span,
2832 }))
2833 })
2834 };
2835 let clause = normalize_with_depth_to(
2836 self,
2837 param_env,
2838 cause.clone(),
2839 recursion_depth,
2840 clause,
2841 &mut obligations,
2842 );
2843 obligations.push(Obligation {
2844 cause,
2845 recursion_depth,
2846 param_env,
2847 predicate: clause.as_predicate(),
2848 });
2849 }
2850
2851 if tcx.def_kind(def_id) == (DefKind::Impl { of_trait: true }) {
2853 for clause in tcx.impl_super_outlives(def_id).iter_instantiated(tcx, args) {
2854 let clause = normalize_with_depth_to(
2855 self,
2856 param_env,
2857 cause.clone(),
2858 recursion_depth,
2859 clause,
2860 &mut obligations,
2861 );
2862 obligations.push(Obligation {
2863 cause: cause.clone(),
2864 recursion_depth,
2865 param_env,
2866 predicate: clause.as_predicate(),
2867 });
2868 }
2869 }
2870
2871 obligations
2872 }
2873
2874 pub(super) fn should_stall_coroutine(&self, def_id: DefId) -> bool {
2875 match self.typing_mode() {
2876 TypingMode::Typeck { defining_opaque_types_and_generators: stalled_generators } => {
2877 def_id.as_local().is_some_and(|def_id| stalled_generators.contains(&def_id))
2878 }
2879 TypingMode::Coherence
2880 | TypingMode::PostAnalysis
2881 | TypingMode::Reflection
2882 | TypingMode::Codegen
2883 | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types: _ }
2884 | TypingMode::PostBorrowck { defined_opaque_types: _ } => false,
2885 }
2886 }
2887}
2888
2889impl<'o, 'tcx> TraitObligationStack<'o, 'tcx> {
2890 fn list(&'o self) -> TraitObligationStackList<'o, 'tcx> {
2891 TraitObligationStackList::with(self)
2892 }
2893
2894 fn cache(&self) -> &'o ProvisionalEvaluationCache<'tcx> {
2895 self.previous.cache
2896 }
2897
2898 fn iter(&'o self) -> TraitObligationStackList<'o, 'tcx> {
2899 self.list()
2900 }
2901
2902 fn update_reached_depth(&self, reached_depth: usize) {
2905 if !(self.depth >= reached_depth) {
{
::core::panicking::panic_fmt(format_args!("invoked `update_reached_depth` with something under this stack: self.depth={0} reached_depth={1}",
self.depth, reached_depth));
}
};assert!(
2906 self.depth >= reached_depth,
2907 "invoked `update_reached_depth` with something under this stack: \
2908 self.depth={} reached_depth={}",
2909 self.depth,
2910 reached_depth,
2911 );
2912 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2912",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2912u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("reached_depth")
}> =
::tracing::__macro_support::FieldName::new("reached_depth");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("update_reached_depth")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&reached_depth as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(reached_depth, "update_reached_depth");
2913 let mut p = self;
2914 while reached_depth < p.depth {
2915 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:2915",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2915u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("p.fresh_trait_pred")
}> =
::tracing::__macro_support::FieldName::new("p.fresh_trait_pred");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("update_reached_depth: marking as cycle participant")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&p.fresh_trait_pred)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?p.fresh_trait_pred, "update_reached_depth: marking as cycle participant");
2916 p.reached_depth.set(p.reached_depth.get().min(reached_depth));
2917 p = p.previous.head.unwrap();
2918 }
2919 }
2920}
2921
2922struct ProvisionalEvaluationCache<'tcx> {
2976 dfn: Cell<usize>,
2978
2979 map: RefCell<FxIndexMap<ty::PolyTraitClause<'tcx>, ProvisionalEvaluation>>,
2995
2996 wf_args: RefCell<Vec<(ty::Term<'tcx>, usize)>>,
3004}
3005
3006#[derive(#[automatically_derived]
impl ::core::marker::Copy for ProvisionalEvaluation { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ProvisionalEvaluation { }
#[automatically_derived]
impl ::core::clone::Clone for ProvisionalEvaluation {
#[inline]
fn clone(&self) -> ProvisionalEvaluation {
let _: ::core::clone::AssertParamIsClone<usize>;
let _: ::core::clone::AssertParamIsClone<EvaluationResult>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ProvisionalEvaluation {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"ProvisionalEvaluation", "from_dfn", &self.from_dfn,
"reached_depth", &self.reached_depth, "result", &&self.result)
}
}Debug)]
3009struct ProvisionalEvaluation {
3010 from_dfn: usize,
3011 reached_depth: usize,
3012 result: EvaluationResult,
3013}
3014
3015impl<'tcx> Default for ProvisionalEvaluationCache<'tcx> {
3016 fn default() -> Self {
3017 Self { dfn: Cell::new(0), map: Default::default(), wf_args: Default::default() }
3018 }
3019}
3020
3021impl<'tcx> ProvisionalEvaluationCache<'tcx> {
3022 fn next_dfn(&self) -> usize {
3024 let result = self.dfn.get();
3025 self.dfn.set(result + 1);
3026 result
3027 }
3028
3029 fn get_provisional(
3034 &self,
3035 fresh_trait_pred: ty::PolyTraitClause<'tcx>,
3036 ) -> Option<ProvisionalEvaluation> {
3037 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3037",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3037u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fresh_trait_pred")
}> =
::tracing::__macro_support::FieldName::new("fresh_trait_pred");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("get_provisional = {0:#?}",
self.map.borrow().get(&fresh_trait_pred)) as
&dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fresh_trait_pred)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
3038 ?fresh_trait_pred,
3039 "get_provisional = {:#?}",
3040 self.map.borrow().get(&fresh_trait_pred),
3041 );
3042 Some(*self.map.borrow().get(&fresh_trait_pred)?)
3043 }
3044
3045 fn insert_provisional(
3050 &self,
3051 from_dfn: usize,
3052 reached_depth: usize,
3053 fresh_trait_pred: ty::PolyTraitClause<'tcx>,
3054 result: EvaluationResult,
3055 ) {
3056 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3056",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3056u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("from_dfn")
}> =
::tracing::__macro_support::FieldName::new("from_dfn");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fresh_trait_pred")
}> =
::tracing::__macro_support::FieldName::new("fresh_trait_pred");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("result")
}> =
::tracing::__macro_support::FieldName::new("result");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("insert_provisional")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&from_dfn)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fresh_trait_pred)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&result)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?from_dfn, ?fresh_trait_pred, ?result, "insert_provisional");
3057
3058 let mut map = self.map.borrow_mut();
3059
3060 for (_k, v) in &mut *map {
3075 if v.from_dfn >= from_dfn {
3076 v.reached_depth = reached_depth.min(v.reached_depth);
3077 }
3078 }
3079
3080 map.insert(fresh_trait_pred, ProvisionalEvaluation { from_dfn, reached_depth, result });
3081 }
3082
3083 fn on_failure(&self, dfn: usize) {
3092 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3092",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3092u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("dfn")
}> =
::tracing::__macro_support::FieldName::new("dfn");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("on_failure")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dfn)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?dfn, "on_failure");
3093 self.map.borrow_mut().retain(|key, eval| {
3094 if !eval.from_dfn >= dfn {
3095 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3095",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3095u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("on_failure: removing {0:?}",
key) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("on_failure: removing {:?}", key);
3096 false
3097 } else {
3098 true
3099 }
3100 });
3101 }
3102
3103 fn on_completion(&self, dfn: usize) {
3141 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3141",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3141u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("dfn")
}> =
::tracing::__macro_support::FieldName::new("dfn");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("on_completion")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dfn)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?dfn, "on_completion");
3142 self.map.borrow_mut().retain(|fresh_trait_pred, eval| {
3143 if eval.from_dfn >= dfn {
3144 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs:3144",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/809936eac66c547a5127ce1da805f0d3a6789b98/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3144u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message",
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fresh_trait_pred")
}> =
::tracing::__macro_support::FieldName::new("fresh_trait_pred");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("eval")
}> =
::tracing::__macro_support::FieldName::new("eval");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("on_completion")
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fresh_trait_pred)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&eval)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(?fresh_trait_pred, ?eval, "on_completion");
3145 return false;
3146 }
3147 true
3148 });
3149 }
3150}
3151
3152#[derive(#[automatically_derived]
impl<'o, 'tcx> ::core::marker::Copy for TraitObligationStackList<'o, 'tcx> { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl<'o, 'tcx> ::core::clone::TrivialClone for
TraitObligationStackList<'o, 'tcx> {
}
#[automatically_derived]
impl<'o, 'tcx> ::core::clone::Clone for TraitObligationStackList<'o, 'tcx> {
#[inline]
fn clone(&self) -> TraitObligationStackList<'o, 'tcx> {
let _:
::core::clone::AssertParamIsClone<&'o ProvisionalEvaluationCache<'tcx>>;
let _:
::core::clone::AssertParamIsClone<Option<&'o TraitObligationStack<'o,
'tcx>>>;
*self
}
}Clone)]
3153struct TraitObligationStackList<'o, 'tcx> {
3154 cache: &'o ProvisionalEvaluationCache<'tcx>,
3155 head: Option<&'o TraitObligationStack<'o, 'tcx>>,
3156}
3157
3158impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> {
3159 fn empty(cache: &'o ProvisionalEvaluationCache<'tcx>) -> TraitObligationStackList<'o, 'tcx> {
3160 TraitObligationStackList { cache, head: None }
3161 }
3162
3163 fn with(r: &'o TraitObligationStack<'o, 'tcx>) -> TraitObligationStackList<'o, 'tcx> {
3164 TraitObligationStackList { cache: r.cache(), head: Some(r) }
3165 }
3166
3167 fn head(&self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
3168 self.head
3169 }
3170
3171 fn depth(&self) -> usize {
3172 if let Some(head) = self.head { head.depth } else { 0 }
3173 }
3174}
3175
3176impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> {
3177 type Item = &'o TraitObligationStack<'o, 'tcx>;
3178
3179 fn next(&mut self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
3180 let o = self.head?;
3181 *self = o.previous;
3182 Some(o)
3183 }
3184}
3185
3186impl<'o, 'tcx> fmt::Debug for TraitObligationStack<'o, 'tcx> {
3187 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3188 f.write_fmt(format_args!("TraitObligationStack({0:?})", self.obligation))write!(f, "TraitObligationStack({:?})", self.obligation)
3189 }
3190}
3191
3192pub(crate) enum ProjectionMatchesProjection {
3193 Yes,
3194 Ambiguous,
3195 No,
3196}
3197
3198#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for AutoImplConstituents<'tcx> {
#[inline]
fn clone(&self) -> AutoImplConstituents<'tcx> {
AutoImplConstituents {
types: ::core::clone::Clone::clone(&self.types),
assumptions: ::core::clone::Clone::clone(&self.assumptions),
}
}
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for AutoImplConstituents<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"AutoImplConstituents", "types", &self.types, "assumptions",
&&self.assumptions)
}
}Debug, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for AutoImplConstituents<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
AutoImplConstituents {
types: __binding_0, assumptions: __binding_1 } => {
AutoImplConstituents {
types: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
assumptions: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
AutoImplConstituents {
types: __binding_0, assumptions: __binding_1 } => {
AutoImplConstituents {
types: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
assumptions: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for AutoImplConstituents<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
AutoImplConstituents {
types: ref __binding_0, assumptions: ref __binding_1 } => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
3199pub(crate) struct AutoImplConstituents<'tcx> {
3200 pub types: Vec<Ty<'tcx>>,
3201 pub assumptions: Vec<ty::ArgOutlivesClause<'tcx>>,
3202}