Skip to content

Enforce syntactical stability of const traits in HIR#135423

Merged
bors merged 1 commit intorust-lang:masterfrom
compiler-errors:enforce-const-trait-syntactical
Jan 15, 2025
Merged

Enforce syntactical stability of const traits in HIR#135423
bors merged 1 commit intorust-lang:masterfrom
compiler-errors:enforce-const-trait-syntactical

Conversation

@compiler-errors
Copy link
Copy Markdown
Contributor

This PR enforces what I'm calling syntactical const stability of traits. In other words, it enforces the ability to name ~const/const traits 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 NonConstOp to 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/const bounds 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

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PG-const-traits Project group: Const traits S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants