Tracking issue for removing unnecessary `ty::Const::{normalize,eval}` calls from the type system
@compiler-errors is already working on this.
Since Sep 22, 2024.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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 idk
Boxy rationale:
with
min_generic_const_argsandassociated_const_equalityfeatuers normalization of type system constants will be behaving much more like types. They'll return nested goals, access in scope whjere clauses such asT: Trait<ASSOC = 10>in order to normalize instead of simply "evaluating".This means that the only correct way to normalize a
ty::Constwill be to use the "normal" normalization routines such asnormalize_erasing_regionsorinfcx/ocx/fcx.normalize. With that in mind all of theeval_xandnormalizemethods onty::Constbecome massive footguns as they are never correct to use.
- Remove eval calls from codegen (#130644)
- Replace calls to
eval_bitswithtry_to_bits, which I forgot in codegen lol
- Replace calls to
- Normalize writeback results (#130645)
- Replace calls to
evalfrommir_buildandpattern_analysisin now that writeback results are normalized (#130715)
- Replace calls to
- Add
structurally_resolve_constfor use inFnCtxt/hir_typeck(#130714)- Replace calls to
eval_*withstructurally_resolve+try_to_*in hir typeck
- Replace calls to
- Audit remaining calls to
eva;/normalizepost-borrowck, replacing them with theirtry_to_*variants + possibly normalizing depending on the source of the const.
More:
- #130712
cc @BoxyUwU
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.