Skip to content

Don't lose comments and attributes between cfg_select! predicates, outer/inner blocks, arm body and trailing commas - #7211

Merged
jieyouxu merged 7 commits into
rust-lang:mainfrom
jieyouxu:jieyouxu/cfg-select-comments
Oct 24, 2026
Merged

jieyouxu merged 7 commits into
rust-lang:mainfrom
jieyouxu:jieyouxu/cfg-select-comments

Conversation

@jieyouxu

@jieyouxu jieyouxu commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Didn't realize Yacin was already working on a patch for #7209 :D Anyway, we can compare notes since there's several annoying edge cases. Probably yoink changes out from this PR if you want.

Best reviewed commit-by-commit. See individual commits.

r? @ytmimi


  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

Used LLM for adversarial review, not changes.

@rustbot rustbot added the S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. label Oct 23, 2026
@jieyouxu

Copy link
Copy Markdown
Member Author

(First 2 are test logistics, it was annoying me that I couldn't find cfg_select! related tests.)

@ytmimi

ytmimi commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

It feels like we implemented things pretty similarly in regards to what this PR now calls maybe_double_block_concise_formatting and my changes in rust-lang/rust#164815 (comment).

I'd be happy to merge this on the rustfmt side, but I still think we should try to move forward with rust-lang/rust#164815 to provide an immediate fix for nightly in the most common case of a comment being written between the start of the outer block and the inner block.

This PR is more comprehensive with the edge cases that it covers so I'd also be in favor of syncing this up to r-l/r sometime next week if this merges.

@jieyouxu
jieyouxu marked this pull request as ready for review October 24, 2026 03:43
@rustbot rustbot added S-waiting-on-review Status: awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. labels Oct 24, 2026
@jieyouxu

Copy link
Copy Markdown
Member Author

I'd be happy to merge this on the rustfmt side, but I still think we should try to move forward with rust-lang/rust#164815 to provide an immediate fix for nightly in the most common case of a comment being written between the start of the outer block and the inner block.

Sent the r-l/r side to the queue. I think we can merge this PR on rustfmt side as well, we'll sort out the merge conflicts on subtree sync.

@jieyouxu
jieyouxu added this pull request to the merge queue Oct 24, 2026
@jieyouxu jieyouxu added A-comments Area: comments A-cfg_select `cfg_select!` labels Oct 24, 2026
Merged via the queue into rust-lang:main with commit ad7516b Oct 24, 2026
33 checks passed
@rustbot rustbot added release-notes Needs an associated changelog entry and removed S-waiting-on-review Status: awaiting review from the assignee but also interested parties. labels Oct 24, 2026
@jieyouxu jieyouxu added X-impacts-nightly-gated Expected formatting impact: only nightly gated formatting A-macros Area: macros (procedural macros, macro_rules! macros, etc.) labels Oct 24, 2026
@jieyouxu
jieyouxu deleted the jieyouxu/cfg-select-comments branch October 24, 2026 04:01
@rustbot rustbot added this to the 1.101.0 milestone Nov 3, 2026
@ytmimi ytmimi removed the release-notes Needs an associated changelog entry label Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cfg_select `cfg_select!` A-comments Area: comments A-macros Area: macros (procedural macros, macro_rules! macros, etc.) X-impacts-nightly-gated Expected formatting impact: only nightly gated formatting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants