Open pozdneev opened 2 years ago
linking tracking issue for control_brace_style https://github.com/rust-lang/rustfmt/issues/3377
I just want to note that AlwaysSameLine
is the default, so at least the first buggy example should be reproducible with only stable options (or no options at all) and the others only really configure max_width
which probably does not have anything to do with this bug, so the label is probably wrong
This bug seems similar to #3560.
If the
if let
ofif
line length is nearmax_width
, then thecontrol_brace_style
option ofrustfmt
pushes the opening brace to the next line. (Notice that this option is still unstable.)I observe this behaviour for "rustfmt 1.4.38-nightly (9257f5aa 2022-05-21)".
In the examples given below, the closing parenthesis character in the non-wrapped
if let
- anif
- expressions is the 100th character in the line."AlwaysSameLine"
The formatting does match the expectations neither for
if let
, nor forif
:"AlwaysSameLine"
+max_width=102
The formatting matches the expectations for both
if let
andif
:"AlwaysSameLine"
+max_width=99
The formatting does match the expectations for
if let
, but matches the expectations forif
:(A similar issue to the one shown in this example is mentioned here: https://github.com/rust-lang/rustfmt/issues/3560#issuecomment-493670516. In that one, the content of the
if let
is much less thanmax_width
, but it gets folded like here, and the opening brace is pushed to the next line as well.)"AlwaysNextLine"
The formatting matches the expectations for both
if let
andif
: