Simplify the unchecked_sh[lr] ub-checks a bit

This commit is contained in:
Scott McMurray 2024-05-25 15:58:26 -07:00
parent 48f00110d0
commit 0c84361342
6 changed files with 8 additions and 12 deletions

View File

@ -1282,8 +1282,7 @@ pub const fn strict_shl(self, rhs: u32) -> Self {
concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"), concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"),
( (
rhs: u32 = rhs, rhs: u32 = rhs,
bits: u32 = Self::BITS, ) => rhs < <$ActualT>::BITS,
) => rhs < bits,
); );
// SAFETY: this is guaranteed to be safe by the caller. // SAFETY: this is guaranteed to be safe by the caller.
@ -1381,8 +1380,7 @@ pub const fn strict_shr(self, rhs: u32) -> Self {
concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"), concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"),
( (
rhs: u32 = rhs, rhs: u32 = rhs,
bits: u32 = Self::BITS, ) => rhs < <$ActualT>::BITS,
) => rhs < bits,
); );
// SAFETY: this is guaranteed to be safe by the caller. // SAFETY: this is guaranteed to be safe by the caller.

View File

@ -1369,8 +1369,7 @@ pub const fn strict_shl(self, rhs: u32) -> Self {
concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"), concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"),
( (
rhs: u32 = rhs, rhs: u32 = rhs,
bits: u32 = Self::BITS, ) => rhs < <$ActualT>::BITS,
) => rhs < bits,
); );
// SAFETY: this is guaranteed to be safe by the caller. // SAFETY: this is guaranteed to be safe by the caller.
@ -1468,8 +1467,7 @@ pub const fn strict_shr(self, rhs: u32) -> Self {
concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"), concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"),
( (
rhs: u32 = rhs, rhs: u32 = rhs,
bits: u32 = Self::BITS, ) => rhs < <$ActualT>::BITS,
) => rhs < bits,
); );
// SAFETY: this is guaranteed to be safe by the caller. // SAFETY: this is guaranteed to be safe by the caller.

View File

@ -29,7 +29,7 @@
} }
bb1: { bb1: {
+ _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4, const core::num::<impl u16>::BITS) -> [return: bb2, unwind unreachable]; + _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4) -> [return: bb2, unwind unreachable];
+ } + }
+ +
+ bb2: { + bb2: {

View File

@ -29,7 +29,7 @@
} }
bb1: { bb1: {
+ _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4, const core::num::<impl u16>::BITS) -> [return: bb2, unwind unreachable]; + _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4) -> [return: bb2, unwind unreachable];
+ } + }
+ +
+ bb2: { + bb2: {

View File

@ -29,7 +29,7 @@
} }
bb1: { bb1: {
+ _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4, const core::num::<impl i64>::BITS) -> [return: bb2, unwind unreachable]; + _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4) -> [return: bb2, unwind unreachable];
+ } + }
+ +
+ bb2: { + bb2: {

View File

@ -29,7 +29,7 @@
} }
bb1: { bb1: {
+ _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4, const core::num::<impl i64>::BITS) -> [return: bb2, unwind unreachable]; + _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4) -> [return: bb2, unwind unreachable];
+ } + }
+ +
+ bb2: { + bb2: {