Skip to content

TotalEq shouldn't need to have the secret method just for #[deriving] #13101

Closed
@huonw

Description

@huonw

The assert_receiver_is_total_eq method is purely so that #[deriving] can enforce that all the contained types are TotalEq. It currently exists because the #[deriving] infrastructure makes it much much much easier to work with a method on a trait than with anything else.

Preferably #[deriving] would be refactored to allow creating a non trait function along the lines of

#[deriving(TotalEq)]
struct Foo<T> {
     x: int,
     y: T
}

// expands to

impl<T: TotalEq> TotalEq for Foo<T> {}

impl<T: TotalEq> Foo<T> {
     #[allow(dead_code)]
     fn assert_Foo_is_total_eq(&self) {
         fn total_eq<T: TotalEq>(_: &T) {}

         total_eq(&self.x);
         total_eq(&self.y);
     }
}

which would allow TotalEq to become just trait TotalEq: Eq {}.

(Placeholder issue for now.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.rust-2-breakage-wishlistIn the wishlist of breaking changes that requires rust 2.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions