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 output is poorly formatted. The issue occurs with the use_small_heuristics = "Max" config option (because the code is from rust-lang/rust). The first line of the output is 99 characters, so there's no more space for the ) and a newline is added. In this case, I think rustfmt should forget about fitting it on one line and just fall back to the default behavior, which is:
I agree with you in the abstract, but practically speaking I'm not sure there's much we can really do.
Even as minor/preferential as such a change may seem to some in this particular case, it would still be an explicit violation of our formatting stability guarantee which has always been a non-starter. Additionally, the wrapping of the closing paren is part of a last ditch effort to still be able to format while staying within the max_width constraints, and there's plenty of non-chain specific cases where this happens (such as heavy indentation, really long idents, etc.)
By overriding the small heuristics option to Max you're basically opting out of letting rustfmt do the chain wrapping here and asking it to stretch the one-line chain til the very end. While I suppose we could do something like a fall back reformatting the entire chain, I suspect it would be rather fiddly (chains are probably the most complicated to format).
The formatting of that particular chain wouldn't be my preference either, but the result is at least consistent and predictable, especially given the Max heuristics value. Maybe some minor refactoring could help reduce the indention levels or single line chain run?
The full input is quite long so I posted it at the bottom of this issue (it's extracted from rust-lang/rust#81546). The key part is:
Input
Output
The output is poorly formatted. The issue occurs with the
use_small_heuristics = "Max"
config option (because the code is fromrust-lang/rust
). The first line of the output is 99 characters, so there's no more space for the)
and a newline is added. In this case, I think rustfmt should forget about fitting it on one line and just fall back to the default behavior, which is:Another approach could work as well, I'm just suggesting that one since it's the behavior without this config option set.
Full Input
Meta
rustfmt 1.4.32-nightly (216a6430 2021-01-16)
The text was updated successfully, but these errors were encountered: