Skip to content

Commit

Permalink
Suppress incorrect_partial_ord_impl_on_ord_type lint within generated…
Browse files Browse the repository at this point in the history
… code

    warning: incorrect implementation of `partial_cmp` on an `Ord` type
      --> tests/ffi/lib.rs:27:43
       |
    27 |     #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
       |                                           ^^^^^^^^^^ help: change this to: `{ Some(self.cmp(other)) }`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incorrect_partial_ord_impl_on_ord_type
       = note: `-W clippy::incorrect-partial-ord-impl-on-ord-type` implied by `-W clippy::all`

    warning: incorrect implementation of `partial_cmp` on an `Ord` type
      --> tests/ffi/lib.rs:37:27
       |
    37 |     #[derive(Debug, Hash, PartialOrd, Ord)]
       |                           ^^^^^^^^^^ help: change this to: `{ Some(self.cmp(other)) }`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incorrect_partial_ord_impl_on_ord_type

    warning: incorrect implementation of `partial_cmp` on an `Ord` type
      --> tests/ffi/lib.rs:89:69
       |
    89 |     #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
       |                                                                     ^^^^^^^^^^ help: change this to: `{ Some(self.cmp(other)) }`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incorrect_partial_ord_impl_on_ord_type
  • Loading branch information
dtolnay committed Jul 18, 2023
1 parent a5e4f14 commit 28954ac
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions macro/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ fn struct_partial_ord(strct: &Struct, span: Span) -> TokenStream {

quote_spanned! {span=>
impl #generics ::cxx::core::cmp::PartialOrd for #ident #generics {
#[allow(clippy::incorrect_partial_ord_impl_on_ord_type)]
fn partial_cmp(&self, other: &Self) -> ::cxx::core::option::Option<::cxx::core::cmp::Ordering> {
#body
}
Expand Down Expand Up @@ -280,6 +281,7 @@ fn enum_partial_ord(enm: &Enum, span: Span) -> TokenStream {

quote_spanned! {span=>
impl ::cxx::core::cmp::PartialOrd for #ident {
#[allow(clippy::incorrect_partial_ord_impl_on_ord_type)]
fn partial_cmp(&self, other: &Self) -> ::cxx::core::option::Option<::cxx::core::cmp::Ordering> {
::cxx::core::cmp::PartialOrd::partial_cmp(&self.repr, &other.repr)
}
Expand Down

0 comments on commit 28954ac

Please sign in to comment.