Enforce syntactical stability of const traits in HIR#135423
Merged
bors merged 1 commit intorust-lang:masterfrom Jan 15, 2025
Merged
Enforce syntactical stability of const traits in HIR#135423bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
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.
This PR enforces what I'm calling syntactical const stability of traits. In other words, it enforces the ability to name
~const/consttraits in trait bounds in various syntax positions in HIR (including in the trait of an impl header). This functionality is analogous to the regular item stability checker, which is concerned with making sure that you cannot refer to unstable items by name, and is implemented as an extension of that pass.This is separate from enforcing the recursive const stability of const trait methods, which is implemented in MIR and runs on MIR bodies. That will require adding a new
NonConstOpto the const checker and probably adjusting some logic to deduplicate redundant errors.However, this check is separate and necessary for making sure that users don't add
~const/constbounds to items when the trait is not const-stable in the first place. I chose to separate enforcing recursive const stability out of this PR to make it easier to review. I'll probably open a follow-up following this one, blocked on this PR.r? @RalfJung cc @rust-lang/project-const-traits