From 7cddfd469309af983658f2397c74992cb2b2c89b Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 25 May 2024 15:58:26 -0700 Subject: [PATCH] Simplify the `unchecked_sh[lr]` ub-checks a bit --- core/src/num/int_macros.rs | 6 ++---- core/src/num/uint_macros.rs | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/core/src/num/int_macros.rs b/core/src/num/int_macros.rs index b8b4f581a7e63..c9c6e34eaad8e 100644 --- a/core/src/num/int_macros.rs +++ b/core/src/num/int_macros.rs @@ -1282,8 +1282,7 @@ macro_rules! int_impl { concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"), ( rhs: u32 = rhs, - bits: u32 = Self::BITS, - ) => rhs < bits, + ) => rhs < <$ActualT>::BITS, ); // SAFETY: this is guaranteed to be safe by the caller. @@ -1381,8 +1380,7 @@ macro_rules! int_impl { concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"), ( rhs: u32 = rhs, - bits: u32 = Self::BITS, - ) => rhs < bits, + ) => rhs < <$ActualT>::BITS, ); // SAFETY: this is guaranteed to be safe by the caller. diff --git a/core/src/num/uint_macros.rs b/core/src/num/uint_macros.rs index 141d164de14a2..f70c34199acec 100644 --- a/core/src/num/uint_macros.rs +++ b/core/src/num/uint_macros.rs @@ -1369,8 +1369,7 @@ macro_rules! uint_impl { concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"), ( rhs: u32 = rhs, - bits: u32 = Self::BITS, - ) => rhs < bits, + ) => rhs < <$ActualT>::BITS, ); // SAFETY: this is guaranteed to be safe by the caller. @@ -1468,8 +1467,7 @@ macro_rules! uint_impl { concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"), ( rhs: u32 = rhs, - bits: u32 = Self::BITS, - ) => rhs < bits, + ) => rhs < <$ActualT>::BITS, ); // SAFETY: this is guaranteed to be safe by the caller.