Skip to content

New const traits syntax #139858

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

Merged
merged 3 commits into from
Jun 28, 2025
Merged

New const traits syntax #139858

merged 3 commits into from
Jun 28, 2025

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Apr 15, 2025

This PR only affects the AST and doesn't actually change anything semantically.

All occurrences of ~const outside of libcore have been replaced by [const]. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts ~const into [const]. After this we can remove the ~const support from the parser

Caveat discovered during impl: there is no legacy bare trait object recovery for [const] Trait as that snippet in type position goes down the slice /array parsing code and will error

r? @fee1-dead

cc @nikomatsakis @traviscross @compiler-errors

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Apr 15, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 15, 2025

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@oli-obk oli-obk force-pushed the new-const-traits-syntax branch from f6be056 to 2003458 Compare April 15, 2025 09:04
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the new-const-traits-syntax branch from 2003458 to d6da247 Compare April 15, 2025 09:51
@rustbot

This comment was marked as outdated.

@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the new-const-traits-syntax branch from d6da247 to e16c40b Compare April 15, 2025 12:38
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the new-const-traits-syntax branch from 234ba91 to ef1acde Compare April 17, 2025 13:04
@oli-obk oli-obk force-pushed the new-const-traits-syntax branch from ef1acde to 5fa25d4 Compare April 29, 2025 09:04
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the new-const-traits-syntax branch from 5fa25d4 to 7762468 Compare April 29, 2025 09:55
@bors
Copy link
Collaborator

bors commented May 6, 2025

☔ The latest upstream changes (presumably #140695) made this pull request unmergeable. Please resolve the merge conflicts.

@compiler-errors
Copy link
Member

Have we actually settled on a syntax here? Sorry for punting it back over, but would like to get an update here if it's actually ready to review :> ping me when it's ready, sorry for the delays!

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 22, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@traviscross
Copy link
Contributor

Have we actually settled on a syntax here?

No. Discussion is ongoing.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 26, 2025
@oli-obk oli-obk force-pushed the new-const-traits-syntax branch from dc95649 to c548946 Compare June 26, 2025 10:25
@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 26, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 26, 2025
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the new-const-traits-syntax branch from c548946 to a9f1140 Compare June 26, 2025 10:45
@rustbot rustbot added the A-tidy Area: The tidy tool label Jun 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 26, 2025

There are changes to the tidy tool.

cc @jieyouxu

@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jun 26, 2025
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the new-const-traits-syntax branch from a9f1140 to 512ff95 Compare June 26, 2025 13:46
@fee1-dead
Copy link
Member

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Jun 27, 2025

📌 Commit 512ff95 has been approved by fee1-dead

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 27, 2025
@compiler-errors
Copy link
Member

This affects a lot of tests but I don't expect it to fail, except if there's an untested doc test or something.

@bors rollup=iffy

compiler-errors added a commit to compiler-errors/rust that referenced this pull request Jun 27, 2025
…=fee1-dead

New const traits syntax

This PR only affects the AST and doesn't actually change anything semantically.

All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser

Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error

r? `@fee1-dead`

cc `@nikomatsakis` `@traviscross` `@compiler-errors`
bors added a commit that referenced this pull request Jun 27, 2025
…rors

Rollup of 8 pull requests

Successful merges:

 - #139858 (New const traits syntax)
 - #140809 (Reduce special casing for the panic runtime)
 - #142963 (Skip unnecessary components in x64 try builds)
 - #142974 (Update stage0 to 1.89.0-beta.1)
 - #142987 (rustdoc: show attributes on enum variants)
 - #143002 (tests: Require `run-fail` ui tests to have an exit code (`SIGABRT` not ok))
 - #143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology)
 - #143096 (tag_for_variant: properly pass TypingEnv)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jun 27, 2025
Rollup of 9 pull requests

Successful merges:

 - #139858 (New const traits syntax)
 - #140809 (Reduce special casing for the panic runtime)
 - #142730 (suggest declaring modules when file found but module not defined)
 - #142806 (Normalize before computing ConstArgHasType goal in new solver)
 - #143046 (const validation: properly ignore zero-sized UnsafeCell)
 - #143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology)
 - #143096 (tag_for_variant: properly pass TypingEnv)
 - #143104 (hir_analysis: prohibit `dyn PointeeSized`)
 - #143106 (gce: don't ICE on non-local const)

Failed merges:

 - #143036 (Remove support for `dyn*` from the compiler)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 36c2b01 into rust-lang:master Jun 28, 2025
10 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jun 28, 2025
@bors
Copy link
Collaborator

bors commented Jun 28, 2025

⌛ Testing commit 512ff95 with merge d41e12f...

rust-timer added a commit that referenced this pull request Jun 28, 2025
Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-dead

New const traits syntax

This PR only affects the AST and doesn't actually change anything semantically.

All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser

Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error

r? ``@fee1-dead``

cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jun 28, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#139858 (New const traits syntax)
 - rust-lang/rust#140809 (Reduce special casing for the panic runtime)
 - rust-lang/rust#142730 (suggest declaring modules when file found but module not defined)
 - rust-lang/rust#142806 (Normalize before computing ConstArgHasType goal in new solver)
 - rust-lang/rust#143046 (const validation: properly ignore zero-sized UnsafeCell)
 - rust-lang/rust#143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology)
 - rust-lang/rust#143096 (tag_for_variant: properly pass TypingEnv)
 - rust-lang/rust#143104 (hir_analysis: prohibit `dyn PointeeSized`)
 - rust-lang/rust#143106 (gce: don't ICE on non-local const)

Failed merges:

 - rust-lang/rust#143036 (Remove support for `dyn*` from the compiler)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs A-tidy Area: The tidy tool S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants