Rollup merge of #125559 - scottmcm:simplify-shift-ubcheck, r=workingjubilee

Simplify the `unchecked_sh[lr]` ub-checks a bit

It can use the constant in the check, rather than passing it as a parameter.
This commit is contained in:
Jubilee 2024-05-26 15:28:28 -07:00 committed by GitHub
commit 25b079a1cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 8 additions and 12 deletions

View File

@ -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.

View File

@ -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.

View File

@ -29,7 +29,7 @@
}
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: {

View File

@ -29,7 +29,7 @@
}
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: {

View File

@ -29,7 +29,7 @@
}
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: {

View File

@ -29,7 +29,7 @@
}
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: {