Skip to content

derive_hash_xor_eq deny deriving PartialEq when implementing Hash manually #2627

Closed
@Alvenix

Description

@Alvenix

According to here

derive_hash_xor_eq "Checks for deriving Hash but implementing PartialEq explicitly." however even doing the reverse is denied too.

I have tried the minimal example below and still faced this problem:

use std::hash::{Hash, Hasher};

#[derive(PartialEq)]
struct Duck {}

impl Hash for Duck {
    fn hash<H: Hasher>(&self, _: &mut H) {}
}
fn main() {}

Where running clippy results in this:


error: you are implementing `Hash` explicitly but have derived `PartialEq`
 --> src/main.rs:6:1
  |
6 | / impl Hash for Duck {
7 | |     fn hash<H: Hasher>(&self, _: &mut H) {}
8 | | }
  | |_^
  |
  = note: #[deny(derive_hash_xor_eq)] on by default
note: `PartialEq` implemented here
 --> src/main.rs:3:10
  |
3 | #[derive(PartialEq)]
  |          ^^^^^^^^^
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.191/index.html#derive_hash_xor_eq

error: aborting due to previous error

error: Could not compile `hashequal`.

I am using the latest rust nightly and the latest clippy. (mac os)

I have tried to look at the code and this seems intentional -well even the name seems to imply so- so maybe only the documentation should change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-documentationArea: Adding or improving documentationgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions