Skip to content

rustfmt fails to format matches! call with enum wildcard destructuring and joined patterns #4512

Closed
@matthiaskrgr

Description

@matthiaskrgr

Input

enum X {
    A(String),
    B(u32),
}

fn fun(a: X, b: X) -> bool {
    matches!((a,b), (X::A(_),

X::B(_))|
(X::B(_),


 X::A(_)))
}

Output

enum X {
    A(String),
    B(u32),
}

fn fun(a: X, b: X) -> bool {
    matches!((a,b), (X::A(_),

X::B(_))|
(X::B(_),


 X::A(_)))
}

Expected output
something more like:

enum X {
    A(String),
    B(u32),
}

fn fun(a: X, b: X) -> bool {
    matches!((a ,b),
           (X::A(_), X::B(_))
           | (X::B(_), X::A(_)))
}

Meta
rustfmt 1.4.22-nightly (97d0301 2020-10-04)

  • 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