Stop rustfmt deleting attributes in fn params - #161709
Merged
rust-bors[bot] merged 4 commits intoAug 25, 2026
Merged
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
|
@teor2345 you can r=me once CI is green |
Member
|
@bors r=ytmimi rollup |
Contributor
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Aug 25, 2026
…, r=ytmimi Stop rustfmt deleting attributes in fn params Currently, rustfmt deletes attributes in function type parameters, for example: ```rust type F = fn(#[rustc_splat] ()); ``` Becomes: ```rust type F = fn(()); ``` [Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=f56e4727022f44a6e5c937c1521830f9) This is an annoying and confusing bug, and causes formatted code to silently change meaning, or fail compilation. This PR cherry-picks the fix and tests from rust-lang/rustfmt#6590 to `rust-lang/rust`. We're discussing a potential beta backport in [Zulip #t-rustfmt > Attributes in fn type deleted on stable but not nightly](https://rust-lang.zulipchat.com/#narrow/channel/357797-t-rustfmt/topic/Attributes.20in.20fn.20type.20deleted.20on.20stable.20but.20not.20nightly/with/618688539), which is why this PR is separate to the subtree sync. Tracking issue: rust-lang#153629 - This formatting bug impacts splatted function pointers - We just published [a "call for experiment" blog post](https://blog.rust-lang.org/inside-rust/2026/08/19/overloading-experiment/), including experiments with splatted function pointers r? @ytmimi
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 25, 2026
Rollup of 9 pull requests Successful merges: - #160533 (dirfd dir operations (3/4)) - #161294 (add crashtests [6/N]) - #160392 (library: motor: bump moto-rt ABI ver to 17) - #161646 (interpret: fix after_local_read handling) - #160819 (Rework `div_ceil` for nonzero integers) - #161591 (run `classify-runtime-const` test for `f128`) - #161680 (renovate: add lockfile update warning) - #161702 (Use `drop_guard` in some places in {core,alloc,std}) - #161709 (Stop rustfmt deleting attributes in fn params)
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 25, 2026
…uwer Rollup of 10 pull requests Successful merges: - #160533 (dirfd dir operations (3/4)) - #161294 (add crashtests [6/N]) - #160392 (library: motor: bump moto-rt ABI ver to 17) - #161646 (interpret: fix after_local_read handling) - #161682 (Update books) - #160819 (Rework `div_ceil` for nonzero integers) - #161204 (core: Make funnel shifts panic only if overflow checks are enabled) - #161591 (run `classify-runtime-const` test for `f128`) - #161680 (renovate: add lockfile update warning) - #161709 (Stop rustfmt deleting attributes in fn params)
Member
Author
Collaborator
|
Error: The feature Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
Member
Author
|
Oops, I was following https://forge.rust-lang.org/triagebot/nominate.html#configuration @rustbot label +beta-nominated |
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 25, 2026
Rollup merge of #161709 - teor2345:rustfmt-fn-param-attr-bug, r=ytmimi Stop rustfmt deleting attributes in fn params Currently, rustfmt deletes attributes in function type parameters, for example: ```rust type F = fn(#[rustc_splat] ()); ``` Becomes: ```rust type F = fn(()); ``` [Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=f56e4727022f44a6e5c937c1521830f9) This is an annoying and confusing bug, and causes formatted code to silently change meaning, or fail compilation. This PR cherry-picks the fix and tests from rust-lang/rustfmt#6590 to `rust-lang/rust`. We're discussing a potential beta backport in [Zulip #t-rustfmt > Attributes in fn type deleted on stable but not nightly](https://rust-lang.zulipchat.com/#narrow/channel/357797-t-rustfmt/topic/Attributes.20in.20fn.20type.20deleted.20on.20stable.20but.20not.20nightly/with/618688539), which is why this PR is separate to the subtree sync. Tracking issue: #153629 - This formatting bug impacts splatted function pointers - We just published [a "call for experiment" blog post](https://blog.rust-lang.org/inside-rust/2026/08/19/overloading-experiment/), including experiments with splatted function pointers r? @ytmimi
Collaborator
|
beta backport approved as per rustfmt team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels are handled by them. |
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 25, 2026
[beta] bump stage0, plus backports - Bump stage0 to stable 1.98.0 - fix buggy MaybeDangling<&T> validation logic #161125 - resolving cyclic glob vis-max #161024 - Check for missing rustfmt in the stdarch intrinsic test step sooner #161641 - Uplift rustfmt macro formatting fix #161370 - Stop rustfmt deleting attributes in fn params #161709 r? me
pull Bot
pushed a commit
to LeeeeeeM/miri
that referenced
this pull request
Aug 26, 2026
…uwer Rollup of 10 pull requests Successful merges: - rust-lang/rust#160533 (dirfd dir operations (3/4)) - rust-lang/rust#161294 (add crashtests [6/N]) - rust-lang/rust#160392 (library: motor: bump moto-rt ABI ver to 17) - rust-lang/rust#161646 (interpret: fix after_local_read handling) - rust-lang/rust#161682 (Update books) - rust-lang/rust#160819 (Rework `div_ceil` for nonzero integers) - rust-lang/rust#161204 (core: Make funnel shifts panic only if overflow checks are enabled) - rust-lang/rust#161591 (run `classify-runtime-const` test for `f128`) - rust-lang/rust#161680 (renovate: add lockfile update warning) - rust-lang/rust#161709 (Stop rustfmt deleting attributes in fn params)
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 27, 2026
[beta] bump stage0, plus backports - Bump stage0 to stable 1.98.0 - fix buggy MaybeDangling<&T> validation logic #161125 - resolving cyclic glob vis-max #161024 - Check for missing rustfmt in the stdarch intrinsic test step sooner #161641 - Uplift rustfmt macro formatting fix #161370 - Stop rustfmt deleting attributes in fn params #161709 - Bust sccache's cache #161384 r? me
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 27, 2026
[beta] bump stage0, plus backports - Bump stage0 to stable 1.98.0 - fix buggy MaybeDangling<&T> validation logic #161125 - resolving cyclic glob vis-max #161024 - Check for missing rustfmt in the stdarch intrinsic test step sooner #161641 - Uplift rustfmt macro formatting fix #161370 - Stop rustfmt deleting attributes in fn params #161709 - Bust sccache's cache #161384 r? me
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 27, 2026
[beta] bump stage0, plus backports - Bump stage0 to stable 1.98.0 - fix buggy MaybeDangling<&T> validation logic #161125 - resolving cyclic glob vis-max #161024 - Check for missing rustfmt in the stdarch intrinsic test step sooner #161641 - Uplift rustfmt macro formatting fix #161370 - Stop rustfmt deleting attributes in fn params #161709 - Bust sccache's cache #161384 r? me
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 27, 2026
[beta] bump stage0, plus backports - Bump stage0 to stable 1.98.0 - fix buggy MaybeDangling<&T> validation logic #161125 - resolving cyclic glob vis-max #161024 - Check for missing rustfmt in the stdarch intrinsic test step sooner #161641 - Uplift rustfmt macro formatting fix #161370 - Stop rustfmt deleting attributes in fn params #161709 - Bust sccache's cache #161384 r? me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, rustfmt deletes attributes in function type parameters, for example:
Becomes:
Playground
This is an annoying and confusing bug, and causes formatted code to silently change meaning, or fail compilation.
This PR cherry-picks the fix and tests from rust-lang/rustfmt#6590 to
rust-lang/rust.We're discussing a potential beta backport in Zulip #t-rustfmt > Attributes in fn type deleted on stable but not nightly, which is why this PR is separate to the subtree sync.
Tracking issue: #153629
r? @ytmimi