Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clippy 1.73 for consistent Ord impl in NumericIndex #2767

Merged
merged 1 commit into from
Oct 5, 2023

Conversation

agourlay
Copy link
Member

@agourlay agourlay commented Oct 5, 2023

New code failing against Clippy on Rust 1.73

Discovered in #2666 (comment)

error: incorrect implementation of `partial_cmp` on an `Ord` type
  --> lib/segment/src/index/field_index/numeric_index/immutable_numeric_index.rs:86:1
   |
86 | /  impl<T: PartialEq + PartialOrd + Encodable> PartialOrd for NumericIndexKey<T> {
87 | |      fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
   | | _______________________________________________________________________-
88 | ||         Some(match self.key.cmp_encoded(&other.key) {
89 | ||             std::cmp::Ordering::Equal => self.idx.cmp(&other.idx),
90 | ||             ord => ord,
91 | ||         })
92 | ||     }
   | ||_____- help: change this to: `{ Some(self.cmp(other)) }`
93 | |  }
   | |__^
   |
   = 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

https://rust-lang.github.io/rust-clippy/master/index.html#/incorrect_partial_ord_impl_on_ord_type

If both PartialOrd and Ord are implemented, they must agree. This is commonly done by wrapping the result of cmp in Some for partial_cmp. Not doing this may silently introduce an error upon refactoring.

@agourlay agourlay requested a review from IvanPleshkov October 5, 2023 16:18
@agourlay
Copy link
Member Author

agourlay commented Oct 5, 2023

Our CI officially upgraded to 1.73 https://github.com/qdrant/qdrant/actions/runs/6421868046/job/17437164076#step:8:1015

Let's unblock it right away 🚀

@agourlay agourlay merged commit 8b2373c into dev Oct 5, 2023
@agourlay agourlay deleted the clippy-numeric-index-ord branch October 5, 2023 16:51
@timvisee timvisee mentioned this pull request Oct 6, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants