yewstack / implicit-clone

Immutable types and ImplicitClone trait similar to Copy
20 stars 10 forks source link

Fix clippy warning related to IString PartialOrd implementation #35

Closed ColonelThirtyTwo closed 1 year ago

kirillsemyonkin commented 1 year ago

Please provide description of why is this needed. I'm being more curious than strict, as to why it passed before and why it needs to be written out like this now.

ColonelThirtyTwo commented 1 year ago

Please provide description of why is this needed. I'm being more curious than strict, as to why it passed before and why it needs to be written out like this now.

As can be seen in the CI failures for my other PRs, the version of clippy included in Rust 1.73.0 issues a new lint for PartialOrd not using the Ord implementaiton, which is true of IString.

> cargo clippy
    Checking implicit-clone v0.4.1 (/home/col/Projects/Code/Libraries/implicit-clone)
error: incorrect implementation of `partial_cmp` on an `Ord` type
   --> src/string.rs:103:9
    |
103 | /          impl $trait<$type2> for $type1 {
104 | |              fn $fn(&self, other: &$type2) -> $ret {
    | | ___________________________________________________-
105 | ||                 $trait::$fn(AsRef::<str>::as_ref(self), AsRef::<str>::as_ref(other))
106 | ||             }
    | ||_____________- help: change this to: `{ Some(self.cmp(other)) }`
107 | |          }
    | |__________^
...
129 |    impl_cmp_as_str!(PartialOrd::<IString, IString>);
    |    ------------------------------------------------ in this macro invocation
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incorrect_partial_ord_impl_on_ord_type
    = note: `#[deny(clippy::incorrect_partial_ord_impl_on_ord_type)]` on by default
    = note: this error originates in the macro `impl_cmp_as_str` (in Nightly builds, run with -Z macro-backtrace for more info)

error: incorrect implementation of `partial_cmp` on an `Ord` type
   --> src/string.rs:103:9
    |
103 | /          impl $trait<$type2> for $type1 {
104 | |              fn $fn(&self, other: &$type2) -> $ret {
    | | ___________________________________________________-
105 | ||                 $trait::$fn(AsRef::<str>::as_ref(self), AsRef::<str>::as_ref(other))
106 | ||             }
    | ||_____________- help: change this to: `{ Some(self.cmp(other)) }`
107 | |          }
    | |__________^
...
129 |    impl_cmp_as_str!(PartialOrd::<IString, IString>);
    |    ------------------------------------------------ in this macro invocation
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incorrect_partial_ord_impl_on_ord_type
    = note: this error originates in the macro `impl_cmp_as_str` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `implicit-clone` (lib) due to 2 previous errors