mcarton / rust-derivative

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

clippy::incorrect_partial_ord_impl_on_ord_type tripping up #115

Open rooooooooob opened 1 year ago

rooooooooob commented 1 year ago

This was introduced in rust 1.73. I'm not sure if this is the right spot to report this. I figure it was better here since this isn't a part of standard rust so a clippy issue didn't seem correct. Feel free to close the issue if this isn't the correct spot to handle it.

Having both a Ord and PartialOrd implementation that isn't just delegating to the Ord wrapping in Some will cause this. I assume it's based on how derivative's proc macros implement the traits cause rustc to look at it as if it were hand implemented.

As a user I would assume that using derivative to derive traits should generally function as close to directly using derive() as possible, e.g. to not have this reported when both traits are derived via derivative to match derive()'s behavior here.

As an end user I also couldn't find a place to put [allow(clippy::incorrect_partial_ord_impl_on_ord_type)] locally on the relevant types to suppress it, I imagine due to how derivative + the lint work.

Minimal repro example with rust 1.73 calling cargo clippy

#[derive(Derivative)]
#[derivative(Eq, PartialEq, Ord, PartialOrd)]
pub struct Foo {
    x: i64,
}
AndrewKvalheim commented 10 months ago

This lint has been renamed to clippy::non_canonical_partial_ord_impl.

AndrewKvalheim commented 10 months ago

Likely the same issue as #112