Skip to content

single_match suggestion causes deny-by-default eq-op warning #13012

Description

@matthiaskrgr

Description

slightly amused:

#[derive(Eq, PartialEq)]
pub struct Data([u8; 4]);

const DATA: Data = Data([1, 2, 3, 4]);

fn main() {
    match DATA {
        DATA => (),
        _ => (),
    }
}

=>

7  | /     match DATA {
8  | |         DATA => (),
9  | |         _ => (),
10 | |     }
   | |_____^ help: try: `if DATA == DATA { () }`

the suggested code however:

error: equal expressions as operands to `==`
 --> a.rs:7:8
  |
7 |     if DATA == DATA { () }
  |        ^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#eq_op
  = note: `#[deny(clippy::eq_op)]` on by default

Version

rustc 1.81.0-nightly (9c3bc805d 2024-06-27)
binary: rustc
commit-hash: 9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9
commit-date: 2024-06-27
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions