rust-clippy
rust-clippy copied to clipboard
`derive_partial_eq_without_eq` false positive in struct using traits
Summary
This is a somewhat convoluted scenario for which I can't provide a concise textual explanation and I couldn't make the reproducer any simpler. But it wrongly emits derive_partial_eq_without_eq
when it clearly already has Eq
.
Lint Name
derive_partial_eq_without_eq
Reproducer
I tried this code:
pub trait Group {
type Element: Eq + PartialEq;
}
pub trait Ciphersuite {
type Group: Group;
}
#[derive(PartialEq, Eq)]
pub struct Public<C: Ciphersuite>(<C::Group as Group>::Element);
fn main() {}
I saw this happen:
warning: you are deriving `PartialEq` and can implement `Eq`
--> src/main.rs:9:10
|
9 | #[derive(PartialEq, Eq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= note: `#[warn(clippy::derive_partial_eq_without_eq)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
warning: `partialeq` (bin "partialeq") generated 1 warning
I expected to see this happen:
No warnings emitted.
Version
rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-unknown-linux-gnu
release: 1.63.0
LLVM version: 14.0.5
Additional Labels
No response
This is the faulty line: https://github.com/rust-lang/rust-clippy/blob/e120fb10c60a27670c72e7ec99e93d16c045f493/clippy_lints/src/derive.rs#L472, so either https://github.com/rust-lang/rust-clippy/blob/e120fb10c60a27670c72e7ec99e93d16c045f493/clippy_lints/src/derive.rs#L493 gives wrong envs or some type parameters needs to be given in that case. Maybe @Jarcho you have an idea of what could be wrong? You wrote the latter method
huh, the problem still exist so... don't mind if I try~
@rustbot claim