1use std::cell::{Cell, RefCell};
6use std::cmp;
7use std::fmt::{self, Display};
8use std::ops::ControlFlow;
9
10use hir::def::DefKind;
11use rustc_attr_ir::lang_items::LangItem;
12use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
13use rustc_errors::Diag;
14use rustc_hir as hir;
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::dep_graph::{DepKind, DepNodeIndex};
23pub use rustc_middle::traits::select::*;
24use rustc_middle::ty::abstract_const::NotConstEvaluatable;
25use rustc_middle::ty::error::TypeErrorToStringExt;
26use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths};
27use rustc_middle::ty::{
28 self, CallerBoundsIterator, CandidatePreferenceMode, CantBeErased, DeepRejectCtxt, GenericArgs,
29 PolyProjectionClause, SizedTraitKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, TypingMode,
30 Unnormalized, Upcast, elaborate, may_use_unstable_feature,
31};
32use rustc_next_trait_solver::solve::AliasBoundKind;
33use rustc_span::bug;
34use tracing::{debug, instrument, trace};
35
36use self::EvaluationResult::*;
37use self::SelectionCandidate::*;
38use super::project::ProjectionTermObligation;
39use super::util::closure_trait_ref_and_return_type;
40use super::{
41 ImplDerivedCause, Normalized, Obligation, ObligationCause, ObligationCauseCode,
42 PolyTraitObligation, PredicateObligation, Selection, SelectionError, SelectionResult,
43 TraitQueryMode, const_evaluatable, project, util, wf,
44};
45use crate::error_reporting::InferCtxtErrorExt;
46use crate::infer::{InferCtxt, InferOk, TypeFreshener};
47use crate::solve::InferCtxtSelectExt as _;
48use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to};
49use crate::traits::project::{ProjectAndUnifyResult, ProjectionCacheKeyExt};
50use crate::traits::{EvaluateConstErr, ProjectionCacheKey, effects, implicit_fast_path};
51
52mod _match;
53mod candidate_assembly;
54mod confirmation;
55
56#[derive(#[automatically_derived]impl<'tcx> ::core::clone::Clone for
IntercrateAmbiguityCause<'tcx> {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
match self {
Self::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),
},
Self::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]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::DownstreamCrate { trait_ref: __self_0, self_ty: __self_1 }
=>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DownstreamCrate trait_ref self_ty", __self_0, &__self_1),
Self::UpstreamCrateUpdate { trait_ref: __self_0, self_ty: __self_1
} =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"UpstreamCrateUpdate trait_ref self_ty", __self_0,
&__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: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::DownstreamCrate {
trait_ref: __self_0, self_ty: __self_1 },
Self::DownstreamCrate {
trait_ref: __arg1_0, self_ty: __arg1_1 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(Self::UpstreamCrateUpdate {
trait_ref: __self_0, self_ty: __self_1 },
Self::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) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::DownstreamCrate { trait_ref: __self_0, self_ty: __self_1 }
=> {
::core::hash::Hash::hash(__self_0, state);
::core::hash::Hash::hash(__self_1, state)
}
Self::UpstreamCrateUpdate { trait_ref: __self_0, self_ty: __self_1
} => {
::core::hash::Hash::hash(__self_0, state);
::core::hash::Hash::hash(__self_1, state)
}
}
}
}Hash)]
57pub enum IntercrateAmbiguityCause<'tcx> {
58 DownstreamCrate { trait_ref: ty::TraitRef<'tcx>, self_ty: Option<Ty<'tcx>> },
59 UpstreamCrateUpdate { trait_ref: ty::TraitRef<'tcx>, self_ty: Option<Ty<'tcx>> },
60}
61
62impl<'tcx> IntercrateAmbiguityCause<'tcx> {
63 pub fn add_intercrate_ambiguity_hint(&self, err: &mut Diag<'_>) {
66 err.note(self.intercrate_ambiguity_hint());
67 }
68
69 pub fn intercrate_ambiguity_hint(&self) -> String {
70 {
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 {
71 IntercrateAmbiguityCause::DownstreamCrate { trait_ref, self_ty } => {
72 format!(
73 "downstream crates may implement trait `{trait_desc}`{self_desc}",
74 trait_desc = trait_ref.print_trait_sugared(),
75 self_desc = if let Some(self_ty) = self_ty {
76 format!(" for type `{self_ty}`")
77 } else {
78 String::new()
79 }
80 )
81 }
82 IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_ref, self_ty } => {
83 format!(
84 "upstream crates may add a new impl of trait `{trait_desc}`{self_desc} \
85 in future versions",
86 trait_desc = trait_ref.print_trait_sugared(),
87 self_desc = if let Some(self_ty) = self_ty {
88 format!(" for type `{self_ty}`")
89 } else {
90 String::new()
91 }
92 )
93 }
94 })
95 }
96}
97
98pub struct SelectionContext<'cx, 'tcx> {
99 pub infcx: &'cx InferCtxt<'tcx>,
100
101 freshener: TypeFreshener<'cx, 'tcx>,
107
108 query_mode: TraitQueryMode,
112}
113
114struct TraitObligationStack<'prev, 'tcx> {
116 obligation: &'prev PolyTraitObligation<'tcx>,
117
118 fresh_trait_pred: ty::PolyTraitClause<'tcx>,
121
122 reached_depth: Cell<usize>,
151
152 previous: TraitObligationStackList<'prev, 'tcx>,
153
154 depth: usize,
156
157 dfn: usize,
160}
161
162struct SelectionCandidateSet<'tcx> {
163 vec: Vec<SelectionCandidate<'tcx>>,
166
167 ambiguous: bool,
172}
173
174#[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: &Self) -> 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]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"EvaluatedCandidate candidate evaluation", &self.candidate,
&&self.evaluation)
}
}Debug, #[automatically_derived]impl<'tcx> ::core::clone::Clone for
EvaluatedCandidate<'tcx> {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
EvaluatedCandidate {
candidate: ::core::clone::Clone::clone(&self.candidate),
evaluation: ::core::clone::Clone::clone(&self.evaluation),
}
}
}Clone)]
175struct EvaluatedCandidate<'tcx> {
176 candidate: SelectionCandidate<'tcx>,
177 evaluation: EvaluationResult,
178}
179
180impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
181 pub fn new(infcx: &'cx InferCtxt<'tcx>) -> SelectionContext<'cx, 'tcx> {
182 SelectionContext {
183 infcx,
184 freshener: TypeFreshener::new(infcx),
185 query_mode: TraitQueryMode::Standard,
186 }
187 }
188
189 pub fn typing_mode(&self) -> TypingMode<'tcx, CantBeErased> {
190 self.infcx.typing_mode_raw().assert_not_erased()
191 }
192
193 pub fn with_query_mode(
194 infcx: &'cx InferCtxt<'tcx>,
195 query_mode: TraitQueryMode,
196 ) -> SelectionContext<'cx, 'tcx> {
197 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:197",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(197u32),
::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");
198 SelectionContext { query_mode, ..SelectionContext::new(infcx) }
199 }
200
201 pub fn tcx(&self) -> TyCtxt<'tcx> {
202 self.infcx.tcx
203 }
204
205 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(222u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:222",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(222u32),
::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)]
223 pub fn poly_select(
224 &mut self,
225 obligation: &PolyTraitObligation<'tcx>,
226 ) -> SelectionResult<'tcx, Selection<'tcx>> {
227 if self.infcx.next_trait_solver() {
228 return self.infcx.select_in_new_trait_solver(obligation);
229 }
230
231 let candidate = match self.select_from_obligation(obligation) {
232 Err(SelectionError::Overflow(OverflowError::Canonical)) => {
233 assert!(self.query_mode == TraitQueryMode::Canonical);
236 return Err(SelectionError::Overflow(OverflowError::Canonical));
237 }
238 Err(e) => {
239 return Err(e);
240 }
241 Ok(None) => {
242 return Ok(None);
243 }
244 Ok(Some(candidate)) => candidate,
245 };
246
247 match self.confirm_candidate(obligation, candidate) {
248 Err(SelectionError::Overflow(OverflowError::Canonical)) => {
249 assert!(self.query_mode == TraitQueryMode::Canonical);
250 Err(SelectionError::Overflow(OverflowError::Canonical))
251 }
252 Err(e) => Err(e),
253 Ok(ImplSource::Builtin(..)) if self.typing_mode().is_reflection() => {
254 Err(SelectionError::Unimplemented)
257 }
258 Ok(candidate) => Ok(Some(candidate)),
259 }
260 }
261
262 pub fn select(
263 &mut self,
264 obligation: &TraitObligation<'tcx>,
265 ) -> SelectionResult<'tcx, Selection<'tcx>> {
266 self.poly_select(&Obligation {
267 cause: obligation.cause.clone(),
268 param_env: obligation.param_env,
269 predicate: ty::Binder::dummy(obligation.predicate),
270 recursion_depth: obligation.recursion_depth,
271 })
272 }
273
274 fn select_from_obligation(
275 &mut self,
276 obligation: &PolyTraitObligation<'tcx>,
277 ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
278 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());
279
280 let pec = &ProvisionalEvaluationCache::default();
281 let stack = self.push_stack(TraitObligationStackList::empty(pec), obligation);
282
283 self.candidate_from_obligation(&stack)
284 }
285
286 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(286u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:302",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(302u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:308",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(308u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:321",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(321u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:286",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(286u32),
::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)]
287 fn candidate_from_obligation<'o>(
288 &mut self,
289 stack: &TraitObligationStack<'o, 'tcx>,
290 ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
291 debug_assert!(!self.infcx.next_trait_solver());
292 self.check_recursion_limit(stack.obligation, stack.obligation)?;
295
296 let cache_fresh_trait_pred =
301 stack.obligation.predicate.fold_with(&mut TypeFreshener::new(self.infcx));
302 debug!(?cache_fresh_trait_pred);
303 debug_assert!(!stack.obligation.predicate.has_escaping_bound_vars());
304
305 if let Some(c) =
306 self.check_candidate_cache(stack.obligation.param_env, cache_fresh_trait_pred)
307 {
308 debug!("CACHE HIT");
309 return c;
310 }
311
312 let (candidate, dep_node) =
319 self.in_task(|this| this.candidate_from_obligation_no_cache(stack));
320
321 debug!("CACHE MISS");
322 self.insert_candidate_cache(
323 stack.obligation.param_env,
324 cache_fresh_trait_pred,
325 dep_node,
326 candidate.clone(),
327 );
328 candidate
329 }
330
331 fn candidate_from_obligation_no_cache<'o>(
332 &mut self,
333 stack: &TraitObligationStack<'o, 'tcx>,
334 ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
335 let candidate_set = self.assemble_candidates(stack)?;
336
337 if candidate_set.ambiguous {
338 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:338",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(338u32),
::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");
339 return Ok(None);
340 }
341
342 let candidates = candidate_set.vec;
343
344 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:344",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(344u32),
::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());
345
346 let mut candidates = self.filter_impls(candidates, stack.obligation);
356
357 if candidates.len() == 1 {
372 return Ok(candidates.pop());
373 }
374
375 let candidates = candidates
378 .into_iter()
379 .map(|c| match self.evaluate_candidate(stack, &c) {
380 Ok(eval) if eval.may_apply() => {
381 Ok(Some(EvaluatedCandidate { candidate: c, evaluation: eval }))
382 }
383 Ok(_) => Ok(None),
384 Err(OverflowError::Canonical) => {
385 Err(SelectionError::Overflow(OverflowError::Canonical))
386 }
387 Err(OverflowError::Error(e)) => {
388 Err(SelectionError::Overflow(OverflowError::Error(e)))
389 }
390 })
391 .flat_map(Result::transpose)
392 .collect::<Result<Vec<_>, _>>()?;
393
394 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:394",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(394u32),
::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());
395 if candidates.is_empty() {
405 if stack.obligation.predicate.references_error() {
410 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:410",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(410u32),
::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");
411 Ok(None)
412 } else {
413 Err(SelectionError::Unimplemented)
414 }
415 } else {
416 let has_non_region_infer = stack.obligation.predicate.has_non_region_infer();
417 let candidate_preference_mode =
418 CandidatePreferenceMode::compute(self.tcx(), stack.obligation.predicate.def_id());
419 Ok(self.winnow_candidates(has_non_region_infer, candidate_preference_mode, candidates))
420 }
421 }
422
423 pub fn evaluate_root_obligation(
439 &mut self,
440 obligation: &PredicateObligation<'tcx>,
441 ) -> Result<EvaluationResult, OverflowError> {
442 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());
443 self.evaluation_probe(|this| {
444 let goal = this
445 .infcx
446 .deeply_resolve_ignoring_regions((obligation.predicate, obligation.param_env));
447 let mut result = this.evaluate_predicate_recursively(
448 TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
449 obligation.clone(),
450 )?;
451 if this.infcx.deeply_resolve_ignoring_regions(goal) != goal {
454 result = result.max(EvaluatedToAmbig);
455 }
456 Ok(result)
457 })
458 }
459
460 fn evaluation_probe(
466 &mut self,
467 op: impl FnOnce(&mut Self) -> Result<EvaluationResult, OverflowError>,
468 ) -> Result<EvaluationResult, OverflowError> {
469 self.infcx.probe(|snapshot| -> Result<EvaluationResult, OverflowError> {
470 let outer_universe = self.infcx.universe();
471 let result = op(self)?;
472
473 match self.infcx.leak_check(outer_universe, Some(snapshot)) {
474 Ok(()) => {}
475 Err(_) => return Ok(EvaluatedToErr),
476 }
477
478 if self.infcx.opaque_types_added_in_snapshot(snapshot) {
479 return Ok(result.max(EvaluatedToOkModuloOpaqueTypes));
480 }
481
482 if self.infcx.region_constraints_added_in_snapshot(snapshot) {
483 Ok(result.max(EvaluatedToOkModuloRegions))
484 } else {
485 Ok(result)
486 }
487 })
488 }
489
490 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(494u32),
::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)?;
if let EvaluatedToErr = eval {
return Ok(EvaluatedToErr);
} else { result = cmp::max(result, eval); }
}
Ok(result)
}
}
}#[instrument(skip(self, stack), level = "debug")]
495 fn evaluate_predicates_recursively<'o, I>(
496 &mut self,
497 stack: TraitObligationStackList<'o, 'tcx>,
498 predicates: I,
499 ) -> Result<EvaluationResult, OverflowError>
500 where
501 I: IntoIterator<Item = PredicateObligation<'tcx>> + std::fmt::Debug,
502 {
503 let mut result = EvaluatedToOk;
504 for mut obligation in predicates {
505 obligation.set_depth_from_parent(stack.depth());
506 let eval = self.evaluate_predicate_recursively(stack, obligation)?;
507 if let EvaluatedToErr = eval {
508 return Ok(EvaluatedToErr);
511 } else {
512 result = cmp::max(result, eval);
513 }
514 }
515 Ok(result)
516 }
517
518 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(518u32),
::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() &&
implicit_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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:623",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(623u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:800",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(800u32),
::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_span::macros::bug_impl(None,
format_args!("NormalizesTo is only used by the new solver"),
Location::caller())
}
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_span::macros::bug_impl(None,
format_args!("placeholder const {0:?} in old solver", ct),
Location::caller())
}
ty::ConstKind::Bound(_, _) =>
::rustc_span::macros::bug_impl(None,
format_args!("escaping bound vars in {0:?}", ct),
Location::caller()),
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),
}
}
ty::PredicateKind::Clause(ty::ClauseKind::CompressedTrait(_))
=> ::core::panicking::unreachable_default_msg(),
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:518",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(518u32),
::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(
519 level = "debug",
520 skip(self, previous_stack),
521 fields(previous_stack = ?previous_stack.head())
522 ret,
523 )]
524 fn evaluate_predicate_recursively<'o>(
525 &mut self,
526 previous_stack: TraitObligationStackList<'o, 'tcx>,
527 obligation: PredicateObligation<'tcx>,
528 ) -> Result<EvaluationResult, OverflowError> {
529 debug_assert!(!self.infcx.next_trait_solver());
530 match previous_stack.head() {
535 Some(h) => self.check_recursion_limit(&obligation, h.obligation)?,
536 None => self.check_recursion_limit(&obligation, &obligation)?,
537 }
538
539 if !self.infcx.disable_trait_solver_fast_paths()
540 && implicit_fast_path(self.tcx(), obligation.predicate, obligation.param_env)
541 {
542 return Ok(EvaluatedToOk);
543 }
544
545 let bound_predicate = obligation.predicate.kind();
546 match bound_predicate.skip_binder() {
547 ty::PredicateKind::Clause(ty::ClauseKind::Trait(t)) => {
548 let t = bound_predicate.rebind(t);
549 debug_assert!(!t.has_escaping_bound_vars());
550 let obligation = obligation.with(self.tcx(), t);
551 self.evaluate_trait_predicate_recursively(previous_stack, obligation)
552 }
553
554 ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(data)) => {
555 self.infcx.enter_forall(bound_predicate.rebind(data), |data| {
556 match effects::evaluate_host_effect_obligation(
557 self,
558 &obligation.with(self.tcx(), data),
559 ) {
560 Ok(nested) => self.evaluate_predicates_recursively(previous_stack, nested),
561 Err(effects::EvaluationFailure::Ambiguous) => Ok(EvaluatedToAmbig),
562 Err(effects::EvaluationFailure::NoSolution) => Ok(EvaluatedToErr),
563 }
564 })
565 }
566
567 ty::PredicateKind::Subtype(p) => {
568 let p = bound_predicate.rebind(p);
569 match self.infcx.subtype_predicate(&obligation.cause, obligation.param_env, p) {
571 Ok(Ok(InferOk { obligations, .. })) => {
572 self.evaluate_predicates_recursively(previous_stack, obligations)
573 }
574 Ok(Err(_)) => Ok(EvaluatedToErr),
575 Err(..) => Ok(EvaluatedToAmbig),
576 }
577 }
578
579 ty::PredicateKind::Coerce(p) => {
580 let p = bound_predicate.rebind(p);
581 match self.infcx.coerce_predicate(&obligation.cause, obligation.param_env, p) {
583 Ok(Ok(InferOk { obligations, .. })) => {
584 self.evaluate_predicates_recursively(previous_stack, obligations)
585 }
586 Ok(Err(_)) => Ok(EvaluatedToErr),
587 Err(..) => Ok(EvaluatedToAmbig),
588 }
589 }
590
591 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
592 if term.is_trivially_wf(self.tcx()) {
593 return Ok(EvaluatedToOk);
594 }
595
596 let cache = previous_stack.cache;
617 let dfn = cache.next_dfn();
618
619 for stack_term in previous_stack.cache.wf_args.borrow().iter().rev() {
620 if stack_term.0 != term {
621 continue;
622 }
623 debug!("WellFormed({:?}) on stack", term);
624 if let Some(stack) = previous_stack.head {
625 let cycle = stack.iter().take_while(|s| s.depth > stack_term.1);
640 let tcx = self.tcx();
641 let cycle = cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
642 if self.coinductive_match(cycle) {
643 stack.update_reached_depth(stack_term.1);
644 return Ok(EvaluatedToOk);
645 } else {
646 return Ok(EvaluatedToAmbigStackDependent);
647 }
648 }
649 return Ok(EvaluatedToOk);
650 }
651
652 match wf::obligations(
653 self.infcx,
654 obligation.param_env,
655 obligation.cause.body_def_id,
656 obligation.recursion_depth + 1,
657 term,
658 obligation.cause.span,
659 ) {
660 Some(obligations) => {
661 cache.wf_args.borrow_mut().push((term, previous_stack.depth()));
662 let result =
663 self.evaluate_predicates_recursively(previous_stack, obligations);
664 cache.wf_args.borrow_mut().pop();
665
666 let result = result?;
667
668 if !result.must_apply_modulo_regions() {
669 cache.on_failure(dfn);
670 }
671
672 cache.on_completion(dfn);
673
674 Ok(result)
675 }
676 None => Ok(EvaluatedToAmbig),
677 }
678 }
679
680 ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(pred)) => {
681 if pred.0.has_free_regions()
684 || pred.0.has_bound_regions()
685 || pred.0.has_non_region_infer()
686 || pred.0.has_non_region_param()
687 {
688 Ok(EvaluatedToOkModuloRegions)
689 } else {
690 Ok(EvaluatedToOk)
691 }
692 }
693
694 ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..)) => {
695 Ok(EvaluatedToOkModuloRegions)
697 }
698
699 ty::PredicateKind::DynCompatible(trait_def_id) => {
700 if self.tcx().is_dyn_compatible(trait_def_id) {
705 Ok(EvaluatedToOk)
706 } else {
707 Ok(EvaluatedToErr)
708 }
709 }
710
711 ty::PredicateKind::Clause(ty::ClauseKind::Projection(data)) => {
712 let data = bound_predicate.rebind(data);
713 let project_obligation = obligation.with(self.tcx(), data);
714 match project::poly_project_and_unify_term(self, &project_obligation) {
715 ProjectAndUnifyResult::Holds(mut subobligations) => {
716 'compute_res: {
717 if let Some(key) = ProjectionCacheKey::from_poly_projection_obligation(
722 self,
723 &project_obligation,
724 ) && let Some(cached_res) =
725 self.infcx.inner.borrow_mut().projection_cache().is_complete(key)
726 {
727 break 'compute_res Ok(cached_res);
728 }
729
730 for subobligation in subobligations.iter_mut() {
736 subobligation.set_depth_from_parent(obligation.recursion_depth);
737 }
738 let res = self
739 .evaluate_predicates_recursively(previous_stack, subobligations);
740 if let Ok(eval_rslt) = res
741 && (eval_rslt == EvaluatedToOk
742 || eval_rslt == EvaluatedToOkModuloRegions)
743 && let Some(key) =
744 ProjectionCacheKey::from_poly_projection_obligation(
745 self,
746 &project_obligation,
747 )
748 {
749 self.infcx
754 .inner
755 .borrow_mut()
756 .projection_cache()
757 .complete(key, eval_rslt);
758 }
759 res
760 }
761 }
762 ProjectAndUnifyResult::FailedNormalization => Ok(EvaluatedToAmbig),
763 ProjectAndUnifyResult::Recursive => Ok(EvaluatedToAmbigStackDependent),
764 ProjectAndUnifyResult::MismatchedProjectionTypes(_) => Ok(EvaluatedToErr),
765 }
766 }
767
768 ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
769 if may_use_unstable_feature(self.infcx, obligation.param_env, symbol) {
770 Ok(EvaluatedToOk)
771 } else {
772 Ok(EvaluatedToAmbig)
773 }
774 }
775
776 ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(alias_const)) => {
777 match const_evaluatable::is_const_evaluatable(
778 self.infcx,
779 alias_const,
780 obligation.param_env,
781 obligation.cause.span,
782 ) {
783 Ok(()) => Ok(EvaluatedToOk),
784 Err(NotConstEvaluatable::MentionsInfer) => Ok(EvaluatedToAmbig),
785 Err(NotConstEvaluatable::MentionsParam) => Ok(EvaluatedToErr),
786 Err(_) => Ok(EvaluatedToErr),
787 }
788 }
789
790 ty::PredicateKind::ConstEquate(c1, c2) => {
791 let tcx = self.tcx();
792 assert!(
793 tcx.features().generic_const_exprs(),
794 "`ConstEquate` without a feature gate: {c1:?} {c2:?}",
795 );
796
797 {
798 let c1 = tcx.expand_abstract_consts(c1);
799 let c2 = tcx.expand_abstract_consts(c2);
800 debug!(
801 "evaluate_predicate_recursively: equating consts:\nc1= {:?}\nc2= {:?}",
802 c1, c2
803 );
804
805 match (c1.kind(), c2.kind()) {
806 (ty::ConstKind::Alias(_, a), ty::ConstKind::Alias(_, b))
807 if a.kind == b.kind
808 && matches!(
809 a.kind,
810 ty::AliasConstKind::Projection { .. }
811 | ty::AliasConstKind::InherentSelf { .. }
812 | ty::AliasConstKind::InherentImpl { .. }
813 ) =>
814 {
815 if let Ok(InferOk { obligations, value: () }) = self
816 .infcx
817 .at(&obligation.cause, obligation.param_env)
818 .eq(
821 DefineOpaqueTypes::Yes,
822 ty::AliasTerm::from(a),
823 ty::AliasTerm::from(b),
824 )
825 {
826 return self
827 .evaluate_predicates_recursively(previous_stack, obligations);
828 }
829 }
830 (_, ty::ConstKind::Alias(_, _)) | (ty::ConstKind::Alias(_, _), _) => (),
831 (_, _) => {
832 if let Ok(InferOk { obligations, value: () }) = self
833 .infcx
834 .at(&obligation.cause, obligation.param_env)
835 .eq(DefineOpaqueTypes::Yes, c1, c2)
838 {
839 return self
840 .evaluate_predicates_recursively(previous_stack, obligations);
841 }
842 }
843 }
844 }
845
846 let evaluate = |c: ty::Const<'tcx>| {
847 if let ty::ConstKind::Alias(_, _) = c.kind() {
848 crate::traits::try_evaluate_const(
849 self.infcx,
850 c,
851 obligation.param_env,
852 |v| Ok::<_, !>(v.skip_norm_wip()),
853 )
854 } else {
855 Ok(c)
856 }
857 };
858
859 match (evaluate(c1), evaluate(c2)) {
860 (Ok(c1), Ok(c2)) => {
861 match self.infcx.at(&obligation.cause, obligation.param_env).eq(
862 DefineOpaqueTypes::Yes,
865 c1,
866 c2,
867 ) {
868 Ok(inf_ok) => self.evaluate_predicates_recursively(
869 previous_stack,
870 inf_ok.into_obligations(),
871 ),
872 Err(_) => Ok(EvaluatedToErr),
873 }
874 }
875 (Err(EvaluateConstErr::InvalidConstParamTy(..)), _)
876 | (_, Err(EvaluateConstErr::InvalidConstParamTy(..))) => Ok(EvaluatedToErr),
877 (Err(EvaluateConstErr::EvaluationFailure(..)), _)
878 | (_, Err(EvaluateConstErr::EvaluationFailure(..))) => Ok(EvaluatedToErr),
879 (Err(EvaluateConstErr::HasGenericsOrInfers), _)
880 | (_, Err(EvaluateConstErr::HasGenericsOrInfers)) => {
881 if c1.has_non_region_infer() || c2.has_non_region_infer() {
882 Ok(EvaluatedToAmbig)
883 } else {
884 Ok(EvaluatedToErr)
886 }
887 }
888 }
889 }
890 ty::PredicateKind::NormalizesTo(..) => {
891 bug!("NormalizesTo is only used by the new solver")
892 }
893 ty::PredicateKind::Ambiguous => Ok(EvaluatedToAmbig),
894 ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
895 let ct = self.infcx.shallow_resolve_const(ct);
896 let ct_ty = match ct.kind() {
897 ty::ConstKind::Infer(_) => {
898 return Ok(EvaluatedToAmbig);
899 }
900 ty::ConstKind::Error(_) => return Ok(EvaluatedToOk),
901 ty::ConstKind::Value(cv) => cv.ty,
902 ty::ConstKind::Alias(_, alias_const) => {
903 alias_const.type_of(self.tcx()).skip_norm_wip()
904 }
905 ty::ConstKind::Expr(_) => return Ok(EvaluatedToOk),
907 ty::ConstKind::Placeholder(_) => {
908 bug!("placeholder const {:?} in old solver", ct)
909 }
910 ty::ConstKind::Bound(_, _) => bug!("escaping bound vars in {:?}", ct),
911 ty::ConstKind::Param(param_ct) => {
912 param_ct.find_const_ty_from_env(obligation.param_env)
913 }
914 };
915
916 match self.infcx.at(&obligation.cause, obligation.param_env).eq(
917 DefineOpaqueTypes::Yes,
919 ct_ty,
920 ty,
921 ) {
922 Ok(inf_ok) => self
923 .evaluate_predicates_recursively(previous_stack, inf_ok.into_obligations()),
924 Err(_) => Ok(EvaluatedToErr),
925 }
926 }
927 ty::PredicateKind::Clause(ty::ClauseKind::CompressedTrait(_)) => unreachable!(),
928 }
929 }
930
931 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(931u32),
::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 true {
if !!self.typing_mode().is_coherence() {
{
::core::panicking::panic_fmt(format_args!("old solver coherence"));
}
};
};
if obligation.is_global() &&
obligation.param_env.caller_bounds().all_clauses(self.tcx()).iter().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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:949",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(949u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:957",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(957u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:962",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(962u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:967",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(967u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1034",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1034u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1042",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1042u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1046",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1046u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1047",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1047u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:931",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(931u32),
::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)]
932 fn evaluate_trait_predicate_recursively<'o>(
933 &mut self,
934 previous_stack: TraitObligationStackList<'o, 'tcx>,
935 mut obligation: PolyTraitObligation<'tcx>,
936 ) -> Result<EvaluationResult, OverflowError> {
937 debug_assert!(!self.typing_mode().is_coherence(), "old solver coherence");
938 if obligation.is_global()
939 && obligation
940 .param_env
941 .caller_bounds()
942 .all_clauses(self.tcx())
943 .iter()
944 .all(|bound| bound.has_param())
945 {
946 debug!("in global");
950 obligation.param_env = ty::ParamEnv::empty();
951 }
952
953 let stack = self.push_stack(previous_stack, &obligation);
954 let fresh_trait_pred = stack.fresh_trait_pred;
955 let param_env = obligation.param_env;
956
957 debug!(?fresh_trait_pred);
958
959 if let Some(result) = self.check_evaluation_cache(param_env, fresh_trait_pred) {
962 debug!("CACHE HIT");
963 return Ok(result);
964 }
965
966 if let Some(result) = stack.cache().get_provisional(fresh_trait_pred) {
967 debug!("PROVISIONAL CACHE HIT");
968 stack.update_reached_depth(result.reached_depth);
969 return Ok(result.result);
970 }
971
972 if let Some(cycle_result) = self.check_evaluation_cycle(&stack) {
978 return Ok(cycle_result);
979 }
980
981 let (result, dep_node) = self.in_task(|this| {
982 let mut result = this.evaluate_stack(&stack)?;
983
984 if EvaluationResult::EvaluatedToErr == result
992 && fresh_trait_pred.has_aliases()
993 && fresh_trait_pred.is_global()
994 {
995 let mut nested_obligations = PredicateObligations::new();
996 let predicate = normalize_with_depth_to(
997 this,
998 param_env,
999 obligation.cause.clone(),
1000 obligation.recursion_depth + 1,
1001 Unnormalized::new_wip(obligation.predicate),
1002 &mut nested_obligations,
1003 );
1004 if predicate != obligation.predicate {
1005 let mut nested_result = EvaluationResult::EvaluatedToOk;
1006 for obligation in nested_obligations {
1007 nested_result = cmp::max(
1008 this.evaluate_predicate_recursively(previous_stack, obligation)?,
1009 nested_result,
1010 );
1011 }
1012
1013 if nested_result.must_apply_modulo_regions() {
1014 let obligation = obligation.with(this.tcx(), predicate);
1015 result = cmp::max(
1016 nested_result,
1017 this.evaluate_trait_predicate_recursively(previous_stack, obligation)?,
1018 );
1019 }
1020 }
1021 }
1022
1023 Ok::<_, OverflowError>(result)
1024 });
1025
1026 let result = result?;
1027
1028 if !result.must_apply_modulo_regions() {
1029 stack.cache().on_failure(stack.dfn);
1030 }
1031
1032 let reached_depth = stack.reached_depth.get();
1033 if reached_depth >= stack.depth {
1034 debug!("CACHE MISS");
1035 self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
1036 stack.cache().on_completion(stack.dfn);
1037 } else if let Some(_guar) = self.infcx.tainted_by_errors() {
1038 debug!("CACHE MISS (tainted by errors)");
1043 self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
1044 stack.cache().on_completion(stack.dfn);
1045 } else {
1046 debug!("PROVISIONAL");
1047 debug!(
1048 "caching provisionally because {:?} \
1049 is a cycle participant (at depth {}, reached depth {})",
1050 fresh_trait_pred, stack.depth, reached_depth,
1051 );
1052
1053 stack.cache().insert_provisional(stack.dfn, reached_depth, fresh_trait_pred, result);
1054 }
1055
1056 Ok(result)
1057 }
1058
1059 fn check_evaluation_cycle(
1079 &mut self,
1080 stack: &TraitObligationStack<'_, 'tcx>,
1081 ) -> Option<EvaluationResult> {
1082 if let Some(cycle_depth) = stack
1083 .iter()
1084 .skip(1) .find(|prev| {
1086 stack.obligation.param_env == prev.obligation.param_env
1087 && stack.fresh_trait_pred == prev.fresh_trait_pred
1088 })
1089 .map(|stack| stack.depth)
1090 {
1091 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1091",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1091u32),
::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);
1092
1093 stack.update_reached_depth(cycle_depth);
1100
1101 let cycle = stack.iter().skip(1).take_while(|s| s.depth >= cycle_depth);
1107 let tcx = self.tcx();
1108 let cycle = cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
1109 if self.coinductive_match(cycle) {
1110 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1110",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1110u32),
::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");
1111 Some(EvaluatedToOk)
1112 } else {
1113 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1113",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1113u32),
::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");
1114 Some(EvaluatedToAmbigStackDependent)
1115 }
1116 } else {
1117 None
1118 }
1119 }
1120
1121 fn evaluate_stack<'o>(
1122 &mut self,
1123 stack: &TraitObligationStack<'o, 'tcx>,
1124 ) -> Result<EvaluationResult, OverflowError> {
1125 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());
1126 let unbound_input_types =
1153 stack.fresh_trait_pred.skip_binder().trait_ref.args.types().any(|ty| ty.is_fresh());
1154
1155 if unbound_input_types
1156 && stack.iter().skip(1).any(|prev| {
1157 stack.obligation.param_env == prev.obligation.param_env
1158 && self.match_fresh_trait_preds(stack.fresh_trait_pred, prev.fresh_trait_pred)
1159 })
1160 {
1161 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1161",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1161u32),
::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");
1162 return Ok(EvaluatedToAmbigStackDependent);
1163 }
1164
1165 match self.candidate_from_obligation(stack) {
1166 Ok(Some(c)) => self.evaluate_candidate(stack, &c),
1167 Ok(None) => Ok(EvaluatedToAmbig),
1168 Err(SelectionError::Overflow(OverflowError::Canonical)) => {
1169 Err(OverflowError::Canonical)
1170 }
1171 Err(..) => Ok(EvaluatedToErr),
1172 }
1173 }
1174
1175 pub(crate) fn coinductive_match<I>(&mut self, mut cycle: I) -> bool
1184 where
1185 I: Iterator<Item = ty::Predicate<'tcx>>,
1186 {
1187 cycle.all(|p| match p.kind().skip_binder() {
1188 ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
1189 self.infcx.tcx.trait_is_coinductive(data.def_id())
1190 }
1191 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => {
1192 self.infcx.tcx.features().generic_const_exprs()
1196 }
1197 _ => false,
1198 })
1199 }
1200
1201 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1204u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1218",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1218u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1204",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1204u32),
::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(
1205 level = "debug",
1206 skip(self, stack),
1207 fields(depth = stack.obligation.recursion_depth),
1208 ret
1209 )]
1210 fn evaluate_candidate<'o>(
1211 &mut self,
1212 stack: &TraitObligationStack<'o, 'tcx>,
1213 candidate: &SelectionCandidate<'tcx>,
1214 ) -> Result<EvaluationResult, OverflowError> {
1215 let mut result = self.evaluation_probe(|this| {
1216 match this.confirm_candidate(stack.obligation, candidate.clone()) {
1217 Ok(selection) => {
1218 debug!(?selection);
1219 if let ImplSource::Builtin(..) = selection
1220 && this.typing_mode().is_reflection()
1221 {
1222 return Ok(EvaluatedToErr);
1223 }
1224 this.evaluate_predicates_recursively(
1225 stack.list(),
1226 selection.nested_obligations().into_iter(),
1227 )
1228 }
1229 Err(..) => Ok(EvaluatedToErr),
1230 }
1231 })?;
1232
1233 if stack.fresh_trait_pred.has_erased_regions() {
1242 result = result.max(EvaluatedToOkModuloRegions);
1243 }
1244
1245 Ok(result)
1246 }
1247
1248 fn check_evaluation_cache(
1249 &self,
1250 param_env: ty::ParamEnv<'tcx>,
1251 trait_pred: ty::PolyTraitClause<'tcx>,
1252 ) -> Option<EvaluationResult> {
1253 let infcx = self.infcx;
1254 let tcx = infcx.tcx;
1255 if self.can_use_global_caches(param_env, trait_pred) {
1256 let key = (infcx.typing_env(param_env), trait_pred);
1257 if let Some(res) = tcx.caches.evaluation_cache.get(&key, tcx) {
1258 Some(res)
1259 } else {
1260 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);
1261 None
1262 }
1263 } else {
1264 self.infcx.evaluation_cache.get(&(param_env, trait_pred), tcx)
1265 }
1266 }
1267
1268 fn insert_evaluation_cache(
1269 &mut self,
1270 param_env: ty::ParamEnv<'tcx>,
1271 trait_pred: ty::PolyTraitClause<'tcx>,
1272 dep_node: DepNodeIndex,
1273 result: EvaluationResult,
1274 ) {
1275 if result.is_stack_dependent() {
1278 return;
1279 }
1280
1281 let infcx = self.infcx;
1282 let tcx = infcx.tcx;
1283 if self.can_use_global_caches(param_env, trait_pred) {
1284 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1284",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1284u32),
::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");
1285 tcx.caches.evaluation_cache.insert(
1287 (infcx.typing_env(param_env), trait_pred),
1288 dep_node,
1289 result,
1290 );
1291 return;
1292 } else {
1293 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1293",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1293u32),
::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");
1294 self.infcx.evaluation_cache.insert((param_env, trait_pred), dep_node, result);
1295 }
1296 }
1297
1298 fn check_recursion_depth<T>(
1299 &self,
1300 depth: usize,
1301 error_obligation: &Obligation<'tcx, T>,
1302 ) -> Result<(), OverflowError>
1303 where
1304 T: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + Clone,
1305 {
1306 if !self.infcx.tcx.recursion_limit().value_within_limit(depth) {
1307 match self.query_mode {
1308 TraitQueryMode::Standard => {
1309 if let Some(e) = self.infcx.tainted_by_errors() {
1310 return Err(OverflowError::Error(e));
1311 }
1312 self.infcx.err_ctxt().report_overflow_obligation(error_obligation, true);
1313 }
1314 TraitQueryMode::Canonical => {
1315 return Err(OverflowError::Canonical);
1316 }
1317 }
1318 }
1319 Ok(())
1320 }
1321
1322 #[inline(always)]
1327 fn check_recursion_limit<T: Display + TypeFoldable<TyCtxt<'tcx>>, V>(
1328 &self,
1329 obligation: &Obligation<'tcx, T>,
1330 error_obligation: &Obligation<'tcx, V>,
1331 ) -> Result<(), OverflowError>
1332 where
1333 V: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + Clone,
1334 {
1335 self.check_recursion_depth(obligation.recursion_depth, error_obligation)
1336 }
1337
1338 fn in_task<OP, R>(&mut self, op: OP) -> (R, DepNodeIndex)
1339 where
1340 OP: FnOnce(&mut Self) -> R,
1341 {
1342 self.tcx().dep_graph.with_anon_task(self.tcx(), DepKind::TraitSelect, || op(self))
1343 }
1344
1345 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1347u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1353",
"rustc_trait_selection::traits::select",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1353u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1370",
"rustc_trait_selection::traits::select",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1370u32),
::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))]
1348 fn filter_impls(
1349 &mut self,
1350 mut candidates: Vec<SelectionCandidate<'tcx>>,
1351 obligation: &PolyTraitObligation<'tcx>,
1352 ) -> Vec<SelectionCandidate<'tcx>> {
1353 trace!("{candidates:#?}");
1354 let tcx = self.tcx();
1355
1356 candidates.retain(|candidate| {
1357 if let &ImplCandidate(def_id) = candidate {
1358 match (tcx.impl_polarity(def_id), obligation.polarity()) {
1359 (ty::ImplPolarity::Positive, ty::ClausePolarity::Positive)
1360 | (ty::ImplPolarity::Negative, ty::ClausePolarity::Negative) => true,
1361
1362 _ => false,
1364 }
1365 } else {
1366 true
1367 }
1368 });
1369
1370 trace!("{candidates:#?}");
1371 candidates
1372 }
1373
1374 fn can_use_global_caches(
1376 &self,
1377 param_env: ty::ParamEnv<'tcx>,
1378 pred: ty::PolyTraitClause<'tcx>,
1379 ) -> bool {
1380 if param_env.has_infer() || pred.has_infer() {
1384 return false;
1385 }
1386
1387 match self.typing_mode() {
1388 TypingMode::Typeck { defining_opaque_types_and_generators: defining_opaque_types }
1397 | TypingMode::PostTypeckThroughBorrowck { defining_opaque_types } => {
1398 defining_opaque_types.is_empty()
1399 || (!pred.has_opaque_types() && !pred.has_coroutines())
1400 }
1401 TypingMode::Reflection => false,
1404 TypingMode::PostBorrowck { .. } => true,
1407 TypingMode::PostAnalysis | TypingMode::Codegen => true,
1413 TypingMode::Coherence => {
1414 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("old solver coherence")));
}unreachable!("old solver coherence")
1415 }
1416 }
1417 }
1418
1419 fn check_candidate_cache(
1420 &mut self,
1421 param_env: ty::ParamEnv<'tcx>,
1422 cache_fresh_trait_pred: ty::PolyTraitClause<'tcx>,
1423 ) -> Option<SelectionResult<'tcx, SelectionCandidate<'tcx>>> {
1424 let infcx = self.infcx;
1425 let tcx = infcx.tcx;
1426 let pred = cache_fresh_trait_pred.skip_binder();
1427
1428 if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
1429 if let Some(res) =
1430 tcx.caches.selection_cache.get(&(infcx.typing_env(param_env), pred), tcx)
1431 {
1432 return Some(res);
1433 } else if truecfg!(debug_assertions) {
1434 match infcx.selection_cache.get(&(param_env, pred), tcx) {
1435 None | Some(Err(SelectionError::Overflow(OverflowError::Canonical))) => {}
1436 res => ::rustc_span::macros::bug_impl(None,
format_args!("unexpected local cache result: {0:?}", res),
Location::caller())bug!("unexpected local cache result: {res:?}"),
1437 }
1438 }
1439 }
1440
1441 infcx.selection_cache.get(&(param_env, pred), tcx)
1445 }
1446
1447 fn can_cache_candidate(
1464 &self,
1465 result: &SelectionResult<'tcx, SelectionCandidate<'tcx>>,
1466 ) -> bool {
1467 match result {
1468 Ok(Some(SelectionCandidate::ParamCandidate(trait_ref))) => !trait_ref.has_infer(),
1469 _ => true,
1470 }
1471 }
1472
1473 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1473u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1486",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1486u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1494",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1494u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1507",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1507u32),
::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")]
1474 fn insert_candidate_cache(
1475 &mut self,
1476 param_env: ty::ParamEnv<'tcx>,
1477 cache_fresh_trait_pred: ty::PolyTraitClause<'tcx>,
1478 dep_node: DepNodeIndex,
1479 candidate: SelectionResult<'tcx, SelectionCandidate<'tcx>>,
1480 ) {
1481 let infcx = self.infcx;
1482 let tcx = infcx.tcx;
1483 let pred = cache_fresh_trait_pred.skip_binder();
1484
1485 if !self.can_cache_candidate(&candidate) {
1486 debug!(?pred, ?candidate, "insert_candidate_cache - candidate is not cacheable");
1487 return;
1488 }
1489
1490 if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
1491 if let Err(SelectionError::Overflow(OverflowError::Canonical)) = candidate {
1492 } else {
1494 debug!(?pred, ?candidate, "insert_candidate_cache global");
1495 debug_assert!(!candidate.has_infer());
1496
1497 tcx.caches.selection_cache.insert(
1499 (infcx.typing_env(param_env), pred),
1500 dep_node,
1501 candidate,
1502 );
1503 return;
1504 }
1505 }
1506
1507 debug!(?pred, ?candidate, "insert_candidate_cache local");
1508 self.infcx.selection_cache.insert((param_env, pred), dep_node, candidate);
1509 }
1510
1511 pub(super) fn for_each_item_bound<T>(
1517 &mut self,
1518 mut self_ty: Ty<'tcx>,
1519 mut for_each: impl FnMut(
1520 &mut Self,
1521 ty::Clause<'tcx>,
1522 usize,
1523 AliasBoundKind,
1524 ) -> ControlFlow<T, ()>,
1525 on_ambiguity: impl FnOnce(),
1526 ) -> ControlFlow<T, ()> {
1527 let mut idx = 0;
1528 let mut alias_bound_kind = AliasBoundKind::SelfBounds;
1529
1530 loop {
1531 let (alias_ty, def_id) = match *self_ty.kind() {
1532 ty::Alias(
1533 _,
1534 alias_ty @ ty::AliasTy {
1535 kind: ty::Projection { def_id } | ty::Opaque { def_id },
1536 ..
1537 },
1538 ) => (alias_ty, def_id),
1539 ty::Infer(ty::TyVar(_)) => {
1540 on_ambiguity();
1541 return ControlFlow::Continue(());
1542 }
1543 _ => return ControlFlow::Continue(()),
1544 };
1545
1546 let relevant_bounds = if alias_bound_kind == AliasBoundKind::NonSelfBounds {
1551 self.tcx().item_non_self_bounds(def_id)
1552 } else {
1553 self.tcx().item_self_bounds(def_id)
1554 };
1555
1556 for bound in relevant_bounds.instantiate(self.tcx(), alias_ty.args).skip_norm_wip() {
1557 for_each(self, bound, idx, alias_bound_kind)?;
1558 idx += 1;
1559 }
1560
1561 if #[allow(non_exhaustive_omitted_patterns)] match alias_ty.kind {
ty::Projection { .. } => true,
_ => false,
}matches!(alias_ty.kind, ty::Projection { .. }) {
1562 self_ty = alias_ty.self_ty();
1563 } else {
1564 return ControlFlow::Continue(());
1565 }
1566
1567 alias_bound_kind = AliasBoundKind::NonSelfBounds;
1568 }
1569 }
1570
1571 fn match_normalize_trait_ref(
1575 &mut self,
1576 obligation: &PolyTraitObligation<'tcx>,
1577 placeholder_trait_ref: ty::TraitRef<'tcx>,
1578 trait_bound: ty::PolyTraitRef<'tcx>,
1579 ) -> Result<Option<ty::TraitRef<'tcx>>, ()> {
1580 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());
1581 if placeholder_trait_ref.def_id != trait_bound.def_id() {
1582 return Err(());
1584 }
1585
1586 let drcx = DeepRejectCtxt::relate_rigid_rigid(self.infcx.tcx);
1587 let obligation_args = obligation.predicate.skip_binder().trait_ref.args;
1588 if !drcx.args_may_unify(obligation_args, trait_bound.skip_binder().args) {
1589 return Err(());
1590 }
1591
1592 let trait_bound = self.infcx.instantiate_binder_with_fresh_vars(
1593 obligation.cause.span,
1594 HigherRankedType,
1595 trait_bound,
1596 );
1597 let Normalized { value: trait_bound, obligations: _ } = normalize_with_depth(
1598 self,
1599 obligation.param_env,
1600 obligation.cause.clone(),
1601 obligation.recursion_depth + 1,
1602 ty::Unnormalized::new_wip(trait_bound),
1603 );
1604 self.infcx
1605 .at(&obligation.cause, obligation.param_env)
1606 .eq(DefineOpaqueTypes::No, placeholder_trait_ref, trait_bound)
1607 .map(|InferOk { obligations: _, value: () }| {
1608 if !trait_bound.has_infer() && !trait_bound.has_placeholders() {
1611 Some(trait_bound)
1612 } else {
1613 None
1614 }
1615 })
1616 .map_err(|_| ())
1617 }
1618
1619 fn where_clause_may_apply<'o>(
1620 &mut self,
1621 stack: &TraitObligationStack<'o, 'tcx>,
1622 where_clause_trait_ref: ty::PolyTraitRef<'tcx>,
1623 ) -> Result<EvaluationResult, OverflowError> {
1624 self.evaluation_probe(|this| {
1625 match this.match_where_clause_trait_ref(stack.obligation, where_clause_trait_ref) {
1626 Ok(obligations) => this.evaluate_predicates_recursively(stack.list(), obligations),
1627 Err(()) => Ok(EvaluatedToErr),
1628 }
1629 })
1630 }
1631
1632 pub(super) fn match_projection_projections(
1639 &mut self,
1640 obligation: &ProjectionTermObligation<'tcx>,
1641 env_predicate: PolyProjectionClause<'tcx>,
1642 potentially_unnormalized_candidates: bool,
1643 ) -> ProjectionMatchesProjection {
1644 let def_id = obligation.predicate.expect_projection_def_id();
1645 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());
1646
1647 let mut nested_obligations = PredicateObligations::new();
1648 let infer_predicate = self.infcx.instantiate_binder_with_fresh_vars(
1649 obligation.cause.span,
1650 BoundRegionConversionTime::HigherRankedType,
1651 env_predicate,
1652 );
1653 let mut infer_projection = infer_predicate.projection_term;
1654 if potentially_unnormalized_candidates {
1655 infer_projection = normalize_with_depth_to(
1656 self,
1657 obligation.param_env,
1658 obligation.cause.clone(),
1659 obligation.recursion_depth + 1,
1660 ty::Unnormalized::new_wip(infer_projection),
1661 &mut nested_obligations,
1662 )
1663 }
1664
1665 let is_match = self
1666 .infcx
1667 .at(&obligation.cause, obligation.param_env)
1668 .eq(DefineOpaqueTypes::No, obligation.predicate, infer_projection)
1669 .is_ok_and(|InferOk { obligations, value: () }| {
1670 self.evaluate_predicates_recursively(
1671 TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
1672 nested_obligations.into_iter().chain(obligations),
1673 )
1674 .is_ok_and(|res| res.may_apply())
1675 });
1676
1677 if is_match {
1678 let generics = self.tcx().generics_of(def_id);
1679 if !generics.is_own_empty()
1688 && obligation.predicate.args.as_slice()[generics.parent_count..].iter().any(|&p| {
1689 p.has_non_region_infer()
1690 && match p.kind() {
1691 ty::GenericArgKind::Const(ct) => {
1692 self.infcx.shallow_resolve_const(ct) != ct
1693 }
1694 ty::GenericArgKind::Type(ty) => self.infcx.shallow_resolve(ty) != ty,
1695 ty::GenericArgKind::Lifetime(_) => false,
1696 }
1697 })
1698 {
1699 ProjectionMatchesProjection::Ambiguous
1700 } else {
1701 ProjectionMatchesProjection::Yes
1702 }
1703 } else {
1704 ProjectionMatchesProjection::No
1705 }
1706 }
1707}
1708
1709impl<'tcx> SelectionContext<'_, 'tcx> {
1716 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1720u32),
::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::unreachable_default_msg(),
}) {
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:1720",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1720u32),
::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)]
1721 fn winnow_candidates(
1722 &mut self,
1723 has_non_region_infer: bool,
1724 candidate_preference_mode: CandidatePreferenceMode,
1725 mut candidates: Vec<EvaluatedCandidate<'tcx>>,
1726 ) -> Option<SelectionCandidate<'tcx>> {
1727 if candidates.len() == 1 {
1728 return Some(candidates.pop().unwrap().candidate);
1729 }
1730
1731 let mut sized_candidates =
1733 candidates.iter().filter(|c| matches!(c.candidate, SizedCandidate));
1734 if let Some(sized_candidate) = sized_candidates.next() {
1735 debug_assert_eq!(sized_candidates.next(), None);
1738 if sized_candidate.evaluation.must_apply_modulo_regions() {
1742 return Some(sized_candidate.candidate.clone());
1743 } else {
1744 return None;
1745 }
1746 }
1747
1748 'search_victim: loop {
1752 for (i, this) in candidates.iter().enumerate() {
1753 let ParamCandidate(this) = this.candidate else { continue };
1754 for (j, other) in candidates.iter().enumerate() {
1755 if i == j {
1756 continue;
1757 }
1758
1759 let ParamCandidate(other) = other.candidate else { continue };
1760 if this == other {
1761 candidates.remove(j);
1762 continue 'search_victim;
1763 }
1764
1765 if this.skip_binder().trait_ref == other.skip_binder().trait_ref
1766 && this.skip_binder().polarity == other.skip_binder().polarity
1767 && !this.skip_binder().trait_ref.has_escaping_bound_vars()
1768 {
1769 candidates.remove(j);
1770 continue 'search_victim;
1771 }
1772 }
1773 }
1774
1775 break;
1776 }
1777
1778 let mut alias_bounds = candidates.iter().filter_map(|c| {
1779 if let ProjectionCandidate { idx, kind } = c.candidate {
1780 Some((idx, kind))
1781 } else {
1782 None
1783 }
1784 });
1785 if matches!(candidate_preference_mode, CandidatePreferenceMode::Marker) {
1788 match alias_bounds
1789 .clone()
1790 .filter_map(|(idx, kind)| (kind == AliasBoundKind::SelfBounds).then_some(idx))
1791 .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) })
1792 {
1793 Some(Some(idx)) => {
1794 return Some(ProjectionCandidate { idx, kind: AliasBoundKind::SelfBounds });
1795 }
1796 Some(None) => {}
1797 None => return None,
1798 }
1799 }
1800
1801 let is_global = |c: ty::PolyTraitClause<'tcx>| c.is_global() && !c.has_bound_vars();
1808 let param_candidates = candidates
1809 .iter()
1810 .filter_map(|c| if let ParamCandidate(p) = c.candidate { Some(p) } else { None });
1811 let mut has_global_bounds = false;
1812 let mut param_candidate = None;
1813 for c in param_candidates {
1814 if is_global(c) {
1815 has_global_bounds = true;
1816 } else if param_candidate.replace(c).is_some() {
1817 return None;
1819 }
1820 }
1821 if let Some(predicate) = param_candidate {
1822 if has_global_bounds {
1824 return None;
1825 } else {
1826 return Some(ParamCandidate(predicate));
1827 }
1828 }
1829
1830 match alias_bounds.try_reduce(|(c1, k1), (c2, k2)| {
1835 if has_non_region_infer {
1836 None
1837 } else if c1 < c2 {
1838 Some((c1, k1))
1839 } else {
1840 Some((c2, k2))
1841 }
1842 }) {
1843 Some(Some((idx, kind))) => return Some(ProjectionCandidate { idx, kind }),
1844 Some(None) => {}
1845 None => return None,
1846 }
1847
1848 let object_bound = candidates
1857 .iter()
1858 .filter_map(|c| if let ObjectCandidate(i) = c.candidate { Some(i) } else { None })
1859 .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) });
1860 match object_bound {
1861 Some(Some(index)) => {
1862 return if has_non_region_infer
1863 && candidates.iter().any(|c| matches!(c.candidate, ImplCandidate(_)))
1864 {
1865 None
1866 } else {
1867 Some(ObjectCandidate(index))
1868 };
1869 }
1870 Some(None) => {}
1871 None => return None,
1872 }
1873 let upcast_bound = candidates
1875 .iter()
1876 .filter_map(|c| {
1877 if let TraitUpcastingUnsizeCandidate(i) = c.candidate { Some(i) } else { None }
1878 })
1879 .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) });
1880 match upcast_bound {
1881 Some(Some(index)) => return Some(TraitUpcastingUnsizeCandidate(index)),
1882 Some(None) => {}
1883 None => return None,
1884 }
1885
1886 let impls = candidates.iter().filter_map(|c| {
1888 if let ImplCandidate(def_id) = c.candidate {
1889 Some((def_id, c.evaluation))
1890 } else {
1891 None
1892 }
1893 });
1894 let mut impl_candidate = None;
1895 for c in impls {
1896 if let Some(prev) = impl_candidate.replace(c) {
1897 if self.prefer_lhs_over_victim(has_non_region_infer, c, prev.0) {
1898 } else if self.prefer_lhs_over_victim(has_non_region_infer, prev, c.0) {
1900 impl_candidate = Some(prev);
1902 } else {
1903 return None;
1905 }
1906 }
1907 }
1908 if let Some((def_id, _evaluation)) = impl_candidate {
1909 if candidates.iter().all(|c| match c.candidate {
1912 SizedCandidate
1913 | BuiltinCandidate
1914 | TransmutabilityCandidate
1915 | AutoImplCandidate
1916 | ClosureCandidate { .. }
1917 | AsyncClosureCandidate
1918 | AsyncFnKindHelperCandidate
1919 | CoroutineCandidate
1920 | FutureCandidate
1921 | IteratorCandidate
1922 | AsyncIteratorCandidate
1923 | FnPointerCandidate
1924 | TraitAliasCandidate
1925 | TraitUpcastingUnsizeCandidate(_)
1926 | BuiltinObjectCandidate
1927 | BuiltinUnsizeCandidate
1928 | TryAsDynCandidate
1929 | BikeshedGuaranteedNoDropCandidate => false,
1930 ParamCandidate(_) | ImplCandidate(_) => true,
1933 ProjectionCandidate { .. } | ObjectCandidate(_) => unreachable!(),
1934 }) {
1935 return Some(ImplCandidate(def_id));
1936 } else {
1937 return None;
1938 }
1939 }
1940
1941 if candidates.len() == 1 {
1942 Some(candidates.pop().unwrap().candidate)
1943 } else {
1944 let mut not_a_global_where_bound = candidates
1947 .into_iter()
1948 .filter(|c| !matches!(c.candidate, ParamCandidate(p) if is_global(p)));
1949 not_a_global_where_bound
1950 .next()
1951 .map(|c| c.candidate)
1952 .filter(|_| not_a_global_where_bound.next().is_none())
1953 }
1954 }
1955
1956 fn prefer_lhs_over_victim(
1957 &self,
1958 has_non_region_infer: bool,
1959 (lhs, lhs_evaluation): (DefId, EvaluationResult),
1960 victim: DefId,
1961 ) -> bool {
1962 let tcx = self.tcx();
1963 if lhs_evaluation.must_apply_modulo_regions() {
1970 if tcx.specializes((lhs, victim)) {
1971 return true;
1972 }
1973 }
1974
1975 match tcx.impls_are_allowed_to_overlap(lhs, victim) {
1976 Some(ty::ImplOverlapKind::Permitted { marker: false }) => {
1979 lhs_evaluation.must_apply_considering_regions()
1980 }
1981 Some(ty::ImplOverlapKind::Permitted { marker: true }) => {
1982 !has_non_region_infer && lhs_evaluation.must_apply_considering_regions()
2022 }
2023 None => false,
2024 }
2025 }
2026}
2027
2028impl<'tcx> SelectionContext<'_, 'tcx> {
2029 fn sizedness_conditions(
2030 &mut self,
2031 self_ty: Ty<'tcx>,
2032 sizedness: SizedTraitKind,
2033 ) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
2034 match self_ty.kind() {
2035 ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2036 | ty::Uint(_)
2037 | ty::Int(_)
2038 | ty::Bool
2039 | ty::Float(_)
2040 | ty::FnDef(..)
2041 | ty::FnPtr(..)
2042 | ty::RawPtr(..)
2043 | ty::Char
2044 | ty::Ref(..)
2045 | ty::Coroutine(..)
2046 | ty::CoroutineWitness(..)
2047 | ty::Array(..)
2048 | ty::Closure(..)
2049 | ty::CoroutineClosure(..)
2050 | ty::Never
2051 | ty::Error(_) => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2052
2053 ty::Str | ty::Slice(_) | ty::Dynamic(..) => match sizedness {
2054 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"),
2055 SizedTraitKind::MetaSized => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2056 },
2057
2058 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"),
2059
2060 ty::Tuple(tys) => {
2061 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]))
2062 }
2063
2064 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]),
2065
2066 ty::Adt(def, args) => {
2067 if let Some(crit) = def.sizedness_constraint(self.tcx(), sizedness) {
2068 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()])
2069 } else {
2070 ty::Binder::dummy(::alloc::vec::Vec::new()vec![])
2071 }
2072 }
2073
2074 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]),
2075
2076 ty::Alias(..)
2077 | ty::Param(_)
2078 | ty::Placeholder(..)
2079 | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_))
2080 | ty::Bound(..) => {
2081 ::rustc_span::macros::bug_impl(None,
format_args!("asked to assemble `Sized` of unexpected type: {0:?}",
self_ty), Location::caller());bug!("asked to assemble `Sized` of unexpected type: {:?}", self_ty);
2082 }
2083
2084 ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
2086 }
2087 }
2088
2089 fn copy_clone_conditions(&mut self, self_ty: Ty<'tcx>) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
2090 match *self_ty.kind() {
2091 ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2092
2093 ty::Uint(_)
2094 | ty::Int(_)
2095 | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2096 | ty::Bool
2097 | ty::Float(_)
2098 | ty::Char
2099 | ty::RawPtr(..)
2100 | ty::Never
2101 | ty::Ref(_, _, hir::Mutability::Not)
2102 | ty::Array(..) => {
2103 {
::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")
2104 }
2105
2106 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"),
2109
2110 ty::Tuple(tys) => {
2111 ty::Binder::dummy(tys.iter().collect())
2113 }
2114
2115 ty::Pat(ty, _) => {
2116 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])
2118 }
2119
2120 ty::Coroutine(def_id, args) => match self.tcx().coroutine_movability(def_id) {
2121 hir::Movability::Static => {
2122 {
::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")
2123 }
2124 hir::Movability::Movable => {
2125 if self.tcx().features().coroutine_clone() {
2126 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![
2127 args.as_coroutine().tupled_upvars_ty(),
2128 Ty::new_coroutine_witness_for_coroutine(self.tcx(), def_id, args),
2129 ])
2130 } else {
2131 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("tried to assemble `Clone` for coroutine without enabled feature")));
}unreachable!(
2132 "tried to assemble `Clone` for coroutine without enabled feature"
2133 )
2134 }
2135 }
2136 },
2137
2138 ty::CoroutineWitness(def_id, args) => self
2139 .infcx
2140 .tcx
2141 .coroutine_hidden_types(def_id)
2142 .instantiate(self.infcx.tcx, args)
2143 .skip_norm_wip()
2144 .map_bound(|witness| witness.types.to_vec()),
2145
2146 ty::Closure(_, args) => ty::Binder::dummy(args.as_closure().upvar_tys().to_vec()),
2147
2148 ty::CoroutineClosure(_, args) => {
2149 ty::Binder::dummy(args.as_coroutine_closure().upvar_tys().to_vec())
2150 }
2151
2152 ty::Foreign(..)
2153 | ty::Str
2154 | ty::Slice(_)
2155 | ty::Dynamic(..)
2156 | ty::Adt(..)
2157 | ty::Alias(..)
2158 | ty::Param(..)
2159 | ty::Placeholder(..)
2160 | ty::Bound(..)
2161 | ty::Ref(_, _, ty::Mutability::Mut)
2162 | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2163 ::rustc_span::macros::bug_impl(None,
format_args!("asked to assemble builtin bounds of unexpected type: {0:?}",
self_ty), Location::caller());bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
2164 }
2165
2166 ty::View(..) => ::core::panicking::unimplemented_default_msg()unimplemented!(),
2168 }
2169 }
2170
2171 fn coroutine_is_gen(&mut self, self_ty: Ty<'tcx>) -> bool {
2172 #[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, ..)
2173 if self.tcx().coroutine_is_gen(did))
2174 }
2175
2176 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2187u32),
::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_span::macros::bug_impl(None,
format_args!("asked to assemble constituent types of unexpected type: {0:?}",
t), Location::caller());
}
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::unreachable_default_msg()
} 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(),
})
}
}
ty::View(..) =>
::core::panicking::unimplemented_default_msg(),
})
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2187",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2187u32),
::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)]
2188 fn constituent_types_for_auto_trait(
2189 &self,
2190 t: Ty<'tcx>,
2191 ) -> Result<ty::Binder<'tcx, AutoImplConstituents<'tcx>>, SelectionError<'tcx>> {
2192 Ok(match *t.kind() {
2193 ty::Uint(_)
2194 | ty::Int(_)
2195 | ty::Bool
2196 | ty::Float(_)
2197 | ty::FnDef(..)
2198 | ty::FnPtr(..)
2199 | ty::Error(_)
2200 | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2201 | ty::Never
2202 | ty::Char => {
2203 ty::Binder::dummy(AutoImplConstituents { types: vec![], assumptions: vec![] })
2204 }
2205
2206 ty::Foreign(..) => {
2210 ty::Binder::dummy(AutoImplConstituents { types: vec![], assumptions: vec![] })
2211 }
2212
2213 ty::UnsafeBinder(ty) => {
2214 ty.map_bound(|ty| AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2215 }
2216
2217 ty::Str => ty::Binder::dummy(AutoImplConstituents {
2219 types: vec![Ty::new_slice(self.tcx(), self.tcx().types.u8)],
2220 assumptions: vec![],
2221 }),
2222
2223 ty::Placeholder(..)
2224 | ty::Dynamic(..)
2225 | ty::Param(..)
2226 | ty::Alias(
2227 _,
2228 ty::AliasTy {
2229 kind: ty::Projection { .. } | ty::Inherent { .. } | ty::Free { .. },
2230 ..
2231 },
2232 )
2233 | ty::Bound(..)
2234 | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2235 bug!("asked to assemble constituent types of unexpected type: {:?}", t);
2236 }
2237
2238 ty::RawPtr(element_ty, _) | ty::Ref(_, element_ty, _) => {
2239 ty::Binder::dummy(AutoImplConstituents {
2240 types: vec![element_ty],
2241 assumptions: vec![],
2242 })
2243 }
2244
2245 ty::Pat(ty, _) | ty::Array(ty, _) | ty::Slice(ty) => {
2246 ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2247 }
2248
2249 ty::Tuple(tys) => {
2250 ty::Binder::dummy(AutoImplConstituents {
2252 types: tys.iter().collect(),
2253 assumptions: vec![],
2254 })
2255 }
2256
2257 ty::Closure(_, args) => {
2258 let ty = self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
2259 ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2260 }
2261
2262 ty::CoroutineClosure(_, args) => {
2263 let ty = self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
2264 ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2265 }
2266
2267 ty::Coroutine(def_id, args) => {
2268 let ty = self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
2269 let tcx = self.tcx();
2270 let witness = Ty::new_coroutine_witness_for_coroutine(tcx, def_id, args);
2271 ty::Binder::dummy(AutoImplConstituents {
2272 types: vec![ty, witness],
2273 assumptions: vec![],
2274 })
2275 }
2276
2277 ty::CoroutineWitness(def_id, args) => self
2278 .infcx
2279 .tcx
2280 .coroutine_hidden_types(def_id)
2281 .instantiate(self.infcx.tcx, args)
2282 .skip_norm_wip()
2283 .map_bound(|witness| AutoImplConstituents {
2284 types: witness.types.to_vec(),
2285 assumptions: witness.assumptions.to_vec(),
2286 }),
2287
2288 ty::Adt(def, args) if def.is_phantom_data() => {
2290 ty::Binder::dummy(AutoImplConstituents {
2291 types: args.types().collect(),
2292 assumptions: vec![],
2293 })
2294 }
2295
2296 ty::Adt(def, args) => ty::Binder::dummy(AutoImplConstituents {
2297 types: def.all_fields().map(|f| f.ty(self.tcx(), args).skip_norm_wip()).collect(),
2298 assumptions: vec![],
2299 }),
2300
2301 ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) => {
2302 if self.infcx.can_define_opaque_ty(def_id) {
2303 unreachable!()
2304 } else {
2305 let ty = self.tcx().type_of_opaque(def_id);
2309 ty::Binder::dummy(AutoImplConstituents {
2310 types: vec![ty.instantiate(self.tcx(), args).skip_norm_wip()],
2311 assumptions: vec![],
2312 })
2313 }
2314 }
2315
2316 ty::View(..) => unimplemented!(),
2318 })
2319 }
2320
2321 fn collect_predicates_for_types(
2322 &mut self,
2323 param_env: ty::ParamEnv<'tcx>,
2324 cause: ObligationCause<'tcx>,
2325 recursion_depth: usize,
2326 trait_def_id: DefId,
2327 types: Vec<Ty<'tcx>>,
2328 ) -> PredicateObligations<'tcx> {
2329 types
2344 .into_iter()
2345 .flat_map(|placeholder_ty| {
2346 let Normalized { value: normalized_ty, mut obligations } = normalize_with_depth(
2347 self,
2348 param_env,
2349 cause.clone(),
2350 recursion_depth,
2351 Unnormalized::new_wip(placeholder_ty),
2352 );
2353
2354 let tcx = self.tcx();
2355 let trait_ref = if tcx.generics_of(trait_def_id).own_params.len() == 1 {
2356 ty::TraitRef::new(tcx, trait_def_id, [normalized_ty])
2357 } else {
2358 let err_args = ty::GenericArgs::extend_with_error(
2361 tcx,
2362 trait_def_id,
2363 &[normalized_ty.into()],
2364 );
2365 ty::TraitRef::new_from_args(tcx, trait_def_id, err_args)
2366 };
2367
2368 let obligation = Obligation::new(self.tcx(), cause.clone(), param_env, trait_ref);
2369 obligations.push(obligation);
2370 obligations
2371 })
2372 .collect()
2373 }
2374
2375 fn rematch_impl(
2386 &mut self,
2387 impl_def_id: DefId,
2388 obligation: &PolyTraitObligation<'tcx>,
2389 ) -> Normalized<'tcx, GenericArgs<'tcx>> {
2390 let impl_trait_header = self.tcx().impl_trait_header(impl_def_id);
2391 match self.match_impl(impl_def_id, impl_trait_header, obligation) {
2392 Ok(args) => args,
2393 Err(()) => {
2394 let predicate = self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
2395 ::rustc_span::macros::bug_impl(None,
format_args!("impl {0:?} was matchable against {1:?} but now is not",
impl_def_id, predicate), Location::caller())bug!("impl {impl_def_id:?} was matchable against {predicate:?} but now is not")
2396 }
2397 }
2398 }
2399
2400 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2400u32),
::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, GenericArgs<'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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2414",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2414u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2426",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2426u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2439",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2439u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2447",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2447u32),
::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::Typeck { .. } |
TypingMode::PostTypeckThroughBorrowck { .. } |
TypingMode::PostBorrowck { .. } | TypingMode::Codegen |
TypingMode::ErasedNotCoherence(_) | TypingMode::Reflection |
TypingMode::PostAnalysis => {}
TypingMode::Coherence => {
{
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("old solver coherence")));
}
}
}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2400",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2400u32),
::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)]
2401 fn match_impl(
2402 &mut self,
2403 impl_def_id: DefId,
2404 impl_trait_header: ty::ImplTraitHeader<'tcx>,
2405 obligation: &PolyTraitObligation<'tcx>,
2406 ) -> Result<Normalized<'tcx, GenericArgs<'tcx>>, ()> {
2407 let placeholder_obligation =
2408 self.infcx.enter_forall_and_leak_universe(obligation.predicate);
2409 let placeholder_obligation_trait_ref = placeholder_obligation.trait_ref;
2410
2411 let impl_args = self.infcx.fresh_args_for_item(obligation.cause.span, impl_def_id);
2412
2413 let trait_ref = impl_trait_header.trait_ref.instantiate(self.tcx(), impl_args);
2414 debug!(?impl_trait_header);
2415
2416 let mut nested_obligations = PredicateObligations::new();
2417 let impl_trait_ref = normalize_with_depth_to(
2418 self,
2419 obligation.param_env,
2420 obligation.cause.clone(),
2421 obligation.recursion_depth + 1,
2422 trait_ref,
2423 &mut nested_obligations,
2424 );
2425
2426 debug!(?impl_trait_ref, ?placeholder_obligation_trait_ref);
2427
2428 let cause = ObligationCause::new(
2429 obligation.cause.span,
2430 obligation.cause.body_def_id,
2431 ObligationCauseCode::MatchImpl(obligation.cause.clone(), impl_def_id),
2432 );
2433
2434 let InferOk { obligations, .. } = self
2435 .infcx
2436 .at(&cause, obligation.param_env)
2437 .eq(DefineOpaqueTypes::No, placeholder_obligation_trait_ref, impl_trait_ref)
2438 .map_err(|e| {
2439 debug!("match_impl: failed eq_trait_refs due to `{}`", e.to_string(self.tcx()))
2440 })?;
2441 nested_obligations.extend(obligations);
2442
2443 match self.typing_mode() {
2444 TypingMode::Reflection
2445 if !self.tcx().impl_is_fully_generic_for_reflection(impl_def_id) =>
2446 {
2447 debug!("reflection mode only allows fully generic impls");
2448 return Err(());
2449 }
2450
2451 TypingMode::Typeck { .. }
2452 | TypingMode::PostTypeckThroughBorrowck { .. }
2453 | TypingMode::PostBorrowck { .. }
2454 | TypingMode::Codegen
2455 | TypingMode::ErasedNotCoherence(_)
2456 | TypingMode::Reflection
2457 | TypingMode::PostAnalysis => {}
2458 TypingMode::Coherence => {
2459 unreachable!("old solver coherence")
2460 }
2461 }
2462
2463 Ok(Normalized { value: impl_args, obligations: nested_obligations })
2464 }
2465
2466 fn match_upcast_principal(
2467 &mut self,
2468 obligation: &PolyTraitObligation<'tcx>,
2469 unnormalized_upcast_principal: ty::Unnormalized<'tcx, ty::PolyTraitRef<'tcx>>,
2470 a_data: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
2471 b_data: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
2472 a_region: ty::Region<'tcx>,
2473 b_region: ty::Region<'tcx>,
2474 ) -> SelectionResult<'tcx, PredicateObligations<'tcx>> {
2475 let tcx = self.tcx();
2476 let mut nested = PredicateObligations::new();
2477
2478 let a_auto_traits: FxIndexSet<DefId> = a_data
2482 .auto_traits()
2483 .chain(
2484 a_data
2485 .principal_def_id()
2486 .map(|principal_def_id| {
2487 elaborate::supertrait_def_ids(tcx, principal_def_id)
2488 .filter(|def_id| tcx.trait_is_auto(*def_id))
2489 })
2490 .into_flat_iter(),
2491 )
2492 .collect();
2493
2494 let upcast_principal = normalize_with_depth_to(
2495 self,
2496 obligation.param_env,
2497 obligation.cause.clone(),
2498 obligation.recursion_depth + 1,
2499 unnormalized_upcast_principal,
2500 &mut nested,
2501 );
2502
2503 for bound in b_data {
2504 match bound.skip_binder() {
2505 ty::ExistentialPredicate::Trait(target_principal) => {
2508 let hr_source_principal = upcast_principal.map_bound(|trait_ref| {
2509 ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
2510 });
2511 let hr_target_principal = bound.rebind(target_principal);
2512
2513 nested.extend(
2514 self.infcx
2515 .enter_forall(hr_target_principal, |target_principal| {
2516 let source_principal =
2517 self.infcx.instantiate_binder_with_fresh_vars(
2518 obligation.cause.span,
2519 HigherRankedType,
2520 hr_source_principal,
2521 );
2522 self.infcx.at(&obligation.cause, obligation.param_env).eq_trace(
2523 DefineOpaqueTypes::Yes,
2524 ToTrace::to_trace(
2525 &obligation.cause,
2526 hr_target_principal,
2527 hr_source_principal,
2528 ),
2529 target_principal,
2530 source_principal,
2531 )
2532 })
2533 .map_err(|_| SelectionError::Unimplemented)?
2534 .into_obligations(),
2535 );
2536 }
2537 ty::ExistentialPredicate::Projection(target_projection) => {
2543 let hr_target_projection = bound.rebind(target_projection);
2544
2545 let mut matching_projections =
2546 a_data.projection_bounds().filter(|&hr_source_projection| {
2547 hr_source_projection.item_def_id() == hr_target_projection.item_def_id()
2550 && self.infcx.probe(|_| {
2551 self.infcx
2552 .enter_forall(hr_target_projection, |target_projection| {
2553 let source_projection =
2554 self.infcx.instantiate_binder_with_fresh_vars(
2555 obligation.cause.span,
2556 HigherRankedType,
2557 hr_source_projection,
2558 );
2559 self.infcx
2560 .at(&obligation.cause, obligation.param_env)
2561 .eq_trace(
2562 DefineOpaqueTypes::Yes,
2563 ToTrace::to_trace(
2564 &obligation.cause,
2565 hr_target_projection,
2566 hr_source_projection,
2567 ),
2568 target_projection,
2569 source_projection,
2570 )
2571 })
2572 .is_ok()
2573 })
2574 });
2575
2576 let Some(hr_source_projection) = matching_projections.next() else {
2577 return Err(SelectionError::Unimplemented);
2578 };
2579 if matching_projections.next().is_some() {
2580 return Ok(None);
2581 }
2582 nested.extend(
2583 self.infcx
2584 .enter_forall(hr_target_projection, |target_projection| {
2585 let source_projection =
2586 self.infcx.instantiate_binder_with_fresh_vars(
2587 obligation.cause.span,
2588 HigherRankedType,
2589 hr_source_projection,
2590 );
2591 self.infcx.at(&obligation.cause, obligation.param_env).eq_trace(
2592 DefineOpaqueTypes::Yes,
2593 ToTrace::to_trace(
2594 &obligation.cause,
2595 hr_target_projection,
2596 hr_source_projection,
2597 ),
2598 target_projection,
2599 source_projection,
2600 )
2601 })
2602 .map_err(|_| SelectionError::Unimplemented)?
2603 .into_obligations(),
2604 );
2605 }
2606 ty::ExistentialPredicate::AutoTrait(def_id) => {
2608 if !a_auto_traits.contains(&def_id) {
2609 return Err(SelectionError::Unimplemented);
2610 }
2611 }
2612 }
2613 }
2614
2615 nested.push(Obligation::with_depth(
2616 tcx,
2617 obligation.cause.clone(),
2618 obligation.recursion_depth + 1,
2619 obligation.param_env,
2620 ty::Binder::dummy(ty::OutlivesClause(a_region, b_region)),
2621 ));
2622
2623 Ok(Some(nested))
2624 }
2625
2626 fn match_where_clause_trait_ref(
2630 &mut self,
2631 obligation: &PolyTraitObligation<'tcx>,
2632 where_clause_trait_ref: ty::PolyTraitRef<'tcx>,
2633 ) -> Result<PredicateObligations<'tcx>, ()> {
2634 self.match_poly_trait_ref(obligation, where_clause_trait_ref)
2635 }
2636
2637 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2639u32),
::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")]
2640 fn match_poly_trait_ref(
2641 &mut self,
2642 obligation: &PolyTraitObligation<'tcx>,
2643 poly_trait_ref: ty::PolyTraitRef<'tcx>,
2644 ) -> Result<PredicateObligations<'tcx>, ()> {
2645 let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
2646 let trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
2647 obligation.cause.span,
2648 HigherRankedType,
2649 poly_trait_ref,
2650 );
2651 self.infcx
2652 .at(&obligation.cause, obligation.param_env)
2653 .eq(DefineOpaqueTypes::No, predicate.trait_ref, trait_ref)
2654 .map(|InferOk { obligations, .. }| obligations)
2655 .map_err(|_| ())
2656 }
2657
2658 fn match_fresh_trait_preds(
2662 &self,
2663 previous: ty::PolyTraitClause<'tcx>,
2664 current: ty::PolyTraitClause<'tcx>,
2665 ) -> bool {
2666 let mut matcher = _match::MatchAgainstFreshVars::new(self.tcx());
2667 matcher.relate(previous, current).is_ok()
2668 }
2669
2670 fn push_stack<'o>(
2671 &mut self,
2672 previous_stack: TraitObligationStackList<'o, 'tcx>,
2673 obligation: &'o PolyTraitObligation<'tcx>,
2674 ) -> TraitObligationStack<'o, 'tcx> {
2675 let fresh_trait_pred = obligation.predicate.fold_with(&mut self.freshener);
2676
2677 let dfn = previous_stack.cache.next_dfn();
2678 let depth = previous_stack.depth() + 1;
2679 TraitObligationStack {
2680 obligation,
2681 fresh_trait_pred,
2682 reached_depth: Cell::new(depth),
2683 previous: previous_stack,
2684 dfn,
2685 depth,
2686 }
2687 }
2688
2689 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2689u32),
::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_span::macros::bug_impl(None,
format_args!("expected closure, found {0}", self_ty),
Location::caller());
};
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")]
2690 fn closure_trait_ref_unnormalized(
2691 &mut self,
2692 self_ty: Ty<'tcx>,
2693 fn_trait_def_id: DefId,
2694 ) -> ty::PolyTraitRef<'tcx> {
2695 let ty::Closure(_, args) = *self_ty.kind() else {
2696 bug!("expected closure, found {self_ty}");
2697 };
2698 let closure_sig = args.as_closure().sig();
2699
2700 closure_trait_ref_and_return_type(
2701 self.tcx(),
2702 fn_trait_def_id,
2703 self_ty,
2704 closure_sig,
2705 util::TupleArgumentsFlag::No,
2706 )
2707 .map_bound(|(trait_ref, _)| trait_ref)
2708 }
2709
2710 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2714u32),
::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))]
2715 fn impl_or_trait_obligations(
2716 &mut self,
2717 cause: &ObligationCause<'tcx>,
2718 recursion_depth: usize,
2719 param_env: ty::ParamEnv<'tcx>,
2720 def_id: DefId, args: GenericArgs<'tcx>, parent_trait_pred: ty::Binder<'tcx, ty::TraitClause<'tcx>>,
2723 ) -> PredicateObligations<'tcx> {
2724 let tcx = self.tcx();
2725
2726 let clauses = tcx.clauses_of(def_id);
2741 assert_eq!(clauses.parent, None);
2742 let clauses = clauses.instantiate_own(tcx, args);
2743 let mut obligations = PredicateObligations::with_capacity(clauses.len());
2744 for (index, (clause, span)) in clauses.into_iter().enumerate() {
2745 let cause = if tcx.is_lang_item(parent_trait_pred.def_id(), LangItem::CoerceUnsized) {
2746 cause.clone()
2747 } else {
2748 cause.clone().derived_cause(parent_trait_pred, |derived| {
2749 ObligationCauseCode::ImplDerived(Box::new(ImplDerivedCause {
2750 derived,
2751 impl_or_alias_def_id: def_id,
2752 impl_def_clause_index: Some(index),
2753 span,
2754 }))
2755 })
2756 };
2757 let clause = normalize_with_depth_to(
2758 self,
2759 param_env,
2760 cause.clone(),
2761 recursion_depth,
2762 clause,
2763 &mut obligations,
2764 );
2765 obligations.push(Obligation {
2766 cause,
2767 recursion_depth,
2768 param_env,
2769 predicate: clause.as_predicate(),
2770 });
2771 }
2772
2773 if tcx.def_kind(def_id) == (DefKind::Impl { of_trait: true }) {
2775 for clause in tcx.impl_super_outlives(def_id).iter_instantiated(tcx, args) {
2776 let clause = normalize_with_depth_to(
2777 self,
2778 param_env,
2779 cause.clone(),
2780 recursion_depth,
2781 clause,
2782 &mut obligations,
2783 );
2784 obligations.push(Obligation {
2785 cause: cause.clone(),
2786 recursion_depth,
2787 param_env,
2788 predicate: clause.as_predicate(),
2789 });
2790 }
2791 }
2792
2793 obligations
2794 }
2795
2796 pub(super) fn should_stall_coroutine(&self, def_id: DefId) -> bool {
2797 match self.typing_mode() {
2798 TypingMode::Typeck { defining_opaque_types_and_generators: stalled_generators } => {
2799 def_id.as_local().is_some_and(|def_id| stalled_generators.contains(&def_id))
2800 }
2801 TypingMode::PostAnalysis
2802 | TypingMode::Reflection
2803 | TypingMode::Codegen
2804 | TypingMode::PostTypeckThroughBorrowck { defining_opaque_types: _ }
2805 | TypingMode::PostBorrowck { defined_opaque_types: _ } => false,
2806 TypingMode::Coherence => {
2807 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("old solver coherence")));
}unreachable!("old solver coherence")
2808 }
2809 }
2810 }
2811}
2812
2813impl<'o, 'tcx> TraitObligationStack<'o, 'tcx> {
2814 fn list(&'o self) -> TraitObligationStackList<'o, 'tcx> {
2815 TraitObligationStackList::with(self)
2816 }
2817
2818 fn cache(&self) -> &'o ProvisionalEvaluationCache<'tcx> {
2819 self.previous.cache
2820 }
2821
2822 fn iter(&'o self) -> TraitObligationStackList<'o, 'tcx> {
2823 self.list()
2824 }
2825
2826 fn update_reached_depth(&self, reached_depth: usize) {
2829 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!(
2830 self.depth >= reached_depth,
2831 "invoked `update_reached_depth` with something under this stack: \
2832 self.depth={} reached_depth={}",
2833 self.depth,
2834 reached_depth,
2835 );
2836 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2836",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2836u32),
::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");
2837 let mut p = self;
2838 while reached_depth < p.depth {
2839 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2839",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2839u32),
::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");
2840 p.reached_depth.set(p.reached_depth.get().min(reached_depth));
2841 p = p.previous.head.unwrap();
2842 }
2843 }
2844}
2845
2846struct ProvisionalEvaluationCache<'tcx> {
2900 dfn: Cell<usize>,
2902
2903 map: RefCell<FxIndexMap<ty::PolyTraitClause<'tcx>, ProvisionalEvaluation>>,
2919
2920 wf_args: RefCell<Vec<(ty::Term<'tcx>, usize)>>,
2928}
2929
2930#[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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<usize>;
let _: ::core::clone::AssertParamIsClone<EvaluationResult>;
*self
}
}Clone, #[automatically_derived]impl ::core::fmt::Debug for ProvisionalEvaluation {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"ProvisionalEvaluation from_dfn reached_depth result",
&self.from_dfn, &self.reached_depth, &&self.result)
}
}Debug)]
2933struct ProvisionalEvaluation {
2934 from_dfn: usize,
2935 reached_depth: usize,
2936 result: EvaluationResult,
2937}
2938
2939impl<'tcx> Default for ProvisionalEvaluationCache<'tcx> {
2940 fn default() -> Self {
2941 Self { dfn: Cell::new(0), map: Default::default(), wf_args: Default::default() }
2942 }
2943}
2944
2945impl<'tcx> ProvisionalEvaluationCache<'tcx> {
2946 fn next_dfn(&self) -> usize {
2948 let result = self.dfn.get();
2949 self.dfn.set(result + 1);
2950 result
2951 }
2952
2953 fn get_provisional(
2958 &self,
2959 fresh_trait_pred: ty::PolyTraitClause<'tcx>,
2960 ) -> Option<ProvisionalEvaluation> {
2961 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2961",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2961u32),
::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!(
2962 ?fresh_trait_pred,
2963 "get_provisional = {:#?}",
2964 self.map.borrow().get(&fresh_trait_pred),
2965 );
2966 Some(*self.map.borrow().get(&fresh_trait_pred)?)
2967 }
2968
2969 fn insert_provisional(
2974 &self,
2975 from_dfn: usize,
2976 reached_depth: usize,
2977 fresh_trait_pred: ty::PolyTraitClause<'tcx>,
2978 result: EvaluationResult,
2979 ) {
2980 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:2980",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2980u32),
::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");
2981
2982 let mut map = self.map.borrow_mut();
2983
2984 for (_k, v) in &mut *map {
2999 if v.from_dfn >= from_dfn {
3000 v.reached_depth = reached_depth.min(v.reached_depth);
3001 }
3002 }
3003
3004 map.insert(fresh_trait_pred, ProvisionalEvaluation { from_dfn, reached_depth, result });
3005 }
3006
3007 fn on_failure(&self, dfn: usize) {
3016 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:3016",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3016u32),
::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");
3017 self.map.borrow_mut().retain(|key, eval| {
3018 if eval.from_dfn < dfn {
3019 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:3019",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3019u32),
::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);
3020 false
3021 } else {
3022 true
3023 }
3024 });
3025 }
3026
3027 fn on_completion(&self, dfn: usize) {
3065 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:3065",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3065u32),
::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");
3066 self.map.borrow_mut().retain(|fresh_trait_pred, eval| {
3067 if eval.from_dfn >= dfn {
3068 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs:3068",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3068u32),
::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");
3069 return false;
3070 }
3071 true
3072 });
3073 }
3074}
3075
3076#[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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _:
::core::clone::AssertParamIsClone<&'o ProvisionalEvaluationCache<'tcx>>;
let _:
::core::clone::AssertParamIsClone<Option<&'o TraitObligationStack<'o,
'tcx>>>;
*self
}
}Clone)]
3077struct TraitObligationStackList<'o, 'tcx> {
3078 cache: &'o ProvisionalEvaluationCache<'tcx>,
3079 head: Option<&'o TraitObligationStack<'o, 'tcx>>,
3080}
3081
3082impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> {
3083 fn empty(cache: &'o ProvisionalEvaluationCache<'tcx>) -> TraitObligationStackList<'o, 'tcx> {
3084 TraitObligationStackList { cache, head: None }
3085 }
3086
3087 fn with(r: &'o TraitObligationStack<'o, 'tcx>) -> TraitObligationStackList<'o, 'tcx> {
3088 TraitObligationStackList { cache: r.cache(), head: Some(r) }
3089 }
3090
3091 fn head(&self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
3092 self.head
3093 }
3094
3095 fn depth(&self) -> usize {
3096 if let Some(head) = self.head { head.depth } else { 0 }
3097 }
3098}
3099
3100impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> {
3101 type Item = &'o TraitObligationStack<'o, 'tcx>;
3102
3103 fn next(&mut self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
3104 let o = self.head?;
3105 *self = o.previous;
3106 Some(o)
3107 }
3108}
3109
3110impl<'o, 'tcx> fmt::Debug for TraitObligationStack<'o, 'tcx> {
3111 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3112 f.write_fmt(format_args!("TraitObligationStack({0:?})", self.obligation))write!(f, "TraitObligationStack({:?})", self.obligation)
3113 }
3114}
3115
3116pub(crate) enum ProjectionMatchesProjection {
3117 Yes,
3118 Ambiguous,
3119 No,
3120}
3121
3122#[derive(#[automatically_derived]impl<'tcx> ::core::clone::Clone for
AutoImplConstituents<'tcx> {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
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]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"AutoImplConstituents types assumptions", &self.types,
&&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)]
3123pub(crate) struct AutoImplConstituents<'tcx> {
3124 pub types: Vec<Ty<'tcx>>,
3125 pub assumptions: Vec<ty::ArgOutlivesClause<'tcx>>,
3126}