Skip to content

PartialOrd bound requires T: Ord, Self: Eq, not T: PartialOrd, Self: PartialEq #42

@stevenengler

Description

@stevenengler

If I derive both PartialOrd and Ord, I get unexpected bounds for PartialOrd.

#[derive(educe::Educe)]
#[educe(PartialEq, Eq, PartialOrd)]
pub struct Foo<T>(T);

results in:

impl<T> ::core::cmp::PartialOrd for Foo<T>
where
    T: ::core::cmp::PartialOrd,
    Self: ::core::cmp::PartialEq,
{ ... }

but:

#[derive(educe::Educe)]
#[educe(PartialEq, Eq, PartialOrd, Ord)]
pub struct Foo<T>(T);

results in:

impl<T> ::core::cmp::PartialOrd for Foo<T>
where
    T: ::core::cmp::Ord,
    Self: ::core::cmp::Eq,
{ ... }

If we compare this to the standard library, we get the expected bounds:

#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub struct Foo<T>(T);
impl<T: ::core::cmp::PartialOrd> ::core::cmp::PartialOrd for Foo<T> { ... }

(And why does educe add a Self bound here?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions