Skip to content

Conversation

@GrigorenkoPV
Copy link
Contributor

@GrigorenkoPV GrigorenkoPV commented Nov 21, 2025

Tracking issue: #149226

This adds support for writing const { ... } as an item in a module. In the current implementation, this is a unique AST item that gets lowered to const _: () = const { ... }; in HIR.

rustfmt support included.

TODO:

@rustbot rustbot added O-SGX Target: SGX S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 21, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@GrigorenkoPV GrigorenkoPV changed the title Const block item const blocks as a mod's item Nov 22, 2025
@rust-log-analyzer

This comment has been minimized.

@GrigorenkoPV GrigorenkoPV changed the title const blocks as a mod's item const blocks as a mod item Nov 23, 2025
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. and removed O-SGX Target: SGX labels Nov 26, 2025
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added T-lang Relevant to the language team and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 29, 2025
@GrigorenkoPV GrigorenkoPV marked this pull request as ready for review November 29, 2025 21:40
@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 Nov 29, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 29, 2025

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

@rustbot
Copy link
Collaborator

rustbot commented Nov 29, 2025

r? @jdonszelmann

rustbot has assigned @jdonszelmann.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@jdonszelmann
Copy link
Contributor

@GrigorenkoPV feel like updating the last comments and finishing this up?

@rustbot
Copy link
Collaborator

rustbot commented Jan 21, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Comment on lines +3 to +4
// ATTENTION: if we ever start accepting inner attributes here, make sure `rustfmt` can handle them.
// see: https://github.com/rust-lang/rustfmt/issues/6158
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 🙏🏼

Copy link
Contributor

@ytmimi ytmimi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good for the rustfmt changes

View changes since this review

@GrigorenkoPV
Copy link
Contributor Author

@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 Jan 24, 2026
@jdonszelmann
Copy link
Contributor

@bors r=me,ytmimi

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 24, 2026

📌 Commit d144915 has been approved by me,ytmimi

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Jan 24, 2026
@GrigorenkoPV
Copy link
Contributor Author

📌 Commit d144915 has been approved by me,ytmimi

It is now in the queue for this repository.

I don't think bors has managed to properly parse "me" as an alias in this context.

rust-bors bot pushed a commit that referenced this pull request Jan 24, 2026
Rollup of 4 pull requests

Successful merges:

 - #149174 (`const` blocks as a `mod` item)
 - #151282 (THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`)
 - #151593 (miri subtree update)
 - #151516 (Do not emit errors on non-metaitem diagnostic attr input)

r? @ghost
@rust-bors rust-bors bot merged commit 0bb1545 into rust-lang:main Jan 24, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 24, 2026
rust-timer added a commit that referenced this pull request Jan 24, 2026
Rollup merge of #149174 - GrigorenkoPV:const_block_item, r=me,ytmimi

`const` blocks as a `mod` item

Tracking issue: #149226

This adds support for writing `const { ... }` as an item in a module. In the current implementation, this is a unique AST item that gets lowered to `const _: () = const { ... };` in HIR.

rustfmt support included.

TODO:
- `pub const { ... }` does not make sense (see #147136). Reject it. Should this be rejected by the parser or smth?
- Improve diagnostics (preferably they should not mention the fake `_` ident).
@GrigorenkoPV GrigorenkoPV deleted the const_block_item branch January 24, 2026 18:08
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 25, 2026
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#149174 (`const` blocks as a `mod` item)
 - rust-lang/rust#151282 (THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`)
 - rust-lang/rust#151593 (miri subtree update)
 - rust-lang/rust#151516 (Do not emit errors on non-metaitem diagnostic attr input)

r? @ghost
vinDelphini pushed a commit to vinDelphini/rust that referenced this pull request Jan 25, 2026
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#149174 (`const` blocks as a `mod` item)
 - rust-lang#151282 (THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`)
 - rust-lang#151593 (miri subtree update)
 - rust-lang#151516 (Do not emit errors on non-metaitem diagnostic attr input)

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

Labels

I-lang-radar Items that are on lang's radar and will need eventual work or consideration. 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-lang Relevant to the language team T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants