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, CandidatePreferenceMode, CantBeErased, DeepRejectCtxt, GenericArgsRef,
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, sizedness_fast_path};
51
52mod _match;
53mod candidate_assembly;
54mod confirmation;
55
56#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for IntercrateAmbiguityCause<'tcx> {
#[inline]
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]
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_0, "self_ty",
&__self_1),
Self::UpstreamCrateUpdate { trait_ref: __self_0, self_ty: __self_1
} =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"UpstreamCrateUpdate", "trait_ref", __self_0, "self_ty",
&__self_1),
}
}
}Debug, #[automatically_derived]
impl<'tcx> ::core::cmp::Eq for IntercrateAmbiguityCause<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<ty::TraitRef<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<Option<Ty<'tcx>>>;
let _: ::core::cmp::AssertParamIsEq<ty::TraitRef<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<Option<Ty<'tcx>>>;
}
}Eq, #[automatically_derived]
impl<'tcx> ::core::marker::StructuralPartialEq for
IntercrateAmbiguityCause<'tcx> {
}
#[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for IntercrateAmbiguityCause<'tcx> {
#[inline]
fn eq(&self, other: &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]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"EvaluatedCandidate", "candidate", &self.candidate, "evaluation",
&&self.evaluation)
}
}Debug, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for EvaluatedCandidate<'tcx> {
#[inline]
fn clone(&self) -> 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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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() &&
sizedness_fast_path(self.tcx(), obligation.predicate,
obligation.param_env) {
return Ok(EvaluatedToOk);
}
let bound_predicate = obligation.predicate.kind();
match bound_predicate.skip_binder() {
ty::PredicateKind::Clause(ty::ClauseKind::Trait(t)) => {
let t = bound_predicate.rebind(t);
if true {
if !!t.has_escaping_bound_vars() {
::core::panicking::panic("assertion failed: !t.has_escaping_bound_vars()")
};
};
let obligation = obligation.with(self.tcx(), t);
self.evaluate_trait_predicate_recursively(previous_stack,
obligation)
}
ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(data))
=> {
self.infcx.enter_forall(bound_predicate.rebind(data),
|data|
{
match effects::evaluate_host_effect_obligation(self,
&obligation.with(self.tcx(), data)) {
Ok(nested) =>
self.evaluate_predicates_recursively(previous_stack,
nested),
Err(effects::EvaluationFailure::Ambiguous) =>
Ok(EvaluatedToAmbig),
Err(effects::EvaluationFailure::NoSolution) =>
Ok(EvaluatedToErr),
}
})
}
ty::PredicateKind::Subtype(p) => {
let p = bound_predicate.rebind(p);
match self.infcx.subtype_predicate(&obligation.cause,
obligation.param_env, p) {
Ok(Ok(InferOk { obligations, .. })) => {
self.evaluate_predicates_recursively(previous_stack,
obligations)
}
Ok(Err(_)) => Ok(EvaluatedToErr),
Err(..) => Ok(EvaluatedToAmbig),
}
}
ty::PredicateKind::Coerce(p) => {
let p = bound_predicate.rebind(p);
match self.infcx.coerce_predicate(&obligation.cause,
obligation.param_env, p) {
Ok(Ok(InferOk { obligations, .. })) => {
self.evaluate_predicates_recursively(previous_stack,
obligations)
}
Ok(Err(_)) => Ok(EvaluatedToErr),
Err(..) => Ok(EvaluatedToAmbig),
}
}
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term))
=> {
if term.is_trivially_wf(self.tcx()) {
return Ok(EvaluatedToOk);
}
let cache = previous_stack.cache;
let dfn = cache.next_dfn();
for stack_term in
previous_stack.cache.wf_args.borrow().iter().rev() {
if stack_term.0 != term { continue; }
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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),
}
}
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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 && sizedness_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 }
928 }
929
930 {}
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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(930u32),
::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(|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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:944",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(944u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:952",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(952u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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(&["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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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!("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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1029",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1029u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1037",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1037u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1041",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1041u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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!("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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:930",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(930u32),
::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)]
931 fn evaluate_trait_predicate_recursively<'o>(
932 &mut self,
933 previous_stack: TraitObligationStackList<'o, 'tcx>,
934 mut obligation: PolyTraitObligation<'tcx>,
935 ) -> Result<EvaluationResult, OverflowError> {
936 debug_assert!(!self.typing_mode().is_coherence(), "old solver coherence");
937
938 if obligation.is_global()
939 && obligation.param_env.caller_bounds().all(|bound| bound.has_param())
940 {
941 debug!("in global");
945 obligation.param_env = ty::ParamEnv::empty();
946 }
947
948 let stack = self.push_stack(previous_stack, &obligation);
949 let fresh_trait_pred = stack.fresh_trait_pred;
950 let param_env = obligation.param_env;
951
952 debug!(?fresh_trait_pred);
953
954 if let Some(result) = self.check_evaluation_cache(param_env, fresh_trait_pred) {
957 debug!("CACHE HIT");
958 return Ok(result);
959 }
960
961 if let Some(result) = stack.cache().get_provisional(fresh_trait_pred) {
962 debug!("PROVISIONAL CACHE HIT");
963 stack.update_reached_depth(result.reached_depth);
964 return Ok(result.result);
965 }
966
967 if let Some(cycle_result) = self.check_evaluation_cycle(&stack) {
973 return Ok(cycle_result);
974 }
975
976 let (result, dep_node) = self.in_task(|this| {
977 let mut result = this.evaluate_stack(&stack)?;
978
979 if EvaluationResult::EvaluatedToErr == result
987 && fresh_trait_pred.has_aliases()
988 && fresh_trait_pred.is_global()
989 {
990 let mut nested_obligations = PredicateObligations::new();
991 let predicate = normalize_with_depth_to(
992 this,
993 param_env,
994 obligation.cause.clone(),
995 obligation.recursion_depth + 1,
996 Unnormalized::new_wip(obligation.predicate),
997 &mut nested_obligations,
998 );
999 if predicate != obligation.predicate {
1000 let mut nested_result = EvaluationResult::EvaluatedToOk;
1001 for obligation in nested_obligations {
1002 nested_result = cmp::max(
1003 this.evaluate_predicate_recursively(previous_stack, obligation)?,
1004 nested_result,
1005 );
1006 }
1007
1008 if nested_result.must_apply_modulo_regions() {
1009 let obligation = obligation.with(this.tcx(), predicate);
1010 result = cmp::max(
1011 nested_result,
1012 this.evaluate_trait_predicate_recursively(previous_stack, obligation)?,
1013 );
1014 }
1015 }
1016 }
1017
1018 Ok::<_, OverflowError>(result)
1019 });
1020
1021 let result = result?;
1022
1023 if !result.must_apply_modulo_regions() {
1024 stack.cache().on_failure(stack.dfn);
1025 }
1026
1027 let reached_depth = stack.reached_depth.get();
1028 if reached_depth >= stack.depth {
1029 debug!("CACHE MISS");
1030 self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
1031 stack.cache().on_completion(stack.dfn);
1032 } else if let Some(_guar) = self.infcx.tainted_by_errors() {
1033 debug!("CACHE MISS (tainted by errors)");
1038 self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
1039 stack.cache().on_completion(stack.dfn);
1040 } else {
1041 debug!("PROVISIONAL");
1042 debug!(
1043 "caching provisionally because {:?} \
1044 is a cycle participant (at depth {}, reached depth {})",
1045 fresh_trait_pred, stack.depth, reached_depth,
1046 );
1047
1048 stack.cache().insert_provisional(stack.dfn, reached_depth, fresh_trait_pred, result);
1049 }
1050
1051 Ok(result)
1052 }
1053
1054 fn check_evaluation_cycle(
1074 &mut self,
1075 stack: &TraitObligationStack<'_, 'tcx>,
1076 ) -> Option<EvaluationResult> {
1077 if let Some(cycle_depth) = stack
1078 .iter()
1079 .skip(1) .find(|prev| {
1081 stack.obligation.param_env == prev.obligation.param_env
1082 && stack.fresh_trait_pred == prev.fresh_trait_pred
1083 })
1084 .map(|stack| stack.depth)
1085 {
1086 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1086",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1086u32),
::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);
1087
1088 stack.update_reached_depth(cycle_depth);
1095
1096 let cycle = stack.iter().skip(1).take_while(|s| s.depth >= cycle_depth);
1102 let tcx = self.tcx();
1103 let cycle = cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
1104 if self.coinductive_match(cycle) {
1105 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1105",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1105u32),
::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");
1106 Some(EvaluatedToOk)
1107 } else {
1108 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1108",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1108u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("evaluate_stack --> recursive, inductive")
as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("evaluate_stack --> recursive, inductive");
1109 Some(EvaluatedToAmbigStackDependent)
1110 }
1111 } else {
1112 None
1113 }
1114 }
1115
1116 fn evaluate_stack<'o>(
1117 &mut self,
1118 stack: &TraitObligationStack<'o, 'tcx>,
1119 ) -> Result<EvaluationResult, OverflowError> {
1120 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());
1121 let unbound_input_types =
1148 stack.fresh_trait_pred.skip_binder().trait_ref.args.types().any(|ty| ty.is_fresh());
1149
1150 if unbound_input_types
1151 && stack.iter().skip(1).any(|prev| {
1152 stack.obligation.param_env == prev.obligation.param_env
1153 && self.match_fresh_trait_preds(stack.fresh_trait_pred, prev.fresh_trait_pred)
1154 })
1155 {
1156 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1156",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1156u32),
::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");
1157 return Ok(EvaluatedToAmbigStackDependent);
1158 }
1159
1160 match self.candidate_from_obligation(stack) {
1161 Ok(Some(c)) => self.evaluate_candidate(stack, &c),
1162 Ok(None) => Ok(EvaluatedToAmbig),
1163 Err(SelectionError::Overflow(OverflowError::Canonical)) => {
1164 Err(OverflowError::Canonical)
1165 }
1166 Err(..) => Ok(EvaluatedToErr),
1167 }
1168 }
1169
1170 pub(crate) fn coinductive_match<I>(&mut self, mut cycle: I) -> bool
1179 where
1180 I: Iterator<Item = ty::Predicate<'tcx>>,
1181 {
1182 cycle.all(|p| match p.kind().skip_binder() {
1183 ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
1184 self.infcx.tcx.trait_is_coinductive(data.def_id())
1185 }
1186 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => {
1187 self.infcx.tcx.features().generic_const_exprs()
1191 }
1192 _ => false,
1193 })
1194 }
1195
1196 {}
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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1199u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1213",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1213u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1199",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1199u32),
::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(
1200 level = "debug",
1201 skip(self, stack),
1202 fields(depth = stack.obligation.recursion_depth),
1203 ret
1204 )]
1205 fn evaluate_candidate<'o>(
1206 &mut self,
1207 stack: &TraitObligationStack<'o, 'tcx>,
1208 candidate: &SelectionCandidate<'tcx>,
1209 ) -> Result<EvaluationResult, OverflowError> {
1210 let mut result = self.evaluation_probe(|this| {
1211 match this.confirm_candidate(stack.obligation, candidate.clone()) {
1212 Ok(selection) => {
1213 debug!(?selection);
1214 if let ImplSource::Builtin(..) = selection
1215 && this.typing_mode().is_reflection()
1216 {
1217 return Ok(EvaluatedToErr);
1218 }
1219 this.evaluate_predicates_recursively(
1220 stack.list(),
1221 selection.nested_obligations().into_iter(),
1222 )
1223 }
1224 Err(..) => Ok(EvaluatedToErr),
1225 }
1226 })?;
1227
1228 if stack.fresh_trait_pred.has_erased_regions() {
1237 result = result.max(EvaluatedToOkModuloRegions);
1238 }
1239
1240 Ok(result)
1241 }
1242
1243 fn check_evaluation_cache(
1244 &self,
1245 param_env: ty::ParamEnv<'tcx>,
1246 trait_pred: ty::PolyTraitClause<'tcx>,
1247 ) -> Option<EvaluationResult> {
1248 let infcx = self.infcx;
1249 let tcx = infcx.tcx;
1250 if self.can_use_global_caches(param_env, trait_pred) {
1251 let key = (infcx.typing_env(param_env), trait_pred);
1252 if let Some(res) = tcx.caches.evaluation_cache.get(&key, tcx) {
1253 Some(res)
1254 } else {
1255 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);
1256 None
1257 }
1258 } else {
1259 self.infcx.evaluation_cache.get(&(param_env, trait_pred), tcx)
1260 }
1261 }
1262
1263 fn insert_evaluation_cache(
1264 &mut self,
1265 param_env: ty::ParamEnv<'tcx>,
1266 trait_pred: ty::PolyTraitClause<'tcx>,
1267 dep_node: DepNodeIndex,
1268 result: EvaluationResult,
1269 ) {
1270 if result.is_stack_dependent() {
1273 return;
1274 }
1275
1276 let infcx = self.infcx;
1277 let tcx = infcx.tcx;
1278 if self.can_use_global_caches(param_env, trait_pred) {
1279 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1279",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1279u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&["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");
1280 tcx.caches.evaluation_cache.insert(
1282 (infcx.typing_env(param_env), trait_pred),
1283 dep_node,
1284 result,
1285 );
1286 return;
1287 } else {
1288 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1288",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1288u32),
::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");
1289 self.infcx.evaluation_cache.insert((param_env, trait_pred), dep_node, result);
1290 }
1291 }
1292
1293 fn check_recursion_depth<T>(
1294 &self,
1295 depth: usize,
1296 error_obligation: &Obligation<'tcx, T>,
1297 ) -> Result<(), OverflowError>
1298 where
1299 T: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + Clone,
1300 {
1301 if !self.infcx.tcx.recursion_limit().value_within_limit(depth) {
1302 match self.query_mode {
1303 TraitQueryMode::Standard => {
1304 if let Some(e) = self.infcx.tainted_by_errors() {
1305 return Err(OverflowError::Error(e));
1306 }
1307 self.infcx.err_ctxt().report_overflow_obligation(error_obligation, true);
1308 }
1309 TraitQueryMode::Canonical => {
1310 return Err(OverflowError::Canonical);
1311 }
1312 }
1313 }
1314 Ok(())
1315 }
1316
1317 #[inline(always)]
1322 fn check_recursion_limit<T: Display + TypeFoldable<TyCtxt<'tcx>>, V>(
1323 &self,
1324 obligation: &Obligation<'tcx, T>,
1325 error_obligation: &Obligation<'tcx, V>,
1326 ) -> Result<(), OverflowError>
1327 where
1328 V: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + Clone,
1329 {
1330 self.check_recursion_depth(obligation.recursion_depth, error_obligation)
1331 }
1332
1333 fn in_task<OP, R>(&mut self, op: OP) -> (R, DepNodeIndex)
1334 where
1335 OP: FnOnce(&mut Self) -> R,
1336 {
1337 self.tcx().dep_graph.with_anon_task(self.tcx(), DepKind::TraitSelect, || op(self))
1338 }
1339
1340 {}
#[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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1342u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1348",
"rustc_trait_selection::traits::select",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1348u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1365",
"rustc_trait_selection::traits::select",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1365u32),
::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))]
1343 fn filter_impls(
1344 &mut self,
1345 mut candidates: Vec<SelectionCandidate<'tcx>>,
1346 obligation: &PolyTraitObligation<'tcx>,
1347 ) -> Vec<SelectionCandidate<'tcx>> {
1348 trace!("{candidates:#?}");
1349 let tcx = self.tcx();
1350
1351 candidates.retain(|candidate| {
1352 if let &ImplCandidate(def_id) = candidate {
1353 match (tcx.impl_polarity(def_id), obligation.polarity()) {
1354 (ty::ImplPolarity::Positive, ty::ClausePolarity::Positive)
1355 | (ty::ImplPolarity::Negative, ty::ClausePolarity::Negative) => true,
1356
1357 _ => false,
1359 }
1360 } else {
1361 true
1362 }
1363 });
1364
1365 trace!("{candidates:#?}");
1366 candidates
1367 }
1368
1369 fn can_use_global_caches(
1371 &self,
1372 param_env: ty::ParamEnv<'tcx>,
1373 pred: ty::PolyTraitClause<'tcx>,
1374 ) -> bool {
1375 if param_env.has_infer() || pred.has_infer() {
1379 return false;
1380 }
1381
1382 match self.typing_mode() {
1383 TypingMode::Typeck { defining_opaque_types_and_generators: defining_opaque_types }
1392 | TypingMode::PostTypeckThroughBorrowck { defining_opaque_types } => {
1393 defining_opaque_types.is_empty()
1394 || (!pred.has_opaque_types() && !pred.has_coroutines())
1395 }
1396 TypingMode::Reflection => false,
1399 TypingMode::PostBorrowck { .. } => true,
1402 TypingMode::PostAnalysis | TypingMode::Codegen => true,
1408 TypingMode::Coherence => {
1409 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("old solver coherence")));
}unreachable!("old solver coherence")
1410 }
1411 }
1412 }
1413
1414 fn check_candidate_cache(
1415 &mut self,
1416 param_env: ty::ParamEnv<'tcx>,
1417 cache_fresh_trait_pred: ty::PolyTraitClause<'tcx>,
1418 ) -> Option<SelectionResult<'tcx, SelectionCandidate<'tcx>>> {
1419 let infcx = self.infcx;
1420 let tcx = infcx.tcx;
1421 let pred = cache_fresh_trait_pred.skip_binder();
1422
1423 if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
1424 if let Some(res) =
1425 tcx.caches.selection_cache.get(&(infcx.typing_env(param_env), pred), tcx)
1426 {
1427 return Some(res);
1428 } else if truecfg!(debug_assertions) {
1429 match infcx.selection_cache.get(&(param_env, pred), tcx) {
1430 None | Some(Err(SelectionError::Overflow(OverflowError::Canonical))) => {}
1431 res => ::rustc_span::macros::bug_impl(None,
format_args!("unexpected local cache result: {0:?}", res),
Location::caller())bug!("unexpected local cache result: {res:?}"),
1432 }
1433 }
1434 }
1435
1436 infcx.selection_cache.get(&(param_env, pred), tcx)
1440 }
1441
1442 fn can_cache_candidate(
1459 &self,
1460 result: &SelectionResult<'tcx, SelectionCandidate<'tcx>>,
1461 ) -> bool {
1462 match result {
1463 Ok(Some(SelectionCandidate::ParamCandidate(trait_ref))) => !trait_ref.has_infer(),
1464 _ => true,
1465 }
1466 }
1467
1468 {}
#[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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1468u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1481",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1481u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1489",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1489u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1502",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1502u32),
::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")]
1469 fn insert_candidate_cache(
1470 &mut self,
1471 param_env: ty::ParamEnv<'tcx>,
1472 cache_fresh_trait_pred: ty::PolyTraitClause<'tcx>,
1473 dep_node: DepNodeIndex,
1474 candidate: SelectionResult<'tcx, SelectionCandidate<'tcx>>,
1475 ) {
1476 let infcx = self.infcx;
1477 let tcx = infcx.tcx;
1478 let pred = cache_fresh_trait_pred.skip_binder();
1479
1480 if !self.can_cache_candidate(&candidate) {
1481 debug!(?pred, ?candidate, "insert_candidate_cache - candidate is not cacheable");
1482 return;
1483 }
1484
1485 if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
1486 if let Err(SelectionError::Overflow(OverflowError::Canonical)) = candidate {
1487 } else {
1489 debug!(?pred, ?candidate, "insert_candidate_cache global");
1490 debug_assert!(!candidate.has_infer());
1491
1492 tcx.caches.selection_cache.insert(
1494 (infcx.typing_env(param_env), pred),
1495 dep_node,
1496 candidate,
1497 );
1498 return;
1499 }
1500 }
1501
1502 debug!(?pred, ?candidate, "insert_candidate_cache local");
1503 self.infcx.selection_cache.insert((param_env, pred), dep_node, candidate);
1504 }
1505
1506 pub(super) fn for_each_item_bound<T>(
1512 &mut self,
1513 mut self_ty: Ty<'tcx>,
1514 mut for_each: impl FnMut(
1515 &mut Self,
1516 ty::Clause<'tcx>,
1517 usize,
1518 AliasBoundKind,
1519 ) -> ControlFlow<T, ()>,
1520 on_ambiguity: impl FnOnce(),
1521 ) -> ControlFlow<T, ()> {
1522 let mut idx = 0;
1523 let mut alias_bound_kind = AliasBoundKind::SelfBounds;
1524
1525 loop {
1526 let (alias_ty, def_id) = match *self_ty.kind() {
1527 ty::Alias(
1528 _,
1529 alias_ty @ ty::AliasTy {
1530 kind: ty::Projection { def_id } | ty::Opaque { def_id },
1531 ..
1532 },
1533 ) => (alias_ty, def_id),
1534 ty::Infer(ty::TyVar(_)) => {
1535 on_ambiguity();
1536 return ControlFlow::Continue(());
1537 }
1538 _ => return ControlFlow::Continue(()),
1539 };
1540
1541 let relevant_bounds = if alias_bound_kind == AliasBoundKind::NonSelfBounds {
1546 self.tcx().item_non_self_bounds(def_id)
1547 } else {
1548 self.tcx().item_self_bounds(def_id)
1549 };
1550
1551 for bound in relevant_bounds.instantiate(self.tcx(), alias_ty.args).skip_norm_wip() {
1552 for_each(self, bound, idx, alias_bound_kind)?;
1553 idx += 1;
1554 }
1555
1556 if #[allow(non_exhaustive_omitted_patterns)] match alias_ty.kind {
ty::Projection { .. } => true,
_ => false,
}matches!(alias_ty.kind, ty::Projection { .. }) {
1557 self_ty = alias_ty.self_ty();
1558 } else {
1559 return ControlFlow::Continue(());
1560 }
1561
1562 alias_bound_kind = AliasBoundKind::NonSelfBounds;
1563 }
1564 }
1565
1566 fn match_normalize_trait_ref(
1570 &mut self,
1571 obligation: &PolyTraitObligation<'tcx>,
1572 placeholder_trait_ref: ty::TraitRef<'tcx>,
1573 trait_bound: ty::PolyTraitRef<'tcx>,
1574 ) -> Result<Option<ty::TraitRef<'tcx>>, ()> {
1575 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());
1576 if placeholder_trait_ref.def_id != trait_bound.def_id() {
1577 return Err(());
1579 }
1580
1581 let drcx = DeepRejectCtxt::relate_rigid_rigid(self.infcx.tcx);
1582 let obligation_args = obligation.predicate.skip_binder().trait_ref.args;
1583 if !drcx.args_may_unify(obligation_args, trait_bound.skip_binder().args) {
1584 return Err(());
1585 }
1586
1587 let trait_bound = self.infcx.instantiate_binder_with_fresh_vars(
1588 obligation.cause.span,
1589 HigherRankedType,
1590 trait_bound,
1591 );
1592 let Normalized { value: trait_bound, obligations: _ } = normalize_with_depth(
1593 self,
1594 obligation.param_env,
1595 obligation.cause.clone(),
1596 obligation.recursion_depth + 1,
1597 ty::Unnormalized::new_wip(trait_bound),
1598 );
1599 self.infcx
1600 .at(&obligation.cause, obligation.param_env)
1601 .eq(DefineOpaqueTypes::No, placeholder_trait_ref, trait_bound)
1602 .map(|InferOk { obligations: _, value: () }| {
1603 if !trait_bound.has_infer() && !trait_bound.has_placeholders() {
1606 Some(trait_bound)
1607 } else {
1608 None
1609 }
1610 })
1611 .map_err(|_| ())
1612 }
1613
1614 fn where_clause_may_apply<'o>(
1615 &mut self,
1616 stack: &TraitObligationStack<'o, 'tcx>,
1617 where_clause_trait_ref: ty::PolyTraitRef<'tcx>,
1618 ) -> Result<EvaluationResult, OverflowError> {
1619 self.evaluation_probe(|this| {
1620 match this.match_where_clause_trait_ref(stack.obligation, where_clause_trait_ref) {
1621 Ok(obligations) => this.evaluate_predicates_recursively(stack.list(), obligations),
1622 Err(()) => Ok(EvaluatedToErr),
1623 }
1624 })
1625 }
1626
1627 pub(super) fn match_projection_projections(
1634 &mut self,
1635 obligation: &ProjectionTermObligation<'tcx>,
1636 env_predicate: PolyProjectionClause<'tcx>,
1637 potentially_unnormalized_candidates: bool,
1638 ) -> ProjectionMatchesProjection {
1639 let def_id = obligation.predicate.expect_projection_def_id();
1640 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());
1641
1642 let mut nested_obligations = PredicateObligations::new();
1643 let infer_predicate = self.infcx.instantiate_binder_with_fresh_vars(
1644 obligation.cause.span,
1645 BoundRegionConversionTime::HigherRankedType,
1646 env_predicate,
1647 );
1648 let mut infer_projection = infer_predicate.projection_term;
1649 if potentially_unnormalized_candidates {
1650 infer_projection = normalize_with_depth_to(
1651 self,
1652 obligation.param_env,
1653 obligation.cause.clone(),
1654 obligation.recursion_depth + 1,
1655 ty::Unnormalized::new_wip(infer_projection),
1656 &mut nested_obligations,
1657 )
1658 }
1659
1660 let is_match = self
1661 .infcx
1662 .at(&obligation.cause, obligation.param_env)
1663 .eq(DefineOpaqueTypes::No, obligation.predicate, infer_projection)
1664 .is_ok_and(|InferOk { obligations, value: () }| {
1665 self.evaluate_predicates_recursively(
1666 TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
1667 nested_obligations.into_iter().chain(obligations),
1668 )
1669 .is_ok_and(|res| res.may_apply())
1670 });
1671
1672 if is_match {
1673 let generics = self.tcx().generics_of(def_id);
1674 if !generics.is_own_empty()
1683 && obligation.predicate.args[generics.parent_count..].iter().any(|&p| {
1684 p.has_non_region_infer()
1685 && match p.kind() {
1686 ty::GenericArgKind::Const(ct) => {
1687 self.infcx.shallow_resolve_const(ct) != ct
1688 }
1689 ty::GenericArgKind::Type(ty) => self.infcx.shallow_resolve(ty) != ty,
1690 ty::GenericArgKind::Lifetime(_) => false,
1691 }
1692 })
1693 {
1694 ProjectionMatchesProjection::Ambiguous
1695 } else {
1696 ProjectionMatchesProjection::Yes
1697 }
1698 } else {
1699 ProjectionMatchesProjection::No
1700 }
1701 }
1702}
1703
1704impl<'tcx> SelectionContext<'_, 'tcx> {
1711 {}
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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1715u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("has_non_region_infer")
}> =
::tracing::__macro_support::FieldName::new("has_non_region_infer");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidate_preference_mode")
}> =
::tracing::__macro_support::FieldName::new("candidate_preference_mode");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("candidates")
}> =
::tracing::__macro_support::FieldName::new("candidates");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&has_non_region_infer
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidate_preference_mode)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&candidates)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Option<SelectionCandidate<'tcx>> = loop {};
return __tracing_attr_fake_return;
}
{
if candidates.len() == 1 {
return Some(candidates.pop().unwrap().candidate);
}
let mut sized_candidates =
candidates.iter().filter(|c|
#[allow(non_exhaustive_omitted_patterns)] match c.candidate
{
SizedCandidate => true,
_ => false,
});
if let Some(sized_candidate) = sized_candidates.next() {
if true {
{
match (&sized_candidates.next(), &None) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};
};
if sized_candidate.evaluation.must_apply_modulo_regions() {
return Some(sized_candidate.candidate.clone());
} else { return None; }
}
'search_victim: loop {
for (i, this) in candidates.iter().enumerate() {
let ParamCandidate(this) = this.candidate else { continue };
for (j, other) in candidates.iter().enumerate() {
if i == j { continue; }
let ParamCandidate(other) =
other.candidate else { continue };
if this == other {
candidates.remove(j);
continue 'search_victim;
}
if this.skip_binder().trait_ref ==
other.skip_binder().trait_ref &&
this.skip_binder().polarity == other.skip_binder().polarity
&& !this.skip_binder().trait_ref.has_escaping_bound_vars() {
candidates.remove(j);
continue 'search_victim;
}
}
}
break;
}
let mut alias_bounds =
candidates.iter().filter_map(|c|
{
if let ProjectionCandidate { idx, kind } = c.candidate {
Some((idx, kind))
} else { None }
});
if #[allow(non_exhaustive_omitted_patterns)] match candidate_preference_mode
{
CandidatePreferenceMode::Marker => true,
_ => false,
} {
match alias_bounds.clone().filter_map(|(idx, kind)|
(kind ==
AliasBoundKind::SelfBounds).then_some(idx)).try_reduce(|c1,
c2|
if has_non_region_infer { None } else { Some(c1.min(c2)) })
{
Some(Some(idx)) => {
return Some(ProjectionCandidate {
idx,
kind: AliasBoundKind::SelfBounds,
});
}
Some(None) => {}
None => return None,
}
}
let is_global =
|c: ty::PolyTraitClause<'tcx>|
c.is_global() && !c.has_bound_vars();
let param_candidates =
candidates.iter().filter_map(|c|
if let ParamCandidate(p) = c.candidate {
Some(p)
} else { None });
let mut has_global_bounds = false;
let mut param_candidate = None;
for c in param_candidates {
if is_global(c) {
has_global_bounds = true;
} else if param_candidate.replace(c).is_some() {
return None;
}
}
if let Some(predicate) = param_candidate {
if has_global_bounds {
return None;
} else { return Some(ParamCandidate(predicate)); }
}
match alias_bounds.try_reduce(|(c1, k1), (c2, k2)|
{
if has_non_region_infer {
None
} else if c1 < c2 { Some((c1, k1)) } else { Some((c2, k2)) }
}) {
Some(Some((idx, kind))) =>
return Some(ProjectionCandidate { idx, kind }),
Some(None) => {}
None => return None,
}
let object_bound =
candidates.iter().filter_map(|c|
if let ObjectCandidate(i) = c.candidate {
Some(i)
} else {
None
}).try_reduce(|c1, c2|
if has_non_region_infer { None } else { Some(c1.min(c2)) });
match object_bound {
Some(Some(index)) => {
return if has_non_region_infer &&
candidates.iter().any(|c|
#[allow(non_exhaustive_omitted_patterns)] match c.candidate
{
ImplCandidate(_) => true,
_ => false,
}) {
None
} else { Some(ObjectCandidate(index)) };
}
Some(None) => {}
None => return None,
}
let upcast_bound =
candidates.iter().filter_map(|c|
{
if let TraitUpcastingUnsizeCandidate(i) = c.candidate {
Some(i)
} else { None }
}).try_reduce(|c1, c2|
if has_non_region_infer { None } else { Some(c1.min(c2)) });
match upcast_bound {
Some(Some(index)) =>
return Some(TraitUpcastingUnsizeCandidate(index)),
Some(None) => {}
None => return None,
}
let impls =
candidates.iter().filter_map(|c|
{
if let ImplCandidate(def_id) = c.candidate {
Some((def_id, c.evaluation))
} else { None }
});
let mut impl_candidate = None;
for c in impls {
if let Some(prev) = impl_candidate.replace(c) {
if self.prefer_lhs_over_victim(has_non_region_infer, c,
prev.0)
{} else if self.prefer_lhs_over_victim(has_non_region_infer,
prev, c.0) {
impl_candidate = Some(prev);
} else { return None; }
}
}
if let Some((def_id, _evaluation)) = impl_candidate {
if candidates.iter().all(|c|
match c.candidate {
SizedCandidate | BuiltinCandidate | TransmutabilityCandidate
| AutoImplCandidate | ClosureCandidate { .. } |
AsyncClosureCandidate | AsyncFnKindHelperCandidate |
CoroutineCandidate | FutureCandidate | IteratorCandidate |
AsyncIteratorCandidate | FnPointerCandidate |
TraitAliasCandidate | TraitUpcastingUnsizeCandidate(_) |
BuiltinObjectCandidate | BuiltinUnsizeCandidate |
TryAsDynCandidate | BikeshedGuaranteedNoDropCandidate =>
false,
ParamCandidate(_) | ImplCandidate(_) => true,
ProjectionCandidate { .. } | ObjectCandidate(_) =>
::core::panicking::panic("internal error: entered unreachable code"),
}) {
return Some(ImplCandidate(def_id));
} else { return None; }
}
if candidates.len() == 1 {
Some(candidates.pop().unwrap().candidate)
} else {
let mut not_a_global_where_bound =
candidates.into_iter().filter(|c|
!#[allow(non_exhaustive_omitted_patterns)] match c.candidate
{
ParamCandidate(p) if is_global(p) => true,
_ => false,
});
not_a_global_where_bound.next().map(|c|
c.candidate).filter(|_|
not_a_global_where_bound.next().is_none())
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:1715",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(1715u32),
::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)]
1716 fn winnow_candidates(
1717 &mut self,
1718 has_non_region_infer: bool,
1719 candidate_preference_mode: CandidatePreferenceMode,
1720 mut candidates: Vec<EvaluatedCandidate<'tcx>>,
1721 ) -> Option<SelectionCandidate<'tcx>> {
1722 if candidates.len() == 1 {
1723 return Some(candidates.pop().unwrap().candidate);
1724 }
1725
1726 let mut sized_candidates =
1728 candidates.iter().filter(|c| matches!(c.candidate, SizedCandidate));
1729 if let Some(sized_candidate) = sized_candidates.next() {
1730 debug_assert_eq!(sized_candidates.next(), None);
1733 if sized_candidate.evaluation.must_apply_modulo_regions() {
1737 return Some(sized_candidate.candidate.clone());
1738 } else {
1739 return None;
1740 }
1741 }
1742
1743 'search_victim: loop {
1747 for (i, this) in candidates.iter().enumerate() {
1748 let ParamCandidate(this) = this.candidate else { continue };
1749 for (j, other) in candidates.iter().enumerate() {
1750 if i == j {
1751 continue;
1752 }
1753
1754 let ParamCandidate(other) = other.candidate else { continue };
1755 if this == other {
1756 candidates.remove(j);
1757 continue 'search_victim;
1758 }
1759
1760 if this.skip_binder().trait_ref == other.skip_binder().trait_ref
1761 && this.skip_binder().polarity == other.skip_binder().polarity
1762 && !this.skip_binder().trait_ref.has_escaping_bound_vars()
1763 {
1764 candidates.remove(j);
1765 continue 'search_victim;
1766 }
1767 }
1768 }
1769
1770 break;
1771 }
1772
1773 let mut alias_bounds = candidates.iter().filter_map(|c| {
1774 if let ProjectionCandidate { idx, kind } = c.candidate {
1775 Some((idx, kind))
1776 } else {
1777 None
1778 }
1779 });
1780 if matches!(candidate_preference_mode, CandidatePreferenceMode::Marker) {
1783 match alias_bounds
1784 .clone()
1785 .filter_map(|(idx, kind)| (kind == AliasBoundKind::SelfBounds).then_some(idx))
1786 .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) })
1787 {
1788 Some(Some(idx)) => {
1789 return Some(ProjectionCandidate { idx, kind: AliasBoundKind::SelfBounds });
1790 }
1791 Some(None) => {}
1792 None => return None,
1793 }
1794 }
1795
1796 let is_global = |c: ty::PolyTraitClause<'tcx>| c.is_global() && !c.has_bound_vars();
1803 let param_candidates = candidates
1804 .iter()
1805 .filter_map(|c| if let ParamCandidate(p) = c.candidate { Some(p) } else { None });
1806 let mut has_global_bounds = false;
1807 let mut param_candidate = None;
1808 for c in param_candidates {
1809 if is_global(c) {
1810 has_global_bounds = true;
1811 } else if param_candidate.replace(c).is_some() {
1812 return None;
1814 }
1815 }
1816 if let Some(predicate) = param_candidate {
1817 if has_global_bounds {
1819 return None;
1820 } else {
1821 return Some(ParamCandidate(predicate));
1822 }
1823 }
1824
1825 match alias_bounds.try_reduce(|(c1, k1), (c2, k2)| {
1830 if has_non_region_infer {
1831 None
1832 } else if c1 < c2 {
1833 Some((c1, k1))
1834 } else {
1835 Some((c2, k2))
1836 }
1837 }) {
1838 Some(Some((idx, kind))) => return Some(ProjectionCandidate { idx, kind }),
1839 Some(None) => {}
1840 None => return None,
1841 }
1842
1843 let object_bound = candidates
1852 .iter()
1853 .filter_map(|c| if let ObjectCandidate(i) = c.candidate { Some(i) } else { None })
1854 .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) });
1855 match object_bound {
1856 Some(Some(index)) => {
1857 return if has_non_region_infer
1858 && candidates.iter().any(|c| matches!(c.candidate, ImplCandidate(_)))
1859 {
1860 None
1861 } else {
1862 Some(ObjectCandidate(index))
1863 };
1864 }
1865 Some(None) => {}
1866 None => return None,
1867 }
1868 let upcast_bound = candidates
1870 .iter()
1871 .filter_map(|c| {
1872 if let TraitUpcastingUnsizeCandidate(i) = c.candidate { Some(i) } else { None }
1873 })
1874 .try_reduce(|c1, c2| if has_non_region_infer { None } else { Some(c1.min(c2)) });
1875 match upcast_bound {
1876 Some(Some(index)) => return Some(TraitUpcastingUnsizeCandidate(index)),
1877 Some(None) => {}
1878 None => return None,
1879 }
1880
1881 let impls = candidates.iter().filter_map(|c| {
1883 if let ImplCandidate(def_id) = c.candidate {
1884 Some((def_id, c.evaluation))
1885 } else {
1886 None
1887 }
1888 });
1889 let mut impl_candidate = None;
1890 for c in impls {
1891 if let Some(prev) = impl_candidate.replace(c) {
1892 if self.prefer_lhs_over_victim(has_non_region_infer, c, prev.0) {
1893 } else if self.prefer_lhs_over_victim(has_non_region_infer, prev, c.0) {
1895 impl_candidate = Some(prev);
1897 } else {
1898 return None;
1900 }
1901 }
1902 }
1903 if let Some((def_id, _evaluation)) = impl_candidate {
1904 if candidates.iter().all(|c| match c.candidate {
1907 SizedCandidate
1908 | BuiltinCandidate
1909 | TransmutabilityCandidate
1910 | AutoImplCandidate
1911 | ClosureCandidate { .. }
1912 | AsyncClosureCandidate
1913 | AsyncFnKindHelperCandidate
1914 | CoroutineCandidate
1915 | FutureCandidate
1916 | IteratorCandidate
1917 | AsyncIteratorCandidate
1918 | FnPointerCandidate
1919 | TraitAliasCandidate
1920 | TraitUpcastingUnsizeCandidate(_)
1921 | BuiltinObjectCandidate
1922 | BuiltinUnsizeCandidate
1923 | TryAsDynCandidate
1924 | BikeshedGuaranteedNoDropCandidate => false,
1925 ParamCandidate(_) | ImplCandidate(_) => true,
1928 ProjectionCandidate { .. } | ObjectCandidate(_) => unreachable!(),
1929 }) {
1930 return Some(ImplCandidate(def_id));
1931 } else {
1932 return None;
1933 }
1934 }
1935
1936 if candidates.len() == 1 {
1937 Some(candidates.pop().unwrap().candidate)
1938 } else {
1939 let mut not_a_global_where_bound = candidates
1942 .into_iter()
1943 .filter(|c| !matches!(c.candidate, ParamCandidate(p) if is_global(p)));
1944 not_a_global_where_bound
1945 .next()
1946 .map(|c| c.candidate)
1947 .filter(|_| not_a_global_where_bound.next().is_none())
1948 }
1949 }
1950
1951 fn prefer_lhs_over_victim(
1952 &self,
1953 has_non_region_infer: bool,
1954 (lhs, lhs_evaluation): (DefId, EvaluationResult),
1955 victim: DefId,
1956 ) -> bool {
1957 let tcx = self.tcx();
1958 if lhs_evaluation.must_apply_modulo_regions() {
1965 if tcx.specializes((lhs, victim)) {
1966 return true;
1967 }
1968 }
1969
1970 match tcx.impls_are_allowed_to_overlap(lhs, victim) {
1971 Some(ty::ImplOverlapKind::Permitted { marker: false }) => {
1974 lhs_evaluation.must_apply_considering_regions()
1975 }
1976 Some(ty::ImplOverlapKind::Permitted { marker: true }) => {
1977 !has_non_region_infer && lhs_evaluation.must_apply_considering_regions()
2017 }
2018 None => false,
2019 }
2020 }
2021}
2022
2023impl<'tcx> SelectionContext<'_, 'tcx> {
2024 fn sizedness_conditions(
2025 &mut self,
2026 self_ty: Ty<'tcx>,
2027 sizedness: SizedTraitKind,
2028 ) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
2029 match self_ty.kind() {
2030 ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2031 | ty::Uint(_)
2032 | ty::Int(_)
2033 | ty::Bool
2034 | ty::Float(_)
2035 | ty::FnDef(..)
2036 | ty::FnPtr(..)
2037 | ty::RawPtr(..)
2038 | ty::Char
2039 | ty::Ref(..)
2040 | ty::Coroutine(..)
2041 | ty::CoroutineWitness(..)
2042 | ty::Array(..)
2043 | ty::Closure(..)
2044 | ty::CoroutineClosure(..)
2045 | ty::Never
2046 | ty::Error(_) => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2047
2048 ty::Str | ty::Slice(_) | ty::Dynamic(..) => match sizedness {
2049 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"),
2050 SizedTraitKind::MetaSized => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2051 },
2052
2053 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"),
2054
2055 ty::Tuple(tys) => {
2056 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]))
2057 }
2058
2059 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]),
2060
2061 ty::Adt(def, args) => {
2062 if let Some(crit) = def.sizedness_constraint(self.tcx(), sizedness) {
2063 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()])
2064 } else {
2065 ty::Binder::dummy(::alloc::vec::Vec::new()vec![])
2066 }
2067 }
2068
2069 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]),
2070
2071 ty::Alias(..)
2072 | ty::Param(_)
2073 | ty::Placeholder(..)
2074 | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_))
2075 | ty::Bound(..) => {
2076 ::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);
2077 }
2078 }
2079 }
2080
2081 fn copy_clone_conditions(&mut self, self_ty: Ty<'tcx>) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
2082 match *self_ty.kind() {
2083 ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) => ty::Binder::dummy(::alloc::vec::Vec::new()vec![]),
2084
2085 ty::Uint(_)
2086 | ty::Int(_)
2087 | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2088 | ty::Bool
2089 | ty::Float(_)
2090 | ty::Char
2091 | ty::RawPtr(..)
2092 | ty::Never
2093 | ty::Ref(_, _, hir::Mutability::Not)
2094 | ty::Array(..) => {
2095 {
::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")
2096 }
2097
2098 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"),
2101
2102 ty::Tuple(tys) => {
2103 ty::Binder::dummy(tys.iter().collect())
2105 }
2106
2107 ty::Pat(ty, _) => {
2108 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])
2110 }
2111
2112 ty::Coroutine(def_id, args) => match self.tcx().coroutine_movability(def_id) {
2113 hir::Movability::Static => {
2114 {
::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")
2115 }
2116 hir::Movability::Movable => {
2117 if self.tcx().features().coroutine_clone() {
2118 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![
2119 args.as_coroutine().tupled_upvars_ty(),
2120 Ty::new_coroutine_witness_for_coroutine(self.tcx(), def_id, args),
2121 ])
2122 } else {
2123 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("tried to assemble `Clone` for coroutine without enabled feature")));
}unreachable!(
2124 "tried to assemble `Clone` for coroutine without enabled feature"
2125 )
2126 }
2127 }
2128 },
2129
2130 ty::CoroutineWitness(def_id, args) => self
2131 .infcx
2132 .tcx
2133 .coroutine_hidden_types(def_id)
2134 .instantiate(self.infcx.tcx, args)
2135 .skip_norm_wip()
2136 .map_bound(|witness| witness.types.to_vec()),
2137
2138 ty::Closure(_, args) => ty::Binder::dummy(args.as_closure().upvar_tys().to_vec()),
2139
2140 ty::CoroutineClosure(_, args) => {
2141 ty::Binder::dummy(args.as_coroutine_closure().upvar_tys().to_vec())
2142 }
2143
2144 ty::Foreign(..)
2145 | ty::Str
2146 | ty::Slice(_)
2147 | ty::Dynamic(..)
2148 | ty::Adt(..)
2149 | ty::Alias(..)
2150 | ty::Param(..)
2151 | ty::Placeholder(..)
2152 | ty::Bound(..)
2153 | ty::Ref(_, _, ty::Mutability::Mut)
2154 | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2155 ::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);
2156 }
2157 }
2158 }
2159
2160 fn coroutine_is_gen(&mut self, self_ty: Ty<'tcx>) -> bool {
2161 #[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, ..)
2162 if self.tcx().coroutine_is_gen(did))
2163 }
2164
2165 {}
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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2176u32),
::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::panic("internal error: entered unreachable code")
} else {
let ty = self.tcx().type_of_opaque(def_id);
ty::Binder::dummy(AutoImplConstituents {
types: ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[ty.instantiate(self.tcx(), args).skip_norm_wip()])),
assumptions: ::alloc::vec::Vec::new(),
})
}
}
})
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:2176",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2176u32),
::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)]
2177 fn constituent_types_for_auto_trait(
2178 &self,
2179 t: Ty<'tcx>,
2180 ) -> Result<ty::Binder<'tcx, AutoImplConstituents<'tcx>>, SelectionError<'tcx>> {
2181 Ok(match *t.kind() {
2182 ty::Uint(_)
2183 | ty::Int(_)
2184 | ty::Bool
2185 | ty::Float(_)
2186 | ty::FnDef(..)
2187 | ty::FnPtr(..)
2188 | ty::Error(_)
2189 | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
2190 | ty::Never
2191 | ty::Char => {
2192 ty::Binder::dummy(AutoImplConstituents { types: vec![], assumptions: vec![] })
2193 }
2194
2195 ty::Foreign(..) => {
2199 ty::Binder::dummy(AutoImplConstituents { types: vec![], assumptions: vec![] })
2200 }
2201
2202 ty::UnsafeBinder(ty) => {
2203 ty.map_bound(|ty| AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2204 }
2205
2206 ty::Str => ty::Binder::dummy(AutoImplConstituents {
2208 types: vec![Ty::new_slice(self.tcx(), self.tcx().types.u8)],
2209 assumptions: vec![],
2210 }),
2211
2212 ty::Placeholder(..)
2213 | ty::Dynamic(..)
2214 | ty::Param(..)
2215 | ty::Alias(
2216 _,
2217 ty::AliasTy {
2218 kind: ty::Projection { .. } | ty::Inherent { .. } | ty::Free { .. },
2219 ..
2220 },
2221 )
2222 | ty::Bound(..)
2223 | ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2224 bug!("asked to assemble constituent types of unexpected type: {:?}", t);
2225 }
2226
2227 ty::RawPtr(element_ty, _) | ty::Ref(_, element_ty, _) => {
2228 ty::Binder::dummy(AutoImplConstituents {
2229 types: vec![element_ty],
2230 assumptions: vec![],
2231 })
2232 }
2233
2234 ty::Pat(ty, _) | ty::Array(ty, _) | ty::Slice(ty) => {
2235 ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2236 }
2237
2238 ty::Tuple(tys) => {
2239 ty::Binder::dummy(AutoImplConstituents {
2241 types: tys.iter().collect(),
2242 assumptions: vec![],
2243 })
2244 }
2245
2246 ty::Closure(_, args) => {
2247 let ty = self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty());
2248 ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2249 }
2250
2251 ty::CoroutineClosure(_, args) => {
2252 let ty = self.infcx.shallow_resolve(args.as_coroutine_closure().tupled_upvars_ty());
2253 ty::Binder::dummy(AutoImplConstituents { types: vec![ty], assumptions: vec![] })
2254 }
2255
2256 ty::Coroutine(def_id, args) => {
2257 let ty = self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty());
2258 let tcx = self.tcx();
2259 let witness = Ty::new_coroutine_witness_for_coroutine(tcx, def_id, args);
2260 ty::Binder::dummy(AutoImplConstituents {
2261 types: vec![ty, witness],
2262 assumptions: vec![],
2263 })
2264 }
2265
2266 ty::CoroutineWitness(def_id, args) => self
2267 .infcx
2268 .tcx
2269 .coroutine_hidden_types(def_id)
2270 .instantiate(self.infcx.tcx, args)
2271 .skip_norm_wip()
2272 .map_bound(|witness| AutoImplConstituents {
2273 types: witness.types.to_vec(),
2274 assumptions: witness.assumptions.to_vec(),
2275 }),
2276
2277 ty::Adt(def, args) if def.is_phantom_data() => {
2279 ty::Binder::dummy(AutoImplConstituents {
2280 types: args.types().collect(),
2281 assumptions: vec![],
2282 })
2283 }
2284
2285 ty::Adt(def, args) => ty::Binder::dummy(AutoImplConstituents {
2286 types: def.all_fields().map(|f| f.ty(self.tcx(), args).skip_norm_wip()).collect(),
2287 assumptions: vec![],
2288 }),
2289
2290 ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) => {
2291 if self.infcx.can_define_opaque_ty(def_id) {
2292 unreachable!()
2293 } else {
2294 let ty = self.tcx().type_of_opaque(def_id);
2298 ty::Binder::dummy(AutoImplConstituents {
2299 types: vec![ty.instantiate(self.tcx(), args).skip_norm_wip()],
2300 assumptions: vec![],
2301 })
2302 }
2303 }
2304 })
2305 }
2306
2307 fn collect_predicates_for_types(
2308 &mut self,
2309 param_env: ty::ParamEnv<'tcx>,
2310 cause: ObligationCause<'tcx>,
2311 recursion_depth: usize,
2312 trait_def_id: DefId,
2313 types: Vec<Ty<'tcx>>,
2314 ) -> PredicateObligations<'tcx> {
2315 types
2330 .into_iter()
2331 .flat_map(|placeholder_ty| {
2332 let Normalized { value: normalized_ty, mut obligations } = normalize_with_depth(
2333 self,
2334 param_env,
2335 cause.clone(),
2336 recursion_depth,
2337 Unnormalized::new_wip(placeholder_ty),
2338 );
2339
2340 let tcx = self.tcx();
2341 let trait_ref = if tcx.generics_of(trait_def_id).own_params.len() == 1 {
2342 ty::TraitRef::new(tcx, trait_def_id, [normalized_ty])
2343 } else {
2344 let err_args = ty::GenericArgs::extend_with_error(
2347 tcx,
2348 trait_def_id,
2349 &[normalized_ty.into()],
2350 );
2351 ty::TraitRef::new_from_args(tcx, trait_def_id, err_args)
2352 };
2353
2354 let obligation = Obligation::new(self.tcx(), cause.clone(), param_env, trait_ref);
2355 obligations.push(obligation);
2356 obligations
2357 })
2358 .collect()
2359 }
2360
2361 fn rematch_impl(
2372 &mut self,
2373 impl_def_id: DefId,
2374 obligation: &PolyTraitObligation<'tcx>,
2375 ) -> Normalized<'tcx, GenericArgsRef<'tcx>> {
2376 let impl_trait_header = self.tcx().impl_trait_header(impl_def_id);
2377 match self.match_impl(impl_def_id, impl_trait_header, obligation) {
2378 Ok(args) => args,
2379 Err(()) => {
2380 let predicate = self.infcx.deeply_resolve_ignoring_regions(obligation.predicate);
2381 ::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")
2382 }
2383 }
2384 }
2385
2386 {}
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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2386u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::traits::select"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("impl_def_id")
}> =
::tracing::__macro_support::FieldName::new("impl_def_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("impl_trait_header")
}> =
::tracing::__macro_support::FieldName::new("impl_trait_header");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("obligation")
}> =
::tracing::__macro_support::FieldName::new("obligation");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_def_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&impl_trait_header)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&obligation)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<Normalized<'tcx, GenericArgsRef<'tcx>>, ()> =
loop {};
return __tracing_attr_fake_return;
}
{
let placeholder_obligation =
self.infcx.enter_forall_and_leak_universe(obligation.predicate);
let placeholder_obligation_trait_ref =
placeholder_obligation.trait_ref;
let impl_args =
self.infcx.fresh_args_for_item(obligation.cause.span,
impl_def_id);
let trait_ref =
impl_trait_header.trait_ref.instantiate(self.tcx(),
impl_args);
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/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/48f4b05538b8eca412137042d9647a61e692c6b3/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_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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:2412",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2412u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:2425",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2425u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:2433",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2433u32),
::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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:2386",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2386u32),
::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)]
2387 fn match_impl(
2388 &mut self,
2389 impl_def_id: DefId,
2390 impl_trait_header: ty::ImplTraitHeader<'tcx>,
2391 obligation: &PolyTraitObligation<'tcx>,
2392 ) -> Result<Normalized<'tcx, GenericArgsRef<'tcx>>, ()> {
2393 let placeholder_obligation =
2394 self.infcx.enter_forall_and_leak_universe(obligation.predicate);
2395 let placeholder_obligation_trait_ref = placeholder_obligation.trait_ref;
2396
2397 let impl_args = self.infcx.fresh_args_for_item(obligation.cause.span, impl_def_id);
2398
2399 let trait_ref = impl_trait_header.trait_ref.instantiate(self.tcx(), impl_args);
2400 debug!(?impl_trait_header);
2401
2402 let mut nested_obligations = PredicateObligations::new();
2403 let impl_trait_ref = normalize_with_depth_to(
2404 self,
2405 obligation.param_env,
2406 obligation.cause.clone(),
2407 obligation.recursion_depth + 1,
2408 trait_ref,
2409 &mut nested_obligations,
2410 );
2411
2412 debug!(?impl_trait_ref, ?placeholder_obligation_trait_ref);
2413
2414 let cause = ObligationCause::new(
2415 obligation.cause.span,
2416 obligation.cause.body_def_id,
2417 ObligationCauseCode::MatchImpl(obligation.cause.clone(), impl_def_id),
2418 );
2419
2420 let InferOk { obligations, .. } = self
2421 .infcx
2422 .at(&cause, obligation.param_env)
2423 .eq(DefineOpaqueTypes::No, placeholder_obligation_trait_ref, impl_trait_ref)
2424 .map_err(|e| {
2425 debug!("match_impl: failed eq_trait_refs due to `{}`", e.to_string(self.tcx()))
2426 })?;
2427 nested_obligations.extend(obligations);
2428
2429 match self.typing_mode() {
2430 TypingMode::Reflection
2431 if !self.tcx().impl_is_fully_generic_for_reflection(impl_def_id) =>
2432 {
2433 debug!("reflection mode only allows fully generic impls");
2434 return Err(());
2435 }
2436
2437 TypingMode::Typeck { .. }
2438 | TypingMode::PostTypeckThroughBorrowck { .. }
2439 | TypingMode::PostBorrowck { .. }
2440 | TypingMode::Codegen
2441 | TypingMode::ErasedNotCoherence(_)
2442 | TypingMode::Reflection
2443 | TypingMode::PostAnalysis => {}
2444 TypingMode::Coherence => {
2445 unreachable!("old solver coherence")
2446 }
2447 }
2448
2449 Ok(Normalized { value: impl_args, obligations: nested_obligations })
2450 }
2451
2452 fn match_upcast_principal(
2453 &mut self,
2454 obligation: &PolyTraitObligation<'tcx>,
2455 unnormalized_upcast_principal: ty::Unnormalized<'tcx, ty::PolyTraitRef<'tcx>>,
2456 a_data: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
2457 b_data: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
2458 a_region: ty::Region<'tcx>,
2459 b_region: ty::Region<'tcx>,
2460 ) -> SelectionResult<'tcx, PredicateObligations<'tcx>> {
2461 let tcx = self.tcx();
2462 let mut nested = PredicateObligations::new();
2463
2464 let a_auto_traits: FxIndexSet<DefId> = a_data
2468 .auto_traits()
2469 .chain(
2470 a_data
2471 .principal_def_id()
2472 .map(|principal_def_id| {
2473 elaborate::supertrait_def_ids(tcx, principal_def_id)
2474 .filter(|def_id| tcx.trait_is_auto(*def_id))
2475 })
2476 .into_flat_iter(),
2477 )
2478 .collect();
2479
2480 let upcast_principal = normalize_with_depth_to(
2481 self,
2482 obligation.param_env,
2483 obligation.cause.clone(),
2484 obligation.recursion_depth + 1,
2485 unnormalized_upcast_principal,
2486 &mut nested,
2487 );
2488
2489 for bound in b_data {
2490 match bound.skip_binder() {
2491 ty::ExistentialPredicate::Trait(target_principal) => {
2494 let hr_source_principal = upcast_principal.map_bound(|trait_ref| {
2495 ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
2496 });
2497 let hr_target_principal = bound.rebind(target_principal);
2498
2499 nested.extend(
2500 self.infcx
2501 .enter_forall(hr_target_principal, |target_principal| {
2502 let source_principal =
2503 self.infcx.instantiate_binder_with_fresh_vars(
2504 obligation.cause.span,
2505 HigherRankedType,
2506 hr_source_principal,
2507 );
2508 self.infcx.at(&obligation.cause, obligation.param_env).eq_trace(
2509 DefineOpaqueTypes::Yes,
2510 ToTrace::to_trace(
2511 &obligation.cause,
2512 hr_target_principal,
2513 hr_source_principal,
2514 ),
2515 target_principal,
2516 source_principal,
2517 )
2518 })
2519 .map_err(|_| SelectionError::Unimplemented)?
2520 .into_obligations(),
2521 );
2522 }
2523 ty::ExistentialPredicate::Projection(target_projection) => {
2529 let hr_target_projection = bound.rebind(target_projection);
2530
2531 let mut matching_projections =
2532 a_data.projection_bounds().filter(|&hr_source_projection| {
2533 hr_source_projection.item_def_id() == hr_target_projection.item_def_id()
2536 && self.infcx.probe(|_| {
2537 self.infcx
2538 .enter_forall(hr_target_projection, |target_projection| {
2539 let source_projection =
2540 self.infcx.instantiate_binder_with_fresh_vars(
2541 obligation.cause.span,
2542 HigherRankedType,
2543 hr_source_projection,
2544 );
2545 self.infcx
2546 .at(&obligation.cause, obligation.param_env)
2547 .eq_trace(
2548 DefineOpaqueTypes::Yes,
2549 ToTrace::to_trace(
2550 &obligation.cause,
2551 hr_target_projection,
2552 hr_source_projection,
2553 ),
2554 target_projection,
2555 source_projection,
2556 )
2557 })
2558 .is_ok()
2559 })
2560 });
2561
2562 let Some(hr_source_projection) = matching_projections.next() else {
2563 return Err(SelectionError::Unimplemented);
2564 };
2565 if matching_projections.next().is_some() {
2566 return Ok(None);
2567 }
2568 nested.extend(
2569 self.infcx
2570 .enter_forall(hr_target_projection, |target_projection| {
2571 let source_projection =
2572 self.infcx.instantiate_binder_with_fresh_vars(
2573 obligation.cause.span,
2574 HigherRankedType,
2575 hr_source_projection,
2576 );
2577 self.infcx.at(&obligation.cause, obligation.param_env).eq_trace(
2578 DefineOpaqueTypes::Yes,
2579 ToTrace::to_trace(
2580 &obligation.cause,
2581 hr_target_projection,
2582 hr_source_projection,
2583 ),
2584 target_projection,
2585 source_projection,
2586 )
2587 })
2588 .map_err(|_| SelectionError::Unimplemented)?
2589 .into_obligations(),
2590 );
2591 }
2592 ty::ExistentialPredicate::AutoTrait(def_id) => {
2594 if !a_auto_traits.contains(&def_id) {
2595 return Err(SelectionError::Unimplemented);
2596 }
2597 }
2598 }
2599 }
2600
2601 nested.push(Obligation::with_depth(
2602 tcx,
2603 obligation.cause.clone(),
2604 obligation.recursion_depth + 1,
2605 obligation.param_env,
2606 ty::Binder::dummy(ty::OutlivesClause(a_region, b_region)),
2607 ));
2608
2609 Ok(Some(nested))
2610 }
2611
2612 fn match_where_clause_trait_ref(
2616 &mut self,
2617 obligation: &PolyTraitObligation<'tcx>,
2618 where_clause_trait_ref: ty::PolyTraitRef<'tcx>,
2619 ) -> Result<PredicateObligations<'tcx>, ()> {
2620 self.match_poly_trait_ref(obligation, where_clause_trait_ref)
2621 }
2622
2623 {}
#[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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2625u32),
::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")]
2626 fn match_poly_trait_ref(
2627 &mut self,
2628 obligation: &PolyTraitObligation<'tcx>,
2629 poly_trait_ref: ty::PolyTraitRef<'tcx>,
2630 ) -> Result<PredicateObligations<'tcx>, ()> {
2631 let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
2632 let trait_ref = self.infcx.instantiate_binder_with_fresh_vars(
2633 obligation.cause.span,
2634 HigherRankedType,
2635 poly_trait_ref,
2636 );
2637 self.infcx
2638 .at(&obligation.cause, obligation.param_env)
2639 .eq(DefineOpaqueTypes::No, predicate.trait_ref, trait_ref)
2640 .map(|InferOk { obligations, .. }| obligations)
2641 .map_err(|_| ())
2642 }
2643
2644 fn match_fresh_trait_preds(
2648 &self,
2649 previous: ty::PolyTraitClause<'tcx>,
2650 current: ty::PolyTraitClause<'tcx>,
2651 ) -> bool {
2652 let mut matcher = _match::MatchAgainstFreshVars::new(self.tcx());
2653 matcher.relate(previous, current).is_ok()
2654 }
2655
2656 fn push_stack<'o>(
2657 &mut self,
2658 previous_stack: TraitObligationStackList<'o, 'tcx>,
2659 obligation: &'o PolyTraitObligation<'tcx>,
2660 ) -> TraitObligationStack<'o, 'tcx> {
2661 let fresh_trait_pred = obligation.predicate.fold_with(&mut self.freshener);
2662
2663 let dfn = previous_stack.cache.next_dfn();
2664 let depth = previous_stack.depth() + 1;
2665 TraitObligationStack {
2666 obligation,
2667 fresh_trait_pred,
2668 reached_depth: Cell::new(depth),
2669 previous: previous_stack,
2670 dfn,
2671 depth,
2672 }
2673 }
2674
2675 {}
#[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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2675u32),
::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")]
2676 fn closure_trait_ref_unnormalized(
2677 &mut self,
2678 self_ty: Ty<'tcx>,
2679 fn_trait_def_id: DefId,
2680 ) -> ty::PolyTraitRef<'tcx> {
2681 let ty::Closure(_, args) = *self_ty.kind() else {
2682 bug!("expected closure, found {self_ty}");
2683 };
2684 let closure_sig = args.as_closure().sig();
2685
2686 closure_trait_ref_and_return_type(
2687 self.tcx(),
2688 fn_trait_def_id,
2689 self_ty,
2690 closure_sig,
2691 util::TupleArgumentsFlag::No,
2692 )
2693 .map_bound(|(trait_ref, _)| trait_ref)
2694 }
2695
2696 {}
#[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/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2700u32),
::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))]
2701 fn impl_or_trait_obligations(
2702 &mut self,
2703 cause: &ObligationCause<'tcx>,
2704 recursion_depth: usize,
2705 param_env: ty::ParamEnv<'tcx>,
2706 def_id: DefId, args: GenericArgsRef<'tcx>, parent_trait_pred: ty::Binder<'tcx, ty::TraitClause<'tcx>>,
2709 ) -> PredicateObligations<'tcx> {
2710 let tcx = self.tcx();
2711
2712 let clauses = tcx.clauses_of(def_id);
2727 assert_eq!(clauses.parent, None);
2728 let clauses = clauses.instantiate_own(tcx, args);
2729 let mut obligations = PredicateObligations::with_capacity(clauses.len());
2730 for (index, (clause, span)) in clauses.into_iter().enumerate() {
2731 let cause = if tcx.is_lang_item(parent_trait_pred.def_id(), LangItem::CoerceUnsized) {
2732 cause.clone()
2733 } else {
2734 cause.clone().derived_cause(parent_trait_pred, |derived| {
2735 ObligationCauseCode::ImplDerived(Box::new(ImplDerivedCause {
2736 derived,
2737 impl_or_alias_def_id: def_id,
2738 impl_def_clause_index: Some(index),
2739 span,
2740 }))
2741 })
2742 };
2743 let clause = normalize_with_depth_to(
2744 self,
2745 param_env,
2746 cause.clone(),
2747 recursion_depth,
2748 clause,
2749 &mut obligations,
2750 );
2751 obligations.push(Obligation {
2752 cause,
2753 recursion_depth,
2754 param_env,
2755 predicate: clause.as_predicate(),
2756 });
2757 }
2758
2759 if tcx.def_kind(def_id) == (DefKind::Impl { of_trait: true }) {
2761 for clause in tcx.impl_super_outlives(def_id).iter_instantiated(tcx, args) {
2762 let clause = normalize_with_depth_to(
2763 self,
2764 param_env,
2765 cause.clone(),
2766 recursion_depth,
2767 clause,
2768 &mut obligations,
2769 );
2770 obligations.push(Obligation {
2771 cause: cause.clone(),
2772 recursion_depth,
2773 param_env,
2774 predicate: clause.as_predicate(),
2775 });
2776 }
2777 }
2778
2779 obligations
2780 }
2781
2782 pub(super) fn should_stall_coroutine(&self, def_id: DefId) -> bool {
2783 match self.typing_mode() {
2784 TypingMode::Typeck { defining_opaque_types_and_generators: stalled_generators } => {
2785 def_id.as_local().is_some_and(|def_id| stalled_generators.contains(&def_id))
2786 }
2787 TypingMode::PostAnalysis
2788 | TypingMode::Reflection
2789 | TypingMode::Codegen
2790 | TypingMode::PostTypeckThroughBorrowck { defining_opaque_types: _ }
2791 | TypingMode::PostBorrowck { defined_opaque_types: _ } => false,
2792 TypingMode::Coherence => {
2793 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("old solver coherence")));
}unreachable!("old solver coherence")
2794 }
2795 }
2796 }
2797}
2798
2799impl<'o, 'tcx> TraitObligationStack<'o, 'tcx> {
2800 fn list(&'o self) -> TraitObligationStackList<'o, 'tcx> {
2801 TraitObligationStackList::with(self)
2802 }
2803
2804 fn cache(&self) -> &'o ProvisionalEvaluationCache<'tcx> {
2805 self.previous.cache
2806 }
2807
2808 fn iter(&'o self) -> TraitObligationStackList<'o, 'tcx> {
2809 self.list()
2810 }
2811
2812 fn update_reached_depth(&self, reached_depth: usize) {
2815 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!(
2816 self.depth >= reached_depth,
2817 "invoked `update_reached_depth` with something under this stack: \
2818 self.depth={} reached_depth={}",
2819 self.depth,
2820 reached_depth,
2821 );
2822 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:2822",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2822u32),
::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");
2823 let mut p = self;
2824 while reached_depth < p.depth {
2825 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:2825",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2825u32),
::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");
2826 p.reached_depth.set(p.reached_depth.get().min(reached_depth));
2827 p = p.previous.head.unwrap();
2828 }
2829 }
2830}
2831
2832struct ProvisionalEvaluationCache<'tcx> {
2886 dfn: Cell<usize>,
2888
2889 map: RefCell<FxIndexMap<ty::PolyTraitClause<'tcx>, ProvisionalEvaluation>>,
2905
2906 wf_args: RefCell<Vec<(ty::Term<'tcx>, usize)>>,
2914}
2915
2916#[derive(#[automatically_derived]
impl ::core::marker::Copy for ProvisionalEvaluation { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ProvisionalEvaluation { }
#[automatically_derived]
impl ::core::clone::Clone for ProvisionalEvaluation {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<usize>;
let _: ::core::clone::AssertParamIsClone<EvaluationResult>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ProvisionalEvaluation {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"ProvisionalEvaluation", "from_dfn", &self.from_dfn,
"reached_depth", &self.reached_depth, "result", &&self.result)
}
}Debug)]
2919struct ProvisionalEvaluation {
2920 from_dfn: usize,
2921 reached_depth: usize,
2922 result: EvaluationResult,
2923}
2924
2925impl<'tcx> Default for ProvisionalEvaluationCache<'tcx> {
2926 fn default() -> Self {
2927 Self { dfn: Cell::new(0), map: Default::default(), wf_args: Default::default() }
2928 }
2929}
2930
2931impl<'tcx> ProvisionalEvaluationCache<'tcx> {
2932 fn next_dfn(&self) -> usize {
2934 let result = self.dfn.get();
2935 self.dfn.set(result + 1);
2936 result
2937 }
2938
2939 fn get_provisional(
2944 &self,
2945 fresh_trait_pred: ty::PolyTraitClause<'tcx>,
2946 ) -> Option<ProvisionalEvaluation> {
2947 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:2947",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2947u32),
::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!(
2948 ?fresh_trait_pred,
2949 "get_provisional = {:#?}",
2950 self.map.borrow().get(&fresh_trait_pred),
2951 );
2952 Some(*self.map.borrow().get(&fresh_trait_pred)?)
2953 }
2954
2955 fn insert_provisional(
2960 &self,
2961 from_dfn: usize,
2962 reached_depth: usize,
2963 fresh_trait_pred: ty::PolyTraitClause<'tcx>,
2964 result: EvaluationResult,
2965 ) {
2966 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:2966",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(2966u32),
::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");
2967
2968 let mut map = self.map.borrow_mut();
2969
2970 for (_k, v) in &mut *map {
2985 if v.from_dfn >= from_dfn {
2986 v.reached_depth = reached_depth.min(v.reached_depth);
2987 }
2988 }
2989
2990 map.insert(fresh_trait_pred, ProvisionalEvaluation { from_dfn, reached_depth, result });
2991 }
2992
2993 fn on_failure(&self, dfn: usize) {
3002 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:3002",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3002u32),
::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");
3003 self.map.borrow_mut().retain(|key, eval| {
3004 if eval.from_dfn < dfn {
3005 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:3005",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3005u32),
::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);
3006 false
3007 } else {
3008 true
3009 }
3010 });
3011 }
3012
3013 fn on_completion(&self, dfn: usize) {
3051 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:3051",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3051u32),
::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");
3052 self.map.borrow_mut().retain(|fresh_trait_pred, eval| {
3053 if eval.from_dfn >= dfn {
3054 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs:3054",
"rustc_trait_selection::traits::select",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_trait_selection/src/traits/select/mod.rs"),
::tracing_core::__macro_support::Option::Some(3054u32),
::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");
3055 return false;
3056 }
3057 true
3058 });
3059 }
3060}
3061
3062#[derive(#[automatically_derived]
impl<'o, 'tcx> ::core::marker::Copy for TraitObligationStackList<'o, 'tcx> { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl<'o, 'tcx> ::core::clone::TrivialClone for
TraitObligationStackList<'o, 'tcx> {
}
#[automatically_derived]
impl<'o, 'tcx> ::core::clone::Clone for TraitObligationStackList<'o, 'tcx> {
#[inline]
fn clone(&self) -> Self {
let _:
::core::clone::AssertParamIsClone<&'o ProvisionalEvaluationCache<'tcx>>;
let _:
::core::clone::AssertParamIsClone<Option<&'o TraitObligationStack<'o,
'tcx>>>;
*self
}
}Clone)]
3063struct TraitObligationStackList<'o, 'tcx> {
3064 cache: &'o ProvisionalEvaluationCache<'tcx>,
3065 head: Option<&'o TraitObligationStack<'o, 'tcx>>,
3066}
3067
3068impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> {
3069 fn empty(cache: &'o ProvisionalEvaluationCache<'tcx>) -> TraitObligationStackList<'o, 'tcx> {
3070 TraitObligationStackList { cache, head: None }
3071 }
3072
3073 fn with(r: &'o TraitObligationStack<'o, 'tcx>) -> TraitObligationStackList<'o, 'tcx> {
3074 TraitObligationStackList { cache: r.cache(), head: Some(r) }
3075 }
3076
3077 fn head(&self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
3078 self.head
3079 }
3080
3081 fn depth(&self) -> usize {
3082 if let Some(head) = self.head { head.depth } else { 0 }
3083 }
3084}
3085
3086impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> {
3087 type Item = &'o TraitObligationStack<'o, 'tcx>;
3088
3089 fn next(&mut self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
3090 let o = self.head?;
3091 *self = o.previous;
3092 Some(o)
3093 }
3094}
3095
3096impl<'o, 'tcx> fmt::Debug for TraitObligationStack<'o, 'tcx> {
3097 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3098 f.write_fmt(format_args!("TraitObligationStack({0:?})", self.obligation))write!(f, "TraitObligationStack({:?})", self.obligation)
3099 }
3100}
3101
3102pub(crate) enum ProjectionMatchesProjection {
3103 Yes,
3104 Ambiguous,
3105 No,
3106}
3107
3108#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for AutoImplConstituents<'tcx> {
#[inline]
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]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"AutoImplConstituents", "types", &self.types, "assumptions",
&&self.assumptions)
}
}Debug, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
for AutoImplConstituents<'tcx> {
fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Result<Self, __F::Error> {
Ok(match self {
AutoImplConstituents {
types: __binding_0, assumptions: __binding_1 } => {
AutoImplConstituents {
types: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
__folder)?,
assumptions: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
__folder)?,
}
}
})
}
fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
__folder: &mut __F) -> Self {
match self {
AutoImplConstituents {
types: __binding_0, assumptions: __binding_1 } => {
AutoImplConstituents {
types: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
__folder),
assumptions: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
__folder),
}
}
}
}
}
};TypeFoldable, const _: () =
{
impl<'tcx>
::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
for AutoImplConstituents<'tcx> {
fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
__visitor: &mut __V) -> __V::Result {
match *self {
AutoImplConstituents {
types: ref __binding_0, assumptions: ref __binding_1 } => {
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
{
match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
__visitor)) {
::core::ops::ControlFlow::Continue(()) => {}
::core::ops::ControlFlow::Break(r) => {
return ::rustc_middle::ty::VisitorResult::from_residual(r);
}
}
}
}
}
<__V::Result as ::rustc_middle::ty::VisitorResult>::output()
}
}
};TypeVisitable)]
3109pub(crate) struct AutoImplConstituents<'tcx> {
3110 pub types: Vec<Ty<'tcx>>,
3111 pub assumptions: Vec<ty::ArgOutlivesClause<'tcx>>,
3112}