rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

Rustfmt add unwanted line wrap and indentation when formatting tuple method call

Open dartt0n opened this issue 2 years ago • 0 comments

rustfmt 1.7.0-stable (82e1608d 2023-12-21) formats the tuple method call very weirdly when the tuple takes up several lines. It adds new line after ) and additional indent.

let x = (
    "some-very-long-first-argument-of-the-tuple",
    "second-argument",
)
    .into();

This produces really weird artefacts in some codebases. For example, some axum code:

return (
    StatusCode::CONFLICT,
    Html(format!("email {email} is already taken")),
)
    .into_response()

Expected formatting is the following:

let x = (
    "some-very-long-first-argument-of-the-tuple",
    "second-argument",
)
.into();
return (
    StatusCode::CONFLICT,
    Html(format!("email {email} is already taken")),
)
.into_response()

dartt0n avatar Jan 12 '24 00:01 dartt0n