From c8edd9a16e2e9db1fa2f26a0164740ae426f4876 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Sat, 30 Oct 2021 06:22:19 +0200 Subject: [PATCH] Remove casts from FullInt impl --- clippy_utils/src/consts.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/clippy_utils/src/consts.rs b/clippy_utils/src/consts.rs index 3b718d64ce6..85dad1dcfb2 100644 --- a/clippy_utils/src/consts.rs +++ b/clippy_utils/src/consts.rs @@ -230,16 +230,9 @@ pub enum FullInt { } impl FullInt { - #[allow(clippy::cast_sign_loss)] #[must_use] fn cmp_s_u(s: i128, u: u128) -> Ordering { - if s < 0 { - Ordering::Less - } else if u > (i128::MAX as u128) { - Ordering::Greater - } else { - (s as u128).cmp(&u) - } + u128::try_from(s).map_or(Ordering::Less, |x| x.cmp(&u)) } }