Skip to content

Commit de474da

Browse files
authored
Unrolled build for rust-lang#125559
Rollup merge of rust-lang#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.
2 parents 0aad3f6 + 0c84361 commit de474da

6 files changed

+8
-12
lines changed

library/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.

library/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.

tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
bb1: {
32-
+ _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4, const core::num::<impl u16>::BITS) -> [return: bb2, unwind unreachable];
32+
+ _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4) -> [return: bb2, unwind unreachable];
3333
+ }
3434
+
3535
+ bb2: {

tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
bb1: {
32-
+ _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4, const core::num::<impl u16>::BITS) -> [return: bb2, unwind unreachable];
32+
+ _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4) -> [return: bb2, unwind unreachable];
3333
+ }
3434
+
3535
+ bb2: {

tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
bb1: {
32-
+ _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4, const core::num::<impl i64>::BITS) -> [return: bb2, unwind unreachable];
32+
+ _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4) -> [return: bb2, unwind unreachable];
3333
+ }
3434
+
3535
+ bb2: {

tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
bb1: {
32-
+ _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4, const core::num::<impl i64>::BITS) -> [return: bb2, unwind unreachable];
32+
+ _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4) -> [return: bb2, unwind unreachable];
3333
+ }
3434
+
3535
+ bb2: {

0 commit comments

Comments
 (0)