about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Wright <mikerite@lavabit.com>2021-10-30 06:22:19 +0200
committerMichael Wright <mikerite@lavabit.com>2021-10-30 06:22:19 +0200
commit665ff57fde7630474b59fc3f292f2b01a26a3493 (patch)
tree1380eb56988bbf2eccc69ad3d88a9d8c2946dfc4
parent4c70c182c092c4b12c6bc737b808d024ffea6165 (diff)
downloadrust-665ff57fde7630474b59fc3f292f2b01a26a3493.tar.gz
rust-665ff57fde7630474b59fc3f292f2b01a26a3493.zip
Remove expects from FullInt Partial{Ord,Eq}
-rw-r--r--clippy_utils/src/consts.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/clippy_utils/src/consts.rs b/clippy_utils/src/consts.rs
index 3e5d74a66f4..3b718d64ce6 100644
--- a/clippy_utils/src/consts.rs
+++ b/clippy_utils/src/consts.rs
@@ -246,27 +246,26 @@ impl FullInt {
 impl PartialEq for FullInt {
     #[must_use]
     fn eq(&self, other: &Self) -> bool {
-        self.partial_cmp(other).expect("`partial_cmp` only returns `Some(_)`") == Ordering::Equal
+        self.cmp(other) == Ordering::Equal
     }
 }
 
 impl PartialOrd for FullInt {
     #[must_use]
     fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
-        Some(match (self, other) {
-            (&Self::S(s), &Self::S(o)) => s.cmp(&o),
-            (&Self::U(s), &Self::U(o)) => s.cmp(&o),
-            (&Self::S(s), &Self::U(o)) => Self::cmp_s_u(s, o),
-            (&Self::U(s), &Self::S(o)) => Self::cmp_s_u(o, s).reverse(),
-        })
+        Some(self.cmp(other))
     }
 }
 
 impl Ord for FullInt {
     #[must_use]
     fn cmp(&self, other: &Self) -> Ordering {
-        self.partial_cmp(other)
-            .expect("`partial_cmp` for FullInt can never return `None`")
+        match (self, other) {
+            (&Self::S(s), &Self::S(o)) => s.cmp(&o),
+            (&Self::U(s), &Self::U(o)) => s.cmp(&o),
+            (&Self::S(s), &Self::U(o)) => Self::cmp_s_u(s, o),
+            (&Self::U(s), &Self::S(o)) => Self::cmp_s_u(o, s).reverse(),
+        }
     }
 }