rust-lang / rust-lang/rust-clippy

New lint: `derived_partial_eq_with_manual_eq`

Open
#17,685 1 comment 0 reactions 1 assignee View on GitHub

@wasd243 is already working on this.

Since Sep 15, 2026.

A-lint
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

Disallows a type from having a derived PartialEq with a manual Eq implementation.

Advantage
Drawbacks

No response

Example
#[derive(PartialEq)]
struct Foo {
    value: u32,
}

impl Eq for Foo {}

#[derive(PartialEq)]
struct Bar {
    value: f32,
}

impl Eq for Bar {}

Either both PartialEq and Eq should be manually implemented or both should be derived:

#[derive(PartialEq, Eq)]
struct Foo {
    value: u32,
}

struct Bar {
    value: f32,
}

impl PartialEq for Bar {
    fn eq(&self, other: &Self) -> bool {
        return self.value.to_bits() == other.value.to_bits()
    }
}

impl Eq for Bar {}

Note that the following doesn't compile:

#[derive(PartialEq, Eq)]
struct Bar {
    value: f32,
}
Comparison with existing lints

No response

Additional Context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.