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
Rustfmt fails to format for_each blocks when there is a long str literal.
example before running rustfmt:
fnmain(){// this block will be properly formatted{let a = 1;let b=2;let c = " very very very very very very very very very very very very very very very very very very long string in a block";}let v = vec![1,2];// this block won't be formatted
v.iter().for_each(|_| {let a = 1;let b=2;let c = " very very very very very very very very very very very very very very very very very very long string in a block";});// this block with shorter str will be properly formatted
v.iter().for_each(|_| {let a = 1;let b=2;let c = " less very very long string in a block";});}
after running rustfmt
fnmain(){// this block will be properly formatted{let a = 1;let b = 2;let c = " very very very very very very very very very very very very very very very very very very long string in a block";}let v = vec![1,2];// this block won't be formatted
v.iter().for_each(|_| {let a = 1;let b=2;let c = " very very very very very very very very very very very very very very very very very very long string in a block";});// this block with shorter str will be properly formatted
v.iter().for_each(|_| {let a = 1;let b = 2;let c = " less very very long string in a block";});}
Not sure if this is a known bug or not ...
EDIT: added example with short &str in for_each block.
The text was updated successfully, but these errors were encountered:
There are some other similar issues, e.g., #3206 and #3135 . From what I remember with these other issues, there is a call to wrap_str that is cancelling any attempts to format that closure.
If you can use the format_strings option, then that block can be formatted.
closing as duplicate of #3863 (realize this is older, but the other issue has more active discussion and plans for next steps so would prefer to consolidate things there)
Rustfmt fails to format for_each blocks when there is a long str literal.
Not sure if this is a known bug or not ...
EDIT: added example with short &str in for_each block.
The text was updated successfully, but these errors were encountered: