Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matthiaskrgr opened this issue Jun 28, 2024 · 0 comments · Fixed by #13324
Closed

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

matthiaskrgr opened this issue Jun 28, 2024 · 0 comments · Fixed by #13324
Labels
I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@matthiaskrgr
Copy link
Member

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

@matthiaskrgr matthiaskrgr added L-suggestion Lint: Improving, adding or fixing lint suggestions I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied labels Jun 28, 2024
@bors bors closed this as completed in bcf528b Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant