diff options
| author | Boxy <rust@boxyuwu.dev> | 2024-11-12 02:54:03 +0000 |
|---|---|---|
| committer | Boxy <rust@boxyuwu.dev> | 2024-11-12 02:54:03 +0000 |
| commit | bea0148ac62758a99dcc2ac2cc2efedacb8881bf (patch) | |
| tree | 1e3cf15272da0fb53f45fc9521b626509467af14 /compiler/rustc_next_trait_solver | |
| parent | 81eef2d362a6f03db6f8928f82d94298d31eb81b (diff) | |
| download | rust-bea0148ac62758a99dcc2ac2cc2efedacb8881bf.tar.gz rust-bea0148ac62758a99dcc2ac2cc2efedacb8881bf.zip | |
Consolidate type system const evaluation under `traits::evaluate_const`
mew
Diffstat (limited to 'compiler/rustc_next_trait_solver')
4 files changed, 8 insertions, 8 deletions
diff --git a/compiler/rustc_next_trait_solver/src/delegate.rs b/compiler/rustc_next_trait_solver/src/delegate.rs index f7fbfed5b8e..4ba54a2e0bf 100644 --- a/compiler/rustc_next_trait_solver/src/delegate.rs +++ b/compiler/rustc_next_trait_solver/src/delegate.rs @@ -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`! diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs index 8685896715e..979a3794748 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs @@ -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( diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs index 6793779b205..5c54656cc59 100644 --- a/compiler/rustc_next_trait_solver/src/solve/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs @@ -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) diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/anon_const.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/anon_const.rs index 5d5597429da..8ad0bf5cdf9 100644 --- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/anon_const.rs +++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/anon_const.rs @@ -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), ) { |
