Skip to content

Include trailing comma in single param vertical fn#6890

Open
jasonaowen wants to merge 1 commit into
rust-lang:mainfrom
jasonaowen:fn_params_layout-vertical-single-arg-trailing-comma
Open

Include trailing comma in single param vertical fn#6890
jasonaowen wants to merge 1 commit into
rust-lang:mainfrom
jasonaowen:fn_params_layout-vertical-single-arg-trailing-comma

Conversation

@jasonaowen

Copy link
Copy Markdown

When formatting a function with a single parameter with fn_params_layout set to Vertical, the previous tactic would remove any trailing commas before spilling to multiple lines for other reasons, such as long function names or return types. Instead, use the same tactic as Tall does, so that the trailing comma is kept if the end result spans multiple lines.

Resolves #6889 fn_params_layout = "Vertical" removes single argument's trailing comma

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label May 10, 2026
@jieyouxu jieyouxu added SO-fn_params_layout Stable option: fn_params_layout F-impacts-stable-formatted-code Expected formatting impact: affects stable formatted code (caution) F-impacts-stable-options Expected formatting impact: impacts stable options (caution) release-notes Needs an associated changelog entry B-next-style-edition-gate Blocked: can only be done over a style edition; needs a style edition gate labels May 30, 2026

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks. Considering

  • Self-consistency with fn_params_layout = "Tall" which already adds trailing commas for single param fn, and
  • Inserting a trailing comma is generally better for minimizing extra diff lines

This makes sense to me. However, I think the fix needs to be gated behind a style edition.

View changes since this review

Comment thread src/config/options.rs
@rustbot rustbot added S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: awaiting review from the assignee but also interested parties. labels May 30, 2026
@rustbot

rustbot commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@jieyouxu jieyouxu self-assigned this May 30, 2026
@jasonaowen jasonaowen force-pushed the fn_params_layout-vertical-single-arg-trailing-comma branch from 41bcf3d to 0ff3f6c Compare June 12, 2026 05:00
@rustbot

rustbot commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@jasonaowen jasonaowen left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Comment thread src/config/options.rs
Comment thread tests/source/configs/fn_params_layout/vertical.rs
@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 Jun 12, 2026

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, one minor stylistic nit

View changes since this review

Comment thread src/config/options.rs Outdated
Comment thread tests/source/configs/fn_params_layout/vertical.rs
@jieyouxu jieyouxu added A-2027-style-edition Area: style edition 2027 and removed B-next-style-edition-gate Blocked: can only be done over a style edition; needs a style edition gate labels Jun 12, 2026
When formatting a function with a single parameter with
`fn_params_layout` set to `Vertical`, the previous tactic would remove
any trailing commas before spilling to multiple lines for other reasons,
such as long function names or return types. Instead, use the same
tactic as `Tall` does, so that the trailing comma is kept if the end
result spans multiple lines.

`fn_params_layout = "Vertical"` is stable, so this is a breaking change.
Guard on the style edition so that it only takes effect starting in the
next edition.

Issue rust-lang#6889 `fn_params_layout = "Vertical"` removes single argument's
            trailing comma
@jasonaowen jasonaowen force-pushed the fn_params_layout-vertical-single-arg-trailing-comma branch from 0ff3f6c to 20a023d Compare June 12, 2026 21:48

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, this look reasonable to me; handing off to a maintainer for final review.

View changes since this review

@jieyouxu jieyouxu added the pr-ready-to-merge Status: PR is largely ready for merge, waiting for secondary review / last nits label Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-2027-style-edition Area: style edition 2027 F-impacts-stable-formatted-code Expected formatting impact: affects stable formatted code (caution) F-impacts-stable-options Expected formatting impact: impacts stable options (caution) pr-ready-to-merge Status: PR is largely ready for merge, waiting for secondary review / last nits release-notes Needs an associated changelog entry S-waiting-on-review Status: awaiting review from the assignee but also interested parties. SO-fn_params_layout Stable option: fn_params_layout

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fn_params_layout = "Vertical" removes single argument's trailing comma

3 participants