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
The following example does not get formatted at all when running cargo fmt, and does not report anything on cargo fmt --check. I've set max_width = 50 to make it easier to visualize, but similar behavior can be seen with the default max width.
// max width of 50 characters is here ---------->|fn_finagle(){let _my_string =
"The quick brown fox jumps over the lazy dog.".split(" ").next().unwrap();}
This seems to be triggered by the fact that the string literal cannot be formatted to fit within max_width, which can be demonstrated by shortening it. Removing "lazy" causes the above example to get formatted to this:
// max width of 50 characters is here ---------->|fn_finagle(){let _my_string =
"The quick brown fox jumps over the dog.".split(" ").next().unwrap();}
However, I would have expected the original example to format to this:
// max width of 50 characters is here ---------->|fn_finagle(){let _my_string =
"The quick brown fox jumps over the lazy dog.".split(" ").next().unwrap();}
It seems strange for the formatter to give up on the entire statement and ignore random blank lines and indentation if part of it can't be fit within the line length limit.
I'm using rustfmt 1.8.0-stable (05f9846f89 2025-03-31) with edition = "2024".
The text was updated successfully, but these errors were encountered:
J-Westin
changed the title
Chained method statements are not formatted if it contains a string that exceeds max_width
Chained method statements are not formatted if they contain a string that exceeds max_widthMay 6, 2025
The following example does not get formatted at all when running
cargo fmt
, and does not report anything oncargo fmt --check
. I've setmax_width = 50
to make it easier to visualize, but similar behavior can be seen with the default max width.This seems to be triggered by the fact that the string literal cannot be formatted to fit within
max_width
, which can be demonstrated by shortening it. Removing "lazy" causes the above example to get formatted to this:However, I would have expected the original example to format to this:
It seems strange for the formatter to give up on the entire statement and ignore random blank lines and indentation if part of it can't be fit within the line length limit.
I'm using
rustfmt 1.8.0-stable (05f9846f89 2025-03-31)
withedition = "2024"
.The text was updated successfully, but these errors were encountered: