Open tspiteri opened 6 years ago
confirming this is still reproducible on rustfmt 1.5.1-nightly (a7bf0090 2022-07-17)
@calebcartwright I know chains are a fairly tricky part of the codebase, but just wanted to walk you through what I found and get your thoughts.
I believe the issue can be tracked down to ChainFormatterShared::format_last_child
.
first we include the number of tries when computing almost_total
We also subtract the number of tries when computing the last_shape
And lastly to compute the one_line_shape
we then offset the width by the almost_total
, thereby double counting the tries.
Version: rustfmt 0.9.0-beta (69ad879 2018-07-27)
This code is unchanged with 0.8.2:
With 0.9.0-beta, it becomes:
It is not clear to me why the line is split; it is only 99 characters long.