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
Formatting doesn't work around match in provided reduced example. Formatting for some other parts of the code around method definition works though. Removing at least one character from text string fixes something and formatting starts working again.
To Reproduce
implFoo{pubfnnew() -> Self{{
foo.bar({{match1{ _
=> {iftrue{foo!("if you remove one character from this line formatting works ");}}}}})}}}
Thank you for reaching out @nazar-pc. This is a duplicate (#3863) of a known/existing issues with formatting chains when one or more of the chain elements would exceed max_width when formatted. In these cases, rustfmt leaves the original formatting in place and defers to the developer to properly format, because any formatting rustfmt would apply would violate a rule (max width in this case)
Your snippet above contains a chain due to the foo.bar(... on line 4, and the string arg for foo! exceeds the max_width value of 100. When you remove a char from the string the length drops below the limit and so rustfmt can format.
If you are using rustfmt on nightly, then you can try enabling format_strings = true in your rustfmt config which will allow rustfmt to split the string to stay within the max_width limit. Otherwise you can try splitting the string yourself:
...foo!("if you remove one character from this line \ formatting works ",);
I'm going to go ahead and close this, feel free to track #3863
Describe the bug
Formatting doesn't work around
match
in provided reduced example. Formatting for some other parts of the code around method definition works though. Removing at least one character from text string fixes something and formatting starts working again.To Reproduce
Expected behavior
Formatting works on such file.
Meta
rustfmt
,cargo fmt
, via IDEThe text was updated successfully, but these errors were encountered: