Add special case handling for matches! to format args as patterns
Open
@topecongiro is already working on this.
Since Oct 10, 2020.
A-macros
C-feature-request
I-poor-formatting
P-low
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Input
matches!(c,
'x' | 'c' | 'b' | 'B' | '?' | 'h' | 'H' | 'i' | 'I' | 'l' | 'L' | 'q' | 'Q' | 'n'
| 'N' | 'f' | 'd' | 's' | 'p' | 'P')
Output
matches!(
c,
'x' | 'c' // <- this part make inconsistency of the formatting
| 'b'
| 'B'
| '?'
| 'h'
| 'H'
| 'i'
| 'I'
| 'l'
| 'L'
| 'q'
| 'Q'
| 'n'
| 'N'
| 'f'
| 'd'
| 's'
| 'p'
| 'P'
)
Expected output
I expect the input form
matches!(c,
'x' | 'c' | 'b' | 'B' | '?' | 'h' | 'H' | 'i' | 'I' | 'l' | 'L' | 'q' | 'Q' | 'n'
| 'N' | 'f' | 'd' | 's' | 'p' | 'P')
Because it is the closest when we use match
match c {
'x' | 'c' | 'b' | 'B' | '?' | 'h' | 'H' | 'i' | 'I' | 'l' | 'L' | 'q' | 'Q' | 'n'
| 'N' | 'f' | 'd' | 's' | 'p' | 'P' => true,
_ => false,
}
Or this kind of form is also acceptable in term of consistency
matches!(
c,
'x'
| 'c'
| 'b'
| 'B'
| '?'
| 'h'
| 'H'
| 'i'
| 'I'
| 'l'
| 'L'
| 'q'
| 'Q'
| 'n'
| 'N'
| 'f'
| 'd'
| 's'
| 'p'
| 'P'
)
Meta
- rustfmt version:
1.4.20-stable (48f6c32e 2020-08-09) - From where did you install rustfmt?: rustup
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.