-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking issue for removing unnecessary ty::Const::{normalize,eval}
calls from the type system
#130704
Comments
Are they? The role of |
As a meta remark here, I think @rust-lang/wg-const-eval should generally be kept in the loop when t-types is fundamentally changing the API of In particular, we did a bunch of work to make that API somewhat consistent with |
Nothing is fundamentally changing about being able to normalize type system constants, this has zero impact on const evaluation. This is a refactoring to make |
I didn't say any functionality was being removed. Just APIs are being (re)moved, for what I assume are good reasons. But surely wg-const-eval needs to understand why this is done. You can't say that the |
I am absolutely saying that in this case it has nothing to do with this group. Nothing has fundamentally changed with this refactoring, it has no impact on const eval whatsoever. This is primarily a focus about how the API should be structured for normalizing type system constants not any of the actual const eval logic. If we were introducing new constraints on how ctfe must work for const generics or what circumstances ctfe must be able to run in then sure wg-const-eval should be included. But this refactoring does not affect const eval/ctfe in any real way. |
Both of you may be interested in moving extended discussion into a Zulip topic :) |
Continue to get rid of `ty::Const::{try_}eval*` This PR mostly does: * Removes all of the `try_eval_*` and `eval_*` helpers from `ty::Const`, and replace their usages with `try_to_*`. * Remove `ty::Const::eval`. * Rename `ty::Const::normalize` to `ty::Const::normalize_internal`. This function is still used in the normalization code itself. * Fix some weirdness around the `TransmuteFrom` goal. I'm happy to split it out further; for example, I could probably land the first part which removes the helpers, or the changes to codegen which are more obvious than the changes to tools. r? BoxyUwU Part of rust-lang#130704
Continue to get rid of `ty::Const::{try_}eval*` This PR mostly does: * Removes all of the `try_eval_*` and `eval_*` helpers from `ty::Const`, and replace their usages with `try_to_*`. * Remove `ty::Const::eval`. * Rename `ty::Const::normalize` to `ty::Const::normalize_internal`. This function is still used in the normalization code itself. * Fix some weirdness around the `TransmuteFrom` goal. I'm happy to split it out further; for example, I could probably land the first part which removes the helpers, or the changes to codegen which are more obvious than the changes to tools. r? BoxyUwU Part of rust-lang/rust#130704
Continue to get rid of `ty::Const::{try_}eval*` This PR mostly does: * Removes all of the `try_eval_*` and `eval_*` helpers from `ty::Const`, and replace their usages with `try_to_*`. * Remove `ty::Const::eval`. * Rename `ty::Const::normalize` to `ty::Const::normalize_internal`. This function is still used in the normalization code itself. * Fix some weirdness around the `TransmuteFrom` goal. I'm happy to split it out further; for example, I could probably land the first part which removes the helpers, or the changes to codegen which are more obvious than the changes to tools. r? BoxyUwU Part of rust-lang/rust#130704
…nst_eval, r=compiler-errors Consolidate type system const evaluation under `traits::evaluate_const` Part of rust-lang#130704 Fixes rust-lang#128232 Fixes rust-lang#118545 Removes `ty::Const::{normalize_internal, eval_valtree}` and `InferCtxt::(try_)const_eval_resolve`, consolidating the associated logic into `evaluate_const` in `rustc_trait_selection`. This results in an API for `ty::Const` that is free of any normalization/evaluation functions that would be incorrect to use under `min_generic_const_args`/`associated_const_equality`/`generic_const_exprs` or, more generally, that would be incorrect to use in the presence of generic type system constants. Moving this logic to `rustc_trait_selection` and out of `rustc_middle` is also a pre-requisite for ensuring that we do not evaluate constants whose where clauses do not hold. From this point it should be relatively simple (hah) to implement more complex normalization of type system constants such as: checking wf'ness before invoking CTFE machinery, or being able to normalize const aliases that still refer to generic parameters. r? `@compiler-errors`
Rollup merge of rust-lang#132927 - BoxyUwU:consolidate_type_system_const_eval, r=compiler-errors Consolidate type system const evaluation under `traits::evaluate_const` Part of rust-lang#130704 Fixes rust-lang#128232 Fixes rust-lang#118545 Removes `ty::Const::{normalize_internal, eval_valtree}` and `InferCtxt::(try_)const_eval_resolve`, consolidating the associated logic into `evaluate_const` in `rustc_trait_selection`. This results in an API for `ty::Const` that is free of any normalization/evaluation functions that would be incorrect to use under `min_generic_const_args`/`associated_const_equality`/`generic_const_exprs` or, more generally, that would be incorrect to use in the presence of generic type system constants. Moving this logic to `rustc_trait_selection` and out of `rustc_middle` is also a pre-requisite for ensuring that we do not evaluate constants whose where clauses do not hold. From this point it should be relatively simple (hah) to implement more complex normalization of type system constants such as: checking wf'ness before invoking CTFE machinery, or being able to normalize const aliases that still refer to generic parameters. r? `@compiler-errors`
We want to remove calls to
ty::Const::{normalize,eval,eval_to_*}
because they won't work correctly with future reformulations of GCE, and because they're unnecessary with non-GCE consts. This issue tracks doing that so I won't forget. Boxy can probably write more motivation here idkBoxy rationale:
eval_bits
withtry_to_bits
, which I forgot in codegen loleval
frommir_build
andpattern_analysis
in now that writeback results are normalized (Replace calls toty::Const::{try_}eval
in mir build/pattern analysis #130715)structurally_resolve_const
for use inFnCtxt
/hir_typeck
(Introducestructurally_normalize_const
, use it inrustc_hir_typeck
#130714)eval_*
withstructurally_resolve
+try_to_*
in hir typeckeva;/normalize
post-borrowck, replacing them with theirtry_to_*
variants + possibly normalizing depending on the source of the const.More:
ty::Const::normalize
in error reporting #130712cc @BoxyUwU
The text was updated successfully, but these errors were encountered: