Skip to content

match_single_binding should ommit entire statement instead of suggestion broken "()" ? #10447

@matthiaskrgr

Description

@matthiaskrgr

Summary

.

Lint Name

match_single_binding

Reproducer

I tried this code:

pub fn a() -> usize {
    match 1 {
        _ => (),
    }
    2
}

pub fn main() {}

Clippy will suggest

pub fn a() -> usize {
    ()
    2
}

but this will not build


error: expected `;`, found `2`
 --> src/main.rs:2:4
  |
2 |     ()
  |       ^ help: add `;` here
3 |     2
  |     - unexpected token

maybe we can make it (); or just suggest removal of the entire match?

Version

rustc 1.69.0-nightly (b1719530f 2023-03-04)
binary: rustc
commit-hash: b1719530f44e3c8ec903f76020a52bd8764d5d10
commit-date: 2023-03-04
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions