match arm grouping with |
can make it hard to distinguish groups of arms
#1129
Labels
|
can make it hard to distinguish groups of arms
#1129
rustfmt renders the following match as it is shown:
Personally, I find that it is visually challenging to identify the "groups" of arms here. This would be even more true if (e.g.)
BuildFail(..)
were a longer pattern likeBuildFail(ref a, SomeStruct { b, c })
etc. The problem is that then you have to scan pretty far to the right to find if there is a=>
or a|
. I have definitely had cases in rustc where I thought the grouping was one thing but it was another.I would prefer a newline after the
=>
:Or maybe, though it's not what I would do myself, a newline separating the groups:
My rule of thumb is to put a newline after the
=>
if there are|
patterns involved (and also to try and put newlines after the=>
if any other groups of patterns have a newline), unless the expression is a block expression (=> {\n
).I am not really familiar with the totality of the match heuristics involved in rustfmt so I can't say how this fits in.
The text was updated successfully, but these errors were encountered: