Skip to content

Derive Hash while manually implementing PartialEq #381

@tcharding

Description

@tcharding

For the Miniscript struct

#[derive(Clone, Hash)]
pub struct Miniscript<Pk: MiniscriptKey, Ctx: ScriptContext> {

Clippy warns us that we are deriving Hash and using a custom implementation of PartialEq, this is likely wrong as explained in the lint docs.

Here is the clippy warning

error: you are deriving `Hash` but have implemented `PartialEq` explicitly
  --> src/miniscript/mod.rs:60:17
   |
60 | #[derive(Clone, Hash)]
   |                 ^^^^
   |
   = note: `#[deny(clippy::derive_hash_xor_eq)]` on by default
note: `PartialEq` implemented here
  --> src/miniscript/mod.rs:93:1
   |
93 | / impl<Pk: MiniscriptKey, Ctx: ScriptContext> PartialEq for Miniscript<Pk, Ctx> {
94 | |     fn eq(&self, other: &Miniscript<Pk, Ctx>) -> bool {
95 | |         self.node.eq(&other.node)
96 | |     }
97 | | }
   | |_^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_hash_xor_eq
   = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions