Consolidate type system const evaluation under traits::evaluate_const
mew
This commit is contained in:
parent
81eef2d362
commit
bea0148ac6
31 changed files with 434 additions and 569 deletions
|
@ -29,10 +29,10 @@ pub trait SolverDelegate: Deref<Target = <Self as SolverDelegate>::Infcx> + Size
|
|||
// FIXME: Uplift the leak check into this crate.
|
||||
fn leak_check(&self, max_input_universe: ty::UniverseIndex) -> Result<(), NoSolution>;
|
||||
|
||||
fn try_const_eval_resolve(
|
||||
fn evaluate_const(
|
||||
&self,
|
||||
param_env: <Self::Interner as Interner>::ParamEnv,
|
||||
unevaluated: ty::UnevaluatedConst<Self::Interner>,
|
||||
uv: ty::UnevaluatedConst<Self::Interner>,
|
||||
) -> Option<<Self::Interner as Interner>::Const>;
|
||||
|
||||
// FIXME: This only is here because `wf::obligations` is in `rustc_trait_selection`!
|
||||
|
|
|
@ -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),
|
||||
) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue