rust-derivative
rust-derivative copied to clipboard
`derivative(Eq)` doesn't require fields to implement `Eq`
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() {}
Similarly
#[derive(PartialEq, Eq)]
struct Struct {
x: f32,
}
shouldn't compile.
rustc enforces this using secret methods: https://github.com/rust-lang/rust/issues/13101