Consolidate type system const evaluation under traits::evaluate_const
mew
This commit is contained in:
@@ -1001,12 +1001,12 @@ where
|
||||
// Try to evaluate a const, or return `None` if the const is too generic.
|
||||
// This doesn't mean the const isn't evaluatable, though, and should be treated
|
||||
// as an ambiguity rather than no-solution.
|
||||
pub(super) fn try_const_eval_resolve(
|
||||
pub(super) fn evaluate_const(
|
||||
&self,
|
||||
param_env: I::ParamEnv,
|
||||
unevaluated: ty::UnevaluatedConst<I>,
|
||||
uv: ty::UnevaluatedConst<I>,
|
||||
) -> Option<I::Const> {
|
||||
self.delegate.try_const_eval_resolve(param_env, unevaluated)
|
||||
self.delegate.evaluate_const(param_env, uv)
|
||||
}
|
||||
|
||||
pub(super) fn is_transmutable(
|
||||
|
||||
@@ -143,7 +143,7 @@ where
|
||||
) -> QueryResult<I> {
|
||||
match ct.kind() {
|
||||
ty::ConstKind::Unevaluated(uv) => {
|
||||
// We never return `NoSolution` here as `try_const_eval_resolve` emits an
|
||||
// We never return `NoSolution` here as `evaluate_const` emits an
|
||||
// error itself when failing to evaluate, so emitting an additional fulfillment
|
||||
// error in that case is unnecessary noise. This may change in the future once
|
||||
// evaluation failures are allowed to impact selection, e.g. generic const
|
||||
@@ -151,7 +151,7 @@ where
|
||||
|
||||
// FIXME(generic_const_exprs): Implement handling for generic
|
||||
// const expressions here.
|
||||
if let Some(_normalized) = self.try_const_eval_resolve(param_env, uv) {
|
||||
if let Some(_normalized) = self.evaluate_const(param_env, uv) {
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
} else {
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
|
||||
|
||||
@@ -14,7 +14,7 @@ where
|
||||
&mut self,
|
||||
goal: Goal<I, ty::NormalizesTo<I>>,
|
||||
) -> QueryResult<I> {
|
||||
if let Some(normalized_const) = self.try_const_eval_resolve(
|
||||
if let Some(normalized_const) = self.evaluate_const(
|
||||
goal.param_env,
|
||||
ty::UnevaluatedConst::new(goal.predicate.alias.def_id, goal.predicate.alias.args),
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user