1mod alias_relate;
15mod assembly;
16mod effect_goals;
17mod eval_ctxt;
18pub mod inspect;
19mod normalizes_to;
20mod project_goals;
21mod search_graph;
22mod trait_goals;
23
24use derive_where::derive_where;
25use rustc_type_ir::inherent::*;
26pub use rustc_type_ir::solve::*;
27use rustc_type_ir::{self as ty, Interner, TyVid};
28use tracing::instrument;
29
30pub use self::eval_ctxt::{
31 EvalCtxt, GenerateProofTree, SolverDelegateEvalExt,
32 evaluate_root_goal_for_proof_tree_raw_provider,
33};
34use crate::delegate::SolverDelegate;
35use crate::solve::assembly::Candidate;
36
37const FIXPOINT_STEP_LIMIT: usize = 8;
47
48#[derive(#[automatically_derived]
impl ::core::cmp::PartialEq for HasChanged {
#[inline]
fn eq(&self, other: &HasChanged) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for HasChanged {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for HasChanged {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self { HasChanged::Yes => "Yes", HasChanged::No => "No", })
}
}Debug, #[automatically_derived]
impl ::core::hash::Hash for HasChanged {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::clone::Clone for HasChanged {
#[inline]
fn clone(&self) -> HasChanged { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for HasChanged { }Copy)]
51pub enum HasChanged {
52 Yes,
53 No,
54}
55
56fn has_no_inference_or_external_constraints<I: Interner>(
59 response: ty::Canonical<I, Response<I>>,
60) -> bool {
61 let ExternalConstraintsData {
62 ref region_constraints,
63 ref opaque_types,
64 ref normalization_nested_goals,
65 } = *response.value.external_constraints;
66 response.value.var_values.is_identity()
67 && region_constraints.is_empty()
68 && opaque_types.is_empty()
69 && normalization_nested_goals.is_empty()
70}
71
72fn has_only_region_constraints<I: Interner>(response: ty::Canonical<I, Response<I>>) -> bool {
73 let ExternalConstraintsData {
74 region_constraints: _,
75 ref opaque_types,
76 ref normalization_nested_goals,
77 } = *response.value.external_constraints;
78 response.value.var_values.is_identity_modulo_regions()
79 && opaque_types.is_empty()
80 && normalization_nested_goals.is_empty()
81}
82
83impl<'a, D, I> EvalCtxt<'a, D>
84where
85 D: SolverDelegate<Interner = I>,
86 I: Interner,
87{
88 #[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("compute_type_outlives_goal",
"rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/mod.rs"),
::tracing_core::__macro_support::Option::Some(88u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
::tracing_core::field::FieldSet::new(&["goal"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&goal)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: QueryResultOrRerunNonErased<I> =
loop {};
return __tracing_attr_fake_return;
}
{
let ty::OutlivesPredicate(ty, lt) = goal.predicate;
if self.cx().assumptions_on_binders() {
let constraint = self.destructure_type_outlives(ty, lt);
self.register_solver_region_constraint(constraint);
} else { self.register_ty_outlives(ty, lt); }
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
}
}#[instrument(level = "trace", skip(self))]
89 fn compute_type_outlives_goal(
90 &mut self,
91 goal: Goal<I, ty::OutlivesPredicate<I, I::Ty>>,
92 ) -> QueryResultOrRerunNonErased<I> {
93 let ty::OutlivesPredicate(ty, lt) = goal.predicate;
94
95 if self.cx().assumptions_on_binders() {
96 let constraint = self.destructure_type_outlives(ty, lt);
98 self.register_solver_region_constraint(constraint);
99 } else {
100 self.register_ty_outlives(ty, lt);
101 }
102
103 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
104 }
105
106 #[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("compute_region_outlives_goal",
"rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/mod.rs"),
::tracing_core::__macro_support::Option::Some(106u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
::tracing_core::field::FieldSet::new(&["goal"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&goal)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: QueryResultOrRerunNonErased<I> =
loop {};
return __tracing_attr_fake_return;
}
{
let ty::OutlivesPredicate(a, b) = goal.predicate;
if self.cx().assumptions_on_binders() {
let constraint =
rustc_type_ir::region_constraint::RegionConstraint::RegionOutlives(a,
b);
self.register_solver_region_constraint(constraint);
} else {
self.register_region_outlives(a, b, VisibleForLeakCheck::Yes);
}
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
}
}#[instrument(level = "trace", skip(self))]
107 fn compute_region_outlives_goal(
108 &mut self,
109 goal: Goal<I, ty::OutlivesPredicate<I, I::Region>>,
110 ) -> QueryResultOrRerunNonErased<I> {
111 let ty::OutlivesPredicate(a, b) = goal.predicate;
112
113 if self.cx().assumptions_on_binders() {
114 let constraint =
115 rustc_type_ir::region_constraint::RegionConstraint::RegionOutlives(a, b);
116 self.register_solver_region_constraint(constraint);
117 } else {
118 self.register_region_outlives(a, b, VisibleForLeakCheck::Yes);
119 }
120
121 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
122 }
123
124 #[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("compute_coerce_goal",
"rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/mod.rs"),
::tracing_core::__macro_support::Option::Some(124u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
::tracing_core::field::FieldSet::new(&["goal"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&goal)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: QueryResultOrRerunNonErased<I> =
loop {};
return __tracing_attr_fake_return;
}
{
self.compute_subtype_goal(Goal {
param_env: goal.param_env,
predicate: ty::SubtypePredicate {
a_is_expected: false,
a: goal.predicate.a,
b: goal.predicate.b,
},
})
}
}
}#[instrument(level = "trace", skip(self))]
125 fn compute_coerce_goal(
126 &mut self,
127 goal: Goal<I, ty::CoercePredicate<I>>,
128 ) -> QueryResultOrRerunNonErased<I> {
129 self.compute_subtype_goal(Goal {
130 param_env: goal.param_env,
131 predicate: ty::SubtypePredicate {
132 a_is_expected: false,
133 a: goal.predicate.a,
134 b: goal.predicate.b,
135 },
136 })
137 }
138
139 #[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("compute_subtype_goal",
"rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/mod.rs"),
::tracing_core::__macro_support::Option::Some(139u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
::tracing_core::field::FieldSet::new(&["goal"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&goal)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: QueryResultOrRerunNonErased<I> =
loop {};
return __tracing_attr_fake_return;
}
{
match (goal.predicate.a.kind(), goal.predicate.b.kind()) {
(ty::Infer(ty::TyVar(a_vid)), ty::Infer(ty::TyVar(b_vid))) =>
{
self.sub_unify_ty_vids_raw(a_vid, b_vid);
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
}
_ => {
self.sub(goal.param_env, goal.predicate.a,
goal.predicate.b)?;
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
}
}
}
}#[instrument(level = "trace", skip(self))]
140 fn compute_subtype_goal(
141 &mut self,
142 goal: Goal<I, ty::SubtypePredicate<I>>,
143 ) -> QueryResultOrRerunNonErased<I> {
144 match (goal.predicate.a.kind(), goal.predicate.b.kind()) {
145 (ty::Infer(ty::TyVar(a_vid)), ty::Infer(ty::TyVar(b_vid))) => {
146 self.sub_unify_ty_vids_raw(a_vid, b_vid);
147 self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
148 }
149 _ => {
150 self.sub(goal.param_env, goal.predicate.a, goal.predicate.b)?;
151 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
152 }
153 }
154 }
155
156 fn compute_dyn_compatible_goal(
157 &mut self,
158 trait_def_id: I::TraitId,
159 ) -> QueryResultOrRerunNonErased<I> {
160 if self.cx().trait_is_dyn_compatible(trait_def_id) {
161 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
162 } else {
163 Err(NoSolution.into())
164 }
165 }
166
167 #[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("compute_well_formed_goal",
"rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/mod.rs"),
::tracing_core::__macro_support::Option::Some(167u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
::tracing_core::field::FieldSet::new(&["goal"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&goal)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: QueryResultOrRerunNonErased<I> =
loop {};
return __tracing_attr_fake_return;
}
{
match self.well_formed_goals(goal.param_env, goal.predicate) {
Some(goals) => {
self.add_goals(GoalSource::Misc, goals)?;
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
None =>
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS),
}
}
}
}#[instrument(level = "trace", skip(self))]
168 fn compute_well_formed_goal(
169 &mut self,
170 goal: Goal<I, I::Term>,
171 ) -> QueryResultOrRerunNonErased<I> {
172 match self.well_formed_goals(goal.param_env, goal.predicate) {
173 Some(goals) => {
174 self.add_goals(GoalSource::Misc, goals)?;
175 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
176 }
177 None => self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS),
178 }
179 }
180
181 fn compute_unstable_feature_goal(
182 &mut self,
183 param_env: <I as Interner>::ParamEnv,
184 symbol: <I as Interner>::Symbol,
185 ) -> QueryResultOrRerunNonErased<I> {
186 if self.may_use_unstable_feature(param_env, symbol)? {
187 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
188 } else {
189 self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
190 }
191 }
192
193 #[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("compute_const_evaluatable_goal",
"rustc_next_trait_solver::solve", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/mod.rs"),
::tracing_core::__macro_support::Option::Some(193u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve"),
::tracing_core::field::FieldSet::new(&["param_env", "ct"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(¶m_env)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ct)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: QueryResultOrRerunNonErased<I> =
loop {};
return __tracing_attr_fake_return;
}
{
match ct.kind() {
ty::ConstKind::Alias(ty::IsRigid::Yes, _) |
ty::ConstKind::Placeholder(_) | ty::ConstKind::Value(_) |
ty::ConstKind::Error(_) => {
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
ty::ConstKind::Infer(_) => {
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
}
ty::ConstKind::Alias(ty::IsRigid::No, alias_const) => {
if let Some(_normalized) =
self.evaluate_const(param_env, alias_const)? {
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
} else {
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
}
}
ty::ConstKind::Param(_) | ty::ConstKind::Bound(_, _) |
ty::ConstKind::Expr(_) => {
{
::core::panicking::panic_fmt(format_args!("unexpected const kind: {0:?}",
ct));
}
}
}
}
}
}#[instrument(level = "trace", skip(self))]
194 fn compute_const_evaluatable_goal(
195 &mut self,
196 Goal { param_env, predicate: ct }: Goal<I, I::Const>,
197 ) -> QueryResultOrRerunNonErased<I> {
198 match ct.kind() {
199 ty::ConstKind::Alias(ty::IsRigid::Yes, _)
200 | ty::ConstKind::Placeholder(_)
201 | ty::ConstKind::Value(_)
202 | ty::ConstKind::Error(_) => {
203 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
204 }
205
206 ty::ConstKind::Infer(_) => {
207 self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
208 }
209
210 ty::ConstKind::Alias(ty::IsRigid::No, alias_const) => {
211 if let Some(_normalized) = self.evaluate_const(param_env, alias_const)? {
220 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
221 } else {
222 self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
223 }
224 }
225
226 ty::ConstKind::Param(_) | ty::ConstKind::Bound(_, _) | ty::ConstKind::Expr(_) => {
231 panic!("unexpected const kind: {:?}", ct)
232 }
233 }
234 }
235
236 x;#[instrument(level = "trace", skip(self), ret)]
237 fn compute_const_arg_has_type_goal(
238 &mut self,
239 goal: Goal<I, (I::Const, I::Ty)>,
240 ) -> QueryResultOrRerunNonErased<I> {
241 let (ct, ty) = goal.predicate;
242 let ct = self.structurally_normalize_const(goal.param_env, ct)?;
243
244 let ct_ty = match ct.kind() {
245 ty::ConstKind::Infer(_) => {
246 return self
247 .evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
248 .map_err(Into::into);
249 }
250 ty::ConstKind::Error(_) => {
251 return self
252 .evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
253 .map_err(Into::into);
254 }
255 ty::ConstKind::Alias(ty::IsRigid::Yes, alias_const) => {
256 alias_const.type_of(self.cx()).skip_norm_wip()
257 }
258 ty::ConstKind::Alias(ty::IsRigid::No, _) => unimplemented!(
259 "non-rigid unevaluated constant for compute_const_arg_has_type_goal: {ct:?}"
260 ),
261 ty::ConstKind::Expr(_) => unimplemented!(
262 "`feature(generic_const_exprs)` is not supported in the new trait solver"
263 ),
264 ty::ConstKind::Param(_) => {
265 unreachable!("`ConstKind::Param` should have been canonicalized to `Placeholder`")
266 }
267 ty::ConstKind::Bound(_, _) => panic!("escaping bound vars in {:?}", ct),
268 ty::ConstKind::Value(cv) => cv.ty(),
269 ty::ConstKind::Placeholder(placeholder) => {
270 placeholder.find_const_ty_from_env(goal.param_env)
271 }
272 };
273
274 self.eq(goal.param_env, ct_ty, ty)?;
275 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes).map_err(Into::into)
276 }
277}
278
279#[derive(#[automatically_derived]
impl ::core::fmt::Debug for MergeCandidateInfo {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
MergeCandidateInfo::AlwaysApplicable(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"AlwaysApplicable", &__self_0),
MergeCandidateInfo::EqualResponse =>
::core::fmt::Formatter::write_str(f, "EqualResponse"),
}
}
}Debug)]
280enum MergeCandidateInfo {
281 AlwaysApplicable(usize),
282 EqualResponse,
283}
284
285impl<D, I> EvalCtxt<'_, D>
286where
287 D: SolverDelegate<Interner = I>,
288 I: Interner,
289{
290 x;#[instrument(level = "trace", skip(self), ret)]
294 fn try_merge_candidates(
295 &mut self,
296 candidates: &[Candidate<I>],
297 ) -> Option<(CanonicalResponse<I>, MergeCandidateInfo)> {
298 if candidates.is_empty() {
299 return None;
300 }
301
302 let always_applicable = candidates.iter().enumerate().find(|(_, candidate)| {
303 candidate.result.value.certainty == Certainty::Yes
304 && has_no_inference_or_external_constraints(candidate.result)
305 });
306 if let Some((i, c)) = always_applicable {
307 return Some((c.result, MergeCandidateInfo::AlwaysApplicable(i)));
308 }
309
310 let one: CanonicalResponse<I> = candidates[0].result;
311 if candidates[1..].iter().all(|candidate| candidate.result == one) {
312 return Some((one, MergeCandidateInfo::EqualResponse));
313 }
314
315 None
316 }
317
318 fn bail_with_ambiguity(&mut self, candidates: &[Candidate<I>]) -> CanonicalResponse<I> {
319 if true {
if !(candidates.len() > 1) {
::core::panicking::panic("assertion failed: candidates.len() > 1")
};
};debug_assert!(candidates.len() > 1);
320 let maybe = candidates.iter().fold(MaybeInfo::AMBIGUOUS, |maybe, candidate| {
321 match candidate.result.value.certainty {
325 Certainty::Yes => maybe,
326 Certainty::Maybe(cand_maybe) => maybe.or(cand_maybe),
327 }
328 });
329 self.make_ambiguous_response_no_constraints(maybe)
330 }
331
332 x;#[instrument(level = "trace", skip(self), ret)]
334 fn flounder(&mut self, candidates: &[Candidate<I>]) -> QueryResult<I> {
335 if candidates.is_empty() {
336 return Err(NoSolution);
337 } else {
338 Ok(self.bail_with_ambiguity(candidates))
339 }
340 }
341
342 x;#[instrument(level = "trace", skip(self, param_env), ret)]
348 fn structurally_normalize_ty(
349 &mut self,
350 param_env: I::ParamEnv,
351 ty: I::Ty,
352 ) -> Result<I::Ty, NoSolutionOrRerunNonErased> {
353 self.structurally_normalize_term(param_env, ty.into()).map(|term| term.expect_ty())
354 }
355
356 x;#[instrument(level = "trace", skip(self, param_env), ret)]
363 fn structurally_normalize_const(
364 &mut self,
365 param_env: I::ParamEnv,
366 ct: I::Const,
367 ) -> Result<I::Const, NoSolutionOrRerunNonErased> {
368 self.structurally_normalize_term(param_env, ct.into()).map(|term| term.expect_const())
369 }
370
371 fn structurally_normalize_term(
376 &mut self,
377 param_env: I::ParamEnv,
378 term: I::Term,
379 ) -> Result<I::Term, NoSolutionOrRerunNonErased> {
380 if !self.cx().renormalize_rigid_aliases() && !term.is_non_rigid_alias() {
381 return Ok(term);
382 }
383
384 if let Some(alias) = term.to_alias_term() {
385 let normalized_term = self.next_term_infer_of_alias_kind(alias);
386 let projection_goal = Goal::new(
387 self.cx(),
388 param_env,
389 ty::ProjectionPredicate { projection_term: alias, term: normalized_term },
390 );
391 self.add_goal(GoalSource::TypeRelating, projection_goal)?;
394 self.try_evaluate_added_goals()?;
395 Ok(self.resolve_vars_if_possible(normalized_term))
396 } else {
397 Ok(term)
398 }
399 }
400}
401
402#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for GoalEvaluation<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
GoalEvaluation {
goal: ref __field_goal,
certainty: ref __field_certainty,
has_changed: ref __field_has_changed,
stalled_on: ref __field_stalled_on } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "GoalEvaluation");
::core::fmt::DebugStruct::field(&mut __builder, "goal",
__field_goal);
::core::fmt::DebugStruct::field(&mut __builder, "certainty",
__field_certainty);
::core::fmt::DebugStruct::field(&mut __builder, "has_changed",
__field_has_changed);
::core::fmt::DebugStruct::field(&mut __builder, "stalled_on",
__field_stalled_on);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}#[derive_where(Debug; I: Interner)]
404pub struct GoalEvaluation<I: Interner> {
405 pub goal: Goal<I, I::Predicate>,
422 pub certainty: Certainty,
423 pub has_changed: HasChanged,
424 pub stalled_on: Option<GoalStalledOn<I>>,
427}
428
429#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for GoalStalledOn<I> where I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
GoalStalledOn {
num_opaques: ref __field_num_opaques,
stalled_vars: ref __field_stalled_vars,
sub_roots: ref __field_sub_roots,
stalled_certainty: ref __field_stalled_certainty,
previously_succeeded_in_erased: ref __field_previously_succeeded_in_erased
} => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "GoalStalledOn");
::core::fmt::DebugStruct::field(&mut __builder, "num_opaques",
__field_num_opaques);
::core::fmt::DebugStruct::field(&mut __builder,
"stalled_vars", __field_stalled_vars);
::core::fmt::DebugStruct::field(&mut __builder, "sub_roots",
__field_sub_roots);
::core::fmt::DebugStruct::field(&mut __builder,
"stalled_certainty", __field_stalled_certainty);
::core::fmt::DebugStruct::field(&mut __builder,
"previously_succeeded_in_erased",
__field_previously_succeeded_in_erased);
::core::fmt::DebugStruct::finish(&mut __builder)
}
}
}
}#[derive_where(Clone, Debug; I: Interner)]
431pub struct GoalStalledOn<I: Interner> {
432 pub num_opaques: usize,
433 pub stalled_vars: Vec<I::GenericArg>,
434 pub sub_roots: Vec<TyVid>,
435 pub stalled_certainty: Certainty,
438 pub previously_succeeded_in_erased: SucceededInErased<I>,
439}
440
441#[automatically_derived]
impl<I: Interner> ::core::fmt::Debug for SucceededInErased<I> where
I: Interner {
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>)
-> ::core::fmt::Result {
match self {
SucceededInErased::Yes {
accessed_opaques: ref __field_accessed_opaques } => {
let mut __builder =
::core::fmt::Formatter::debug_struct(__f, "Yes");
::core::fmt::DebugStruct::field(&mut __builder,
"accessed_opaques", __field_accessed_opaques);
::core::fmt::DebugStruct::finish(&mut __builder)
}
SucceededInErased::No =>
::core::fmt::Formatter::write_str(__f, "No"),
}
}
}#[derive_where(Clone, Debug; I: Interner)]
442pub enum SucceededInErased<I: Interner> {
443 Yes { accessed_opaques: AccessedOpaques<I> },
444 No,
445}