#[derive(Eq)] currently uses the hidden method Eq::assert_receiver_is_total_eq to emit checks that every field of the type being derived on also implements Eq. It would be nice to be able to get rid of it entirely, which requires changing this derive macro to no longer place its checks in this method.
Some implementation notes from #149978 (comment):
For this struct:
struct Point {
x: u32,
y: u32,
}
Instead of generating this:
#[automatically_derived]
impl ::core::cmp::Eq for Point {
#[inline]
#[doc(hidden)]
#[coverage(off)]
#[allow(internal_eq_trait_method_impls)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
You would generate this:
#[automatically_derived]
impl ::core::cmp::Eq for Point {}
const _: () = {
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq() {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
};
One problem is that the const should probably also have #[automatically_derived] put on it, but that's currently not permitted.
#149978 (comment) contains some more notes on this.
Tracking issue: #152336
#[derive(Eq)]currently uses the hidden methodEq::assert_receiver_is_total_eqto emit checks that every field of the type being derived on also implementsEq. It would be nice to be able to get rid of it entirely, which requires changing this derive macro to no longer place its checks in this method.Some implementation notes from #149978 (comment):
For this struct:
Instead of generating this:
You would generate this:
One problem is that the
constshould probably also have#[automatically_derived]put on it, but that's currently not permitted.#149978 (comment) contains some more notes on this.
Tracking issue: #152336