diff options
| author | Michael Wright <mikerite@lavabit.com> | 2021-10-30 06:22:19 +0200 |
|---|---|---|
| committer | Michael Wright <mikerite@lavabit.com> | 2021-10-30 06:22:19 +0200 |
| commit | c8edd9a16e2e9db1fa2f26a0164740ae426f4876 (patch) | |
| tree | 29a2db7b4799e6258620e5fc54c09288ebc34a9d | |
| parent | 665ff57fde7630474b59fc3f292f2b01a26a3493 (diff) | |
| download | rust-c8edd9a16e2e9db1fa2f26a0164740ae426f4876.tar.gz rust-c8edd9a16e2e9db1fa2f26a0164740ae426f4876.zip | |
Remove casts from FullInt impl
| -rw-r--r-- | clippy_utils/src/consts.rs | 9 |
1 files changed, 1 insertions, 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)) } } |
