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