Consolidate type system const evaluation under traits::evaluate_const#132927
Merged
bors merged 1 commit intorust-lang:masterfrom Nov 12, 2024
Merged
Consolidate type system const evaluation under traits::evaluate_const#132927bors merged 1 commit intorust-lang:masterfrom
traits::evaluate_const#132927bors merged 1 commit intorust-lang:masterfrom
Conversation
Collaborator
|
Some changes occurred in match checking cc @Nadrieril Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
BoxyUwU
commented
Nov 12, 2024
Comment on lines
-95
to
-96
| // FIXME: We should only try to evaluate a given constant here if it is fully concrete | ||
| // as we don't want to allow things like `[u8; std::mem::size_of::<*mut T>()]`. |
Member
Author
There was a problem hiding this comment.
try_evaluate_const will be responsible for not evaluating if generic parameters are being used (either directly or indirectly through ctfe machinery returning TooGeneric)
This comment has been minimized.
This comment has been minimized.
Contributor
compiler-errors
left a comment
There was a problem hiding this comment.
Some initial thoughts
Contributor
|
clippy moment :ferrisClueless: |
This comment has been minimized.
This comment has been minimized.
5558a84 to
b77593e
Compare
Collaborator
|
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
b77593e to
47948d5
Compare
Contributor
|
r=me when green |
This comment has been minimized.
This comment has been minimized.
47948d5 to
bea0148
Compare
Member
Author
|
@bors r=compiler-errors |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 12, 2024
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#132651 (Remove attributes from generics in built-in derive macros) - rust-lang#132668 (Feature gate yield expressions not in 2024) - rust-lang#132771 (test(configure): cover `parse_args` in `src/bootstrap/configure.py`) - rust-lang#132895 (Generalize `NonNull::from_raw_parts` per ACP362) - rust-lang#132914 (Update grammar in std::cell docs.) - rust-lang#132927 (Consolidate type system const evaluation under `traits::evaluate_const`) - rust-lang#132935 (Make sure to ignore elided lifetimes when pointing at args for fulfillment errors) - rust-lang#132941 (Subtree update of `rust-analyzer`) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 12, 2024
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`
This was referenced Nov 12, 2024
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #130704
Fixes #128232
Fixes #118545
Removes
ty::Const::{normalize_internal, eval_valtree}andInferCtxt::(try_)const_eval_resolve, consolidating the associated logic intoevaluate_constinrustc_trait_selection. This results in an API forty::Constthat is free of any normalization/evaluation functions that would be incorrect to use undermin_generic_const_args/associated_const_equality/generic_const_exprsor, more generally, that would be incorrect to use in the presence of generic type system constants.Moving this logic to
rustc_trait_selectionand out ofrustc_middleis 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