rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

Allow generic arguments in chain method calls to overflow

Open ytmimi opened this issue 3 years ago • 4 comments
trafficstars

Fixes #5249

Previously, we always formatted generic arguments horizontally.

Now, we attempt to format generic items horizontally, but when doing so would lead to issue like exceeding the max_width we format the generic arguments vertically.


Edit: After doing some backlog triage I found that this would also fix the following:

Closes #3191

ytmimi avatar Mar 03 '22 16:03 ytmimi

I think you're likely heading in the right direction, though remember that we have to remain compliant with style rule prescriptions. Taking a quick glance through the tests I believe what you have so far fails to meet the requirements for the presence of any multi-lined element to require all subsequent elements to be on their own line individually

https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/expressions.md#multi-line-elements

calebcartwright avatar Mar 12 '22 16:03 calebcartwright

Ahh I didn't see that part of the style guide. Thanks for pointing that out 😄. Fingers crossed making the change is a simple enough fix! I know you're a little more familiar with the chain formatting, so I'm wondering if you could point me to where (or explain how) chains know to format all following values vertically?

ytmimi avatar Mar 12 '22 17:03 ytmimi

Actually I may have been doing too much of a drive by and was mistaken. I think the chain layout in your target tests look fine as far as the chain pieces go (suspect I was looking at the source files thinking I was looking at the target), though do want to double check to see if there's potential for any unintended side effects on the arg front

calebcartwright avatar Mar 16 '22 02:03 calebcartwright

Definitely! Take the time you need to properly review the change and if you determine that there's something I'm overlooking here I'd be happy to tweak the implementation.

ytmimi avatar Mar 16 '22 17:03 ytmimi