Skip to content

Store the names of Fn trait parameters in the AST, fix rustfmt bug - #160937

Merged
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
JonathanBrouwer:param_ast
Aug 12, 2026
Merged

Store the names of Fn trait parameters in the AST, fix rustfmt bug#160937
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
JonathanBrouwer:param_ast

Conversation

@JonathanBrouwer

@JonathanBrouwer JonathanBrouwer commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This PR stores the name of a Fn trait parameters in the AST. This is needed because

  • rustfmt needs to rewrite it.
  • this will also be needed in a follow-up PR to do semantic validation.

This PR is split up in commits for reviewability:

I have not worked in the rustfmt codebase before so please review this part carefully.

Tracking issue: #158499
cc @ytmimi @JohnTitor

@rustbot

rustbot commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

rustfmt is developed in its own repository. If possible, consider making this change to rust-lang/rustfmt instead.

cc @rust-lang/rustfmt

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. 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 Aug 11, 2026
@rustbot

rustbot commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

r? @ytmimi

rustbot has assigned @ytmimi.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustfmt, rustfmt-contributors
  • rustfmt, rustfmt-contributors expanded to 6 candidates
  • Random selection from fee1-dead, jieyouxu, ytmimi

@JonathanBrouwer

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue
This should not have any effect, but changing the AST representation (although only a small part of it) deserves a sanity check

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 11, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 11, 2026
Store the names of `Fn` trait parameters in the AST, fix rustfmt bug
@rust-bors

rust-bors Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 0051041 (0051041425480d6ca5704480c6e5a31a5ed63824)
Base parent: e64c8a6 (e64c8a664d9da54fc239cd4404cbf67f0d624326)

@rust-timer

This comment has been minimized.

@ytmimi

ytmimi commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@JonathanBrouwer Thank you, again. I took a look at the rustfmt code changes and they all look very straightforward to me. Having the rustfmt target test case there will help us avoid any regressions and make sure that the formatting stays idempotent.

