Skip to content

Commit 7cddfd4

Browse files
committedMay 25, 2024
Simplify the unchecked_sh[lr] ub-checks a bit
1 parent 23bb5bc commit 7cddfd4

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed
 

‎core/src/num/int_macros.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1282,8 +1282,7 @@ macro_rules! int_impl {
12821282
concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"),
12831283
(
12841284
rhs: u32 = rhs,
1285-
bits: u32 = Self::BITS,
1286-
) => rhs < bits,
1285+
) => rhs < <$ActualT>::BITS,
12871286
);
12881287

12891288
// SAFETY: this is guaranteed to be safe by the caller.
@@ -1381,8 +1380,7 @@ macro_rules! int_impl {
13811380
concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"),
13821381
(
13831382
rhs: u32 = rhs,
1384-
bits: u32 = Self::BITS,
1385-
) => rhs < bits,
1383+
) => rhs < <$ActualT>::BITS,
13861384
);
13871385

13881386
// SAFETY: this is guaranteed to be safe by the caller.

‎core/src/num/uint_macros.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1369,8 +1369,7 @@ macro_rules! uint_impl {
13691369
concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"),
13701370
(
13711371
rhs: u32 = rhs,
1372-
bits: u32 = Self::BITS,
1373-
) => rhs < bits,
1372+
) => rhs < <$ActualT>::BITS,
13741373
);
13751374

13761375
// SAFETY: this is guaranteed to be safe by the caller.
@@ -1468,8 +1467,7 @@ macro_rules! uint_impl {
14681467
concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"),
14691468
(
14701469
rhs: u32 = rhs,
1471-
bits: u32 = Self::BITS,
1472-
) => rhs < bits,
1470+
) => rhs < <$ActualT>::BITS,
14731471
);
14741472

14751473
// SAFETY: this is guaranteed to be safe by the caller.

0 commit comments

Comments
 (0)