Skip to content

Conversation

@BoxyUwU
Copy link
Member

@BoxyUwU BoxyUwU commented Feb 6, 2026

r? oli-obk

mGCA now handles const blocks by always handling them during lower_expr_to_const_arg_direct instead of sometimes stripping them out at parse time. This is just generally a lot clearer/nicer but also means parsing isn't lossy which is just straight up wrong.

We now use MgcaDisambiguation::Direct for const blocks because we "directly" represent a const block as hir::ConstArgKind::Anon :> The only time that an anon const for const generics uses MgcaDisambiguation::AnonConst is for unbraced literals.

Once we properly support literals in hir::ConstArgKind (see #152139 #152001) then MgcaDisambiguation can be renamed to AnonConstKind with TypeSystem and NonTypeSystem variants. We can also get rid of mgca_direct_lit_hack. I expect this to be a very nice cleanup :)

Fixes rust-lang/rustfmt#6788

The diff relating to passing spans around is to avoid a bunch of mGCA diagnostics changing from const {} to {}. I'm not entirely sure why this was happening.

cc @rust-lang/rustfmt

How do I run the tests in the rustfmt repo from here? x test rustfmt only seems to run like 100 tests and doesn't result in a target/issue-6788.rs getting created. I've verified locally that this formats correctly though

@rustbot
Copy link
Collaborator

rustbot commented Feb 6, 2026

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

@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-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. labels Feb 6, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 6, 2026

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@BoxyUwU
Copy link
Member Author

BoxyUwU commented Feb 6, 2026

I don't think this should be beta backported to fix rustfmt so I'm going to file a separate PR for that

@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 6, 2026

r=me with CI green

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

Labels

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-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.

Regression in 1.94.0 beta: Rustfmt produces broken code for const blocks in array lengths

4 participants