Assuming that CI passes and the timing run doesn't show any performance impacts from this change you can r=me.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0051041): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary 2.2%, secondary 0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.2% [0.6%, 3.8%] 2
Regressions ❌
(secondary)
1.6% [0.4%, 4.2%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.6% [-1.1%, -0.4%] 10
All ❌✅ (primary) 2.2% [0.6%, 3.8%] 2

Cycles

Results (primary 0.0%, secondary -0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.3% [2.3%, 2.3%] 1
Regressions ❌
(secondary)
1.0% [0.4%, 2.5%] 11
Improvements ✅
(primary)
-2.3% [-2.3%, -2.3%] 1
Improvements ✅
(secondary)
-0.7% [-1.6%, -0.4%] 16
All ❌✅ (primary) 0.0% [-2.3%, 2.3%] 2

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 455.693s -> 460.326s (1.02%)
Artifact size: 396.39 MiB -> 396.43 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 11, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor Author

@bors r=ytmimi rollup

@rust-bors

rust-bors Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 2e63745 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 11, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 11, 2026
Store the names of `Fn` trait parameters in the AST, fix rustfmt bug

This PR stores the name of a `Fn` trait parameters in the AST. This is needed because
* rustfmt needs to rewrite it.
* this will also be needed in a follow-up PR to do semantic validation.

This PR is split up in commits for reviewability:
* `Make inputs to ParenthesizedArgs a ThinVec<Param> in the compiler` changes the AST datatypes, should have no observable effect
* `Fix errors in tooling` deals with the consequenses of the first commit in tooling, should have no observable effect
* `Improve rewrite_generic_args to take pattern into account` fixes rust-lang/rustfmt#7021
* `Add rustfmt regression test` regression test for rust-lang/rustfmt#7021

I have not worked in the rustfmt codebase before so please review this part carefully.

Tracking issue: rust-lang#158499
cc @ytmimi @JohnTitor
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 11, 2026
Store the names of `Fn` trait parameters in the AST, fix rustfmt bug

This PR stores the name of a `Fn` trait parameters in the AST. This is needed because
* rustfmt needs to rewrite it.
* this will also be needed in a follow-up PR to do semantic validation.

This PR is split up in commits for reviewability:
* `Make inputs to ParenthesizedArgs a ThinVec<Param> in the compiler` changes the AST datatypes, should have no observable effect
* `Fix errors in tooling` deals with the consequenses of the first commit in tooling, should have no observable effect
* `Improve rewrite_generic_args to take pattern into account` fixes rust-lang/rustfmt#7021
* `Add rustfmt regression test` regression test for rust-lang/rustfmt#7021

I have not worked in the rustfmt codebase before so please review this part carefully.

Tracking issue: rust-lang#158499
cc @ytmimi @JohnTitor
rust-bors Bot pushed a commit that referenced this pull request Aug 11, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #160620 (Do not pass `-no-pie` on Windows)
 - #160731 (Arc: Remove unnecessary fmt::Display use for overflow assertion)
 - #160760 (Miri: give the incremental session a chance to finish)
 - #160854 (Add -Zwasm-proc-macros flag)
 - #160868 (std: Adjust cfgs again for TLS on WASI)
 - #160894 (Allow running an arbitrary number of try jobs per PR)
 - #160790 (rustc-book: update sys-v abi link)
 - #160878 (Add rust_analyzer to check-cfg names)
 - #160909 (tests/run-make-cargo/thumb-none-cortex-m: bump `cortex-m` dependency)
 - #160920 (No longer mention the removed generic)
 - #160921 (rustdoc: Fix invalid CSS classes generated for notable items)
 - #160924 (split up `rustc_session`)
 - #160934 (Ensure TLS accesses don't call the global allocator through panic)
 - #160937 (Store the names of `Fn` trait parameters in the AST, fix rustfmt bug)
rust-bors Bot pushed a commit that referenced this pull request Aug 12, 2026
Rollup of 14 pull requests

Successful merges:

 - #160620 (Do not pass `-no-pie` on Windows)
 - #160731 (Arc: Remove unnecessary fmt::Display use for overflow assertion)
 - #160854 (Add -Zwasm-proc-macros flag)
 - #160868 (std: Adjust cfgs again for TLS on WASI)
 - #160882 (Add basic `splat` support to `rustdoc`)
 - #160894 (Allow running an arbitrary number of try jobs per PR)
 - #160790 (rustc-book: update sys-v abi link)
 - #160878 (Add rust_analyzer to check-cfg names)
 - #160909 (tests/run-make-cargo/thumb-none-cortex-m: bump `cortex-m` dependency)
 - #160920 (No longer mention the removed generic)
 - #160921 (rustdoc: Fix invalid CSS classes generated for notable items)
 - #160924 (split up `rustc_session`)
 - #160934 (Ensure TLS accesses don't call the global allocator through panic)
 - #160937 (Store the names of `Fn` trait parameters in the AST, fix rustfmt bug)
@rust-bors
rust-bors Bot merged commit 329e321 into rust-lang:main Aug 12, 2026
14 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 12, 2026
rust-timer added a commit that referenced this pull request Aug 12, 2026
Rollup merge of #160937 - JonathanBrouwer:param_ast, r=ytmimi

Store the names of `Fn` trait parameters in the AST, fix rustfmt bug

This PR stores the name of a `Fn` trait parameters in the AST. This is needed because
* rustfmt needs to rewrite it.
* this will also be needed in a follow-up PR to do semantic validation.

This PR is split up in commits for reviewability:
* `Make inputs to ParenthesizedArgs a ThinVec<Param> in the compiler` changes the AST datatypes, should have no observable effect
* `Fix errors in tooling` deals with the consequenses of the first commit in tooling, should have no observable effect
* `Improve rewrite_generic_args to take pattern into account` fixes rust-lang/rustfmt#7021
* `Add rustfmt regression test` regression test for rust-lang/rustfmt#7021

I have not worked in the rustfmt codebase before so please review this part carefully.

Tracking issue: #158499
cc @ytmimi @JohnTitor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. 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.

rustfmt emits non-compiling code by removing tokens from function-like macro invocations

4 participants