Skip to content

Revert "Fixes adjustment of max_width within macros" (rust-lang/rustfmt#6651) and follow-up (rust-lang/rustfmt#7152) - #7222

Merged
jieyouxu merged 2 commits into
rust-lang:mainfrom
jieyouxu:jieyouxu/revert-macro-fmt
Nov 2, 2026
Merged

jieyouxu merged 2 commits into
rust-lang:mainfrom
jieyouxu:jieyouxu/revert-macro-fmt

Conversation

@jieyouxu

@jieyouxu jieyouxu commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Part of #7223.

See #7221 (comment). This PR reverts both:

  1. Fixes adjustment of max_width within macros #6651 (partially; I kept the baseline test commit but not the actual formatting change commit), and
  2. Use saturating arithmetics for adjust_max_width #7152 (follow-up fix)

I didn't expect #6651 to affect stable formatting (not stable default since it requires stable width options to be changed) since format_macro_bodies is unstable. Which it is, but the default value of format_macro_bodies being yes is part of stable default config; you just can't stably toggle format_macro_bodies to no. So #6651 actually affects stable formatted macro bodies using one of the stable width options, so we can't make that change absent a style edition gate.

Considering #6651 and #7152 are both on 1.100 beta (will become stable next week, but beta branch promotion / forking actually happens this Friday), let's revert to be safe. We can reland #6651 + #7152 + #7221 together to give them two release cycles to bake.

Re-opens #5404.

Notes for the reviewer

  • We need to sync this to rust-lang/rust
  • We'll need to cherry-pick these reverts against rust-lang/rust beta as well

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.

Reverts rust-lang#7152.

This reverts commit 677b954, reversing
changes made to b4260f4.
Reverts rust-lang#6651 since it affects stable macro formatting,
even though `format_macro_bodies` is unstable option (unstability
applies only to the config, the "format macro bodies" value is stable
default formatting). We generally cannot make this change on SE 2024.

This reverts commit 93e78f2.
@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Nov 2, 2026
@jieyouxu jieyouxu added X-impacts-stable-default-format Expected formatting impact: affects stable default format configuration (caution) UO-format_macro_bodies Unstable option: format_macro_bodies A-macros Area: macros (procedural macros, macro_rules! macros, etc.) X-impacts-stable-formatted-code Expected formatting impact: affects stable formatted code (caution) labels Nov 2, 2026
@jieyouxu

jieyouxu commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

(NB: the labels match #6651, but these are still only on beta right now.)

@jieyouxu jieyouxu changed the title Revert "Use saturating arithmetics for adjust_max_width" Revert "Use saturating arithmetics for adjust_max_width" and follow-up Nov 2, 2026
@jieyouxu jieyouxu changed the title Revert "Use saturating arithmetics for adjust_max_width" and follow-up Revert "Use saturating arithmetics for adjust_max_width" (rust-lang/rustfmt#6651) and follow-up Nov 2, 2026
@jieyouxu jieyouxu changed the title Revert "Use saturating arithmetics for adjust_max_width" (rust-lang/rustfmt#6651) and follow-up Revert "Use saturating arithmetics for adjust_max_width" (rust-lang/rustfmt#6651) and follow-up (rust-lang/rustfmt#7152) Nov 2, 2026

@jieyouxu jieyouxu Nov 2, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think I'd like to have stronger test coverage for the reland.

(This is now more obvious on hindsight...)

View changes since the review

@jieyouxu jieyouxu added X-impacts-stable-options Expected formatting impact: impacts stable options (caution) beta-nominated Nominated for backporting to the beta channel. and removed X-impacts-stable-default-format Expected formatting impact: affects stable default format configuration (caution) labels Nov 2, 2026
@jieyouxu

jieyouxu commented Nov 2, 2026 •

Copy link
Copy Markdown
Member Author

@ytmimi since this is essentially 2 clean reverts and we essentially have agreement in #7221 (comment), I'm going to unilaterally merge this revert so I can start on the subtree syncs.

(If there's a problem we can still revert this revert before we land the syncs, so no big deal.)

@jieyouxu
jieyouxu added this pull request to the merge queue Nov 2, 2026
Merged via the queue into rust-lang:main with commit 7b3988a Nov 2, 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 Nov 2, 2026
@jieyouxu
jieyouxu deleted the jieyouxu/revert-macro-fmt branch November 2, 2026 11:00
@jieyouxu jieyouxu mentioned this pull request Nov 2, 2026
1 of 2 tasks
@jieyouxu jieyouxu changed the title Revert "Use saturating arithmetics for adjust_max_width" (rust-lang/rustfmt#6651) and follow-up (rust-lang/rustfmt#7152) Revert "Fixes adjustment of max_width within macros" (rust-lang/rustfmt#6651) and follow-up (rust-lang/rustfmt#7152) Nov 2, 2026
@jieyouxu jieyouxu mentioned this pull request Nov 2, 2026
1 of 2 tasks
@ytmimi

ytmimi commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for getting this merged 🙏🏼

@jieyouxu jieyouxu added the beta-accepted Accepted for backporting to the beta channel. label Nov 3, 2026
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Nov 3, 2026
[beta] Revert "Fixes adjustment of `max_width` within macros" (rust-lang/rustfmt#6651) and follow-up (rust-lang/rustfmt#7152)

rust-lang/rust side beta-backport of rust-lang/rustfmt#7222.

Part of rust-lang/rustfmt#7223.
Closes rust-lang/rustfmt#7223.

See rust-lang/rustfmt#7221 (comment). This PR reverts both:

1. rust-lang/rustfmt#6651 (partially; I kept the baseline test commit but not the actual formatting change commit), and
2. rust-lang/rustfmt#7152 (follow-up fix)

r? @ytmimi
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Nov 3, 2026
[beta] Revert "Fixes adjustment of `max_width` within macros" (rust-lang/rustfmt#6651) and follow-up (rust-lang/rustfmt#7152)

rust-lang/rust side beta-backport of rust-lang/rustfmt#7222.

Part of rust-lang/rustfmt#7223.
Closes rust-lang/rustfmt#7223.

See rust-lang/rustfmt#7221 (comment). This PR reverts both:

1. rust-lang/rustfmt#6651 (partially; I kept the baseline test commit but not the actual formatting change commit), and
2. rust-lang/rustfmt#7152 (follow-up fix)

r? @ytmimi
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Nov 3, 2026
[beta] Revert "Fixes adjustment of `max_width` within macros" (rust-lang/rustfmt#6651) and follow-up (rust-lang/rustfmt#7152)

rust-lang/rust side beta-backport of rust-lang/rustfmt#7222.

Part of rust-lang/rustfmt#7223.
Closes rust-lang/rustfmt#7223.

See rust-lang/rustfmt#7221 (comment). This PR reverts both:

1. rust-lang/rustfmt#6651 (partially; I kept the baseline test commit but not the actual formatting change commit), and
2. rust-lang/rustfmt#7152 (follow-up fix)

r? @ytmimi
@jieyouxu jieyouxu removed the beta-nominated Nominated for backporting to the beta channel. label Nov 3, 2026
@jieyouxu jieyouxu modified the milestones: 1.100.0, 1.101.0 Nov 3, 2026
@jieyouxu

jieyouxu commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Beta cherry-pick of this merged in rust-lang/rust#165368. Technically this PR is both 1.100.0 + 1.101.0.

@rustbot rustbot modified the milestones: 1.100.0, 1.101.0 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-macros Area: macros (procedural macros, macro_rules! macros, etc.) beta-accepted Accepted for backporting to the beta channel. UO-format_macro_bodies Unstable option: format_macro_bodies X-impacts-stable-formatted-code Expected formatting impact: affects stable formatted code (caution) X-impacts-stable-options Expected formatting impact: impacts stable options (caution)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants