Skip to content

Stop rustfmt deleting attributes in fn params - #161709

Merged
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
teor2345:rustfmt-fn-param-attr-bug
Aug 25, 2026
Merged

Stop rustfmt deleting attributes in fn params#161709
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
teor2345:rustfmt-fn-param-attr-bug

Conversation

@teor2345

@teor2345 teor2345 commented Aug 25, 2026

Copy link
Copy Markdown
Member

Currently, rustfmt deletes attributes in function type parameters, for example:

type F = fn(#[rustc_splat] ());

Becomes:

type F = fn(());

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

@teor2345 teor2345 self-assigned this Aug 25, 2026
@teor2345 teor2345 added C-bug Category: This is a bug. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. F-splat `#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629 labels Aug 25, 2026
@rustbot

This comment was marked as resolved.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 25, 2026
@ytmimi

ytmimi commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@teor2345 you can r=me once CI is green

@jieyouxu

Copy link
Copy Markdown
Member

@bors r=ytmimi rollup

@rust-bors

rust-bors Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 6a1074e has been approved by 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 Aug 25, 2026
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)
@teor2345

Copy link
Copy Markdown
Member Author

We talked about a possible beta backport in Zulip. I'm nominating before it merges because I'm off work for the next few days, and I might forget.

@rustbot beta-nominate T-rustdoc

@rustbot

rustbot commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Error: The feature nominate is not enabled in this repository.
To enable it add its section in the triagebot.toml in the root of the repository.

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip.

@teor2345

Copy link
Copy Markdown
Member Author

Oops, I was following https://forge.rust-lang.org/triagebot/nominate.html#configuration
But I think it's just

@rustbot label +beta-nominated

@rustbot rustbot added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Aug 25, 2026
@rust-bors
rust-bors Bot merged commit c887061 into rust-lang:main Aug 25, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 25, 2026
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
@rustbot

rustbot commented Aug 25, 2026

Copy link
Copy Markdown
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.

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Aug 25, 2026
@cuviper cuviper modified the milestones: 1.100.0, 1.99.0 Aug 25, 2026
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Aug 25, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-accepted Accepted for backporting to the compiler in the beta channel. C-bug Category: This is a bug. F-splat `#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629 S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants