about summary refs log tree commit diff
path: root/library/core
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2024-05-25 15:58:26 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2024-05-25 15:58:26 -0700
commit0c843613423cdd6fdf8d8efe462bfc66640c14f2 (patch)
treef8f7f08ade2bd181e2184628d95fa00ba3c288d0 /library/core
parent48f00110d0dae38b3046a9ac05d20ea321fd6637 (diff)
downloadrust-0c843613423cdd6fdf8d8efe462bfc66640c14f2.tar.gz
rust-0c843613423cdd6fdf8d8efe462bfc66640c14f2.zip
Simplify the `unchecked_sh[lr]` ub-checks a bit
Diffstat (limited to 'library/core')
-rw-r--r--library/core/src/num/int_macros.rs6
-rw-r--r--library/core/src/num/uint_macros.rs6
2 files changed, 4 insertions, 8 deletions
diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs
index b8b4f581a7e..c9c6e34eaad 100644
--- a/library/core/src/num/int_macros.rs
+++ b/library/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/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs
index 141d164de14..f70c34199ac 100644
--- a/library/core/src/num/uint_macros.rs
+++ b/library/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.