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
With hard_tabs = true, the formatting of some if/else expressions is shifted one level of indentation to the left. Everything works as expected when hard_tabs = false.
Input
fnmain(){let condition_a = true;let condition_b = false;let x = 123.456789
+ if condition_a {
x + y + z + w
}else{123.456789}
+ if condition_b {
x - y - z - w
}else{123.456789};}
Output
The issue is the last three lines of the main() function are indented one level less than expected.
fnmain(){let condition_a = true;let condition_b = false;let x = 123.456789
+ if condition_a {
x + y + z + w
}else{123.456789} + if condition_b {
x - y - z - w
}else{123.456789};}
Expected output
fnmain(){let condition_a = true;let condition_b = false;let x = 123.456789
+ if condition_a {
x + y + z + w
}else{123.456789} + if condition_b {
x - y - z - w
}else{123.456789};}
As with #3151 and #3251, this produces a lot of spaces when hard_tabs = true is combined with the indent_style = "Visual" option, with no improvement on the formatting itself.
fnmain(){let condition_a = true;let condition_b = false;let x = 123.456789
+ if condition_a {
x + y + z + w
}else{123.456789} + if condition_b {
x - y - z - w
}else{123.456789};}
screenshot:
>rustfmt --version
rustfmt 1.4.36-nightly (7de6968e 2021-02-07) # from rustup
The documentation says itʼs supposed to produce those spaces
hard_tabs
Use tab characters for indentation, spaces for alignment
That way, things that are visually aligned stay visually aligned regardless of the tabstop. It doesnʼt look aligned on your screenshot because IDEA added : f64 to the code and rustfmt canʼt know about that to account for it in alignment, but if you donʼt have that it does. Consider the code block right above the screenshot, as seen on my computer:
There, the + on line 5 is aligned right below the 1 on line 4, even though by browser uses 8-space tabs instead of the 4-space ones rustfmt would assume.
Even if this were the wrong behavior, itʼs unrelated to this issue; Iʼm seeing it with 1.4.37-stable with the default indent_style:
fnmain(){let condition_a = true;let condition_b = false;let x = 123.456789
+ if condition_a {
x + y + z + w
}else{123.456789} + if condition_b {
x - y - z - w
}else{123.456789};}
With hard_tabs = true, the formatting of some if/else expressions is shifted one level of indentation to the left. Everything works as expected when hard_tabs = false.
Input
Output
The issue is the last three lines of the
main()
function are indented one level less than expected.Expected output
Meta
The text was updated successfully, but these errors were encountered: