You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which looks worse due to splitting the if over multiple lines, and which looks like a bug since in the original code, this line was actually shorter than the next one, so it is clearly below the threshold for breaking long lines. I've never seen normal if behave like that, so it's probably something specific to if let, maybe specific to let_chains even.
This is a recent regression, until recently rustfmt didn't change our formatting here.
The text was updated successfully, but these errors were encountered:
RalfJung
changed the title
Strange linebreaks introduced in if-let expressions
Strange linebreaks introduced in if-let expressions with let_chains
Oct 23, 2023
This isn't a regression. rustfmt wasn't formatting things at all before, and just left the let-chain unformatted. Support for let-chains was added in #5910, and those changes were synced with r-l/rust a little while ago rust-lang/rust#117066. Formatting was implemented following the rules outlined in rust-lang/rust#110568.
Given that let-chains are still unstable the formatting rules haven't been fully decided, but we wanted to get something implemented in rustfmt sooner rather than later. The formatting is subject to change, and if you have thoughts on the formatting rules I think it would be best to reach out to @rust-lang/style
I haven't found a self-contained example of this yet, but this commit demonstrates the problem: rustfmt changes
to
Which looks worse due to splitting the
if
over multiple lines, and which looks like a bug since in the original code, this line was actually shorter than the next one, so it is clearly below the threshold for breaking long lines. I've never seen normalif
behave like that, so it's probably something specific toif let
, maybe specific tolet_chains
even.This is a recent regression, until recently rustfmt didn't change our formatting here.
The text was updated successfully, but these errors were encountered: