mcarton / rust-derivative

A set of alternative `derive` attributes for Rust
Apache License 2.0
422 stars 46 forks source link

Add `skip_discriminant` to skip discriminant comparison in derived `PartialEq` implementations #116

Open compiler-errors opened 1 year ago

compiler-errors commented 1 year ago

rustc wants to use derivative to simplify PartialEq derives, but encounters a pretty significant perf hit because the derivative(PartialEq) impl will add a discriminant comparison first, unlike our hand-rolled implementations.

This PR adds a PartialEq = "skip_discriminant" mode to skip generating an initial discriminant comparison so that rustc can derive more tailored PartialEq implementations for derivative. This is proven to work.