-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Consolidate type system const evaluation under traits::evaluate_const
#132927
Consolidate type system const evaluation under traits::evaluate_const
#132927
Conversation
Some changes occurred in match checking cc @Nadrieril Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
// 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>()]`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial thoughts
clippy moment :ferrisClueless: |
This comment has been minimized.
This comment has been minimized.
5558a84
to
b77593e
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
b77593e
to
47948d5
Compare
r=me when green |
This comment has been minimized.
This comment has been minimized.
47948d5
to
bea0148
Compare
@bors r=compiler-errors |
…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
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`
Part of #130704
Fixes #128232
Fixes #118545
Removes
ty::Const::{normalize_internal, eval_valtree}
andInferCtxt::(try_)const_eval_resolve
, consolidating the associated logic intoevaluate_const
inrustc_trait_selection
. This results in an API forty::Const
that is free of any normalization/evaluation functions that would be incorrect to use undermin_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 ofrustc_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