rustfmt
rustfmt copied to clipboard
Fix idempotency issue when wrapping the last match arm in a block
Fixes #5193
The issues was related to the interaction between two differnt configuration options when applied to the last match arm.
trailing_comma = Nevermatch_block_trailing_comma = true
Previously, rustfmt only consider the match_block_trailing_comma
configuration value when wrapping match arms. This lead to rustfmt
adding a trailing comma to all newly wrapped match arms.
Now, rustfmt also considers the trailing_comma configuration value
when deciding whether or not to add a trailing comma when wrapping the
last match arm in a block.
@calebcartwright Two things to note:
-
I plan on adding some additional tests cases to cover the various combinations of
trailing_commaandmatch_block_trailing_comma. Just wanted to get the PR in when I identified an initial solution. -
I know you mentioned that #5193 might be a duplicate. If you happen to track down the original issue (or other duplicates), I'll see if this PR fixes them as well and add test cases accordingly!
Changes LGTM @ytmimi, and happy to merge as-is. Will hold off on merging since it sounds like there may be more you want to do, but lmk when you're ready
@calebcartwright Awesome! Yeah, I'd just want to add a few more test cases and see if I can track down any duplicates. I'll make sure to let you know when that's all taken care of!
@calebcartwright no rush on this. I know it's been a while since you've last reviewed it. The last time you looked at these changes you said it was ready to merge, but since I've added some additional test cases I feel like it would be worth it to do another review if we choose to move forward with this