Summary
When fn_params_layout is set to Vertical, the trailing comma is removed when there is a single argument and the function name, parameter name, parameter type, or return type is long enough to ensure a multiline layout.
When fn_params_layout is set to Tall (the default), the trailing comma is emitted, as expected.
Example
I tried to format this code:
trait _MultilineFunctions {
fn long_param_name(
very_very_very_very_very_very_very_very_very_very_very_long_param_name: String
);
fn long_param_type(
s: Option<Option<Option<Option<Option<Option<Option<Option<Option<String>>>>>>>>>
);
fn long_return_type(
s: String
) -> Option<Option<Option<Option<Option<Option<Option<Option<Option<String>>>>>>>>>;
fn very_very_very_very_very_very_very_very_very_very_very_long_function_name(
s: String
) -> String;
}
Expected behavior
I expected to see this happen: the single arguments would each have a trailing comma: s: String,.
Actual behavior
Instead, this happened: no trailing commas were emitted, and existing trailing commas were removed.
Configuration
# rustfmt.toml
fn_params_layout = "Vertical"
Meta
rustfmt --version:
rustfmt 1.9.0-stable (59807616e1 2026-04-14)
The same behavior appears on nightly, when run as rustup run nightly cargo fmt.
rustup run nightly rustfmt --version:
rustfmt 1.9.0-nightly (82bee96507 2026-05-09)
Summary
When
fn_params_layoutis set toVertical, the trailing comma is removed when there is a single argument and the function name, parameter name, parameter type, or return type is long enough to ensure a multiline layout.When
fn_params_layoutis set toTall(the default), the trailing comma is emitted, as expected.Example
I tried to format this code:
Expected behavior
I expected to see this happen: the single arguments would each have a trailing comma:
s: String,.Actual behavior
Instead, this happened: no trailing commas were emitted, and existing trailing commas were removed.
Configuration
Meta
rustfmt --version:The same behavior appears on nightly, when run as
rustup run nightly cargo fmt.rustup run nightly rustfmt --version: