mcarton/rust-derivative

`derivative(Eq)` doesn't require fields to implement `Eq`

mcarton opened this issue · 0 comments

The following compiles but shouldn't because Error is only PartialEq and not Eq:

#[derive(derivative::Derivative)]
#[derivative(PartialEq)]
struct Error;

#[derive(derivative::Derivative)]
#[derivative(PartialEq, Eq)]
struct Struct {
    x: Error,
}

fn main() {}

(Permalink to the playground)

Similarly

#[derive(PartialEq, Eq)]
struct Struct {
    x: f32,
}

shouldn't compile.

rustc enforces this using secret methods: rust-lang/rust#13101