Skip to content

Add special case handling for matches! to format args as patterns #4462

Open
@youknowone

Description

@youknowone

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions