Skip to content

rustfmt thinks that a pattern matching is a closure #5709

Open
@real-felix

Description

@real-felix

When formatting this code:

fn is_something(foo: Foo, bar: Bar) -> bool {
    matches!((legacy_required_finality, signature_weight),
        | (LegacyRequiredFinality::Any, Insufficient | Weak | Strict)
        | (LegacyRequiredFinality::Weak, Weak | Strict)
        | (LegacyRequiredFinality::Strict, Strict)
    )
}

It is written like that:

fn is_something(foo: Foo, bar: Bar) -> bool {
    matches!((legacy_required_finality, signature_weight), |(
        LegacyRequiredFinality::Any,
        Insufficient | Weak | Strict,
    )| (
        LegacyRequiredFinality::Weak,
        Weak | Strict
    ) | (
        LegacyRequiredFinality::Strict,
        Strict
    ))
}

I think that rustfmt sees it as a closure.

I tried to reproduce with a simpler example, but it doesn't work. I think it comes from diverse things, like the fact there is a tuple.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions