Simplify the unchecked_sh[lr] ub-checks a bit · rust-lang/rust@0c84361 (original) (raw)

6 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -1282,8 +1282,7 @@ macro_rules! int_impl {
1282 1282 concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"),
1283 1283 (
1284 1284 rhs: u32 = rhs,
1285 - bits: u32 = Self::BITS,
1286 -) => rhs < bits,
1285 +) => rhs < <$ActualT>::BITS,
1287 1286 );
1288 1287
1289 1288 // SAFETY: this is guaranteed to be safe by the caller.
@@ -1381,8 +1380,7 @@ macro_rules! int_impl {
1381 1380 concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"),
1382 1381 (
1383 1382 rhs: u32 = rhs,
1384 - bits: u32 = Self::BITS,
1385 -) => rhs < bits,
1383 +) => rhs < <$ActualT>::BITS,
1386 1384 );
1387 1385
1388 1386 // SAFETY: this is guaranteed to be safe by the caller.
Original file line number Diff line number Diff line change
@@ -1369,8 +1369,7 @@ macro_rules! uint_impl {
1369 1369 concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"),
1370 1370 (
1371 1371 rhs: u32 = rhs,
1372 - bits: u32 = Self::BITS,
1373 -) => rhs < bits,
1372 +) => rhs < <$ActualT>::BITS,
1374 1373 );
1375 1374
1376 1375 // SAFETY: this is guaranteed to be safe by the caller.
@@ -1468,8 +1467,7 @@ macro_rules! uint_impl {
1468 1467 concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"),
1469 1468 (
1470 1469 rhs: u32 = rhs,
1471 - bits: u32 = Self::BITS,
1472 -) => rhs < bits,
1470 +) => rhs < <$ActualT>::BITS,
1473 1471 );
1474 1472
1475 1473 // SAFETY: this is guaranteed to be safe by the caller.
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@
29 29 }
30 30
31 31 bb1: {
32 -+ _6 = core::num::::unchecked_shl::precondition_check(_4, const core::num::::BITS) -> [return: bb2, unwind unreachable];
32 ++ _6 = core::num::::unchecked_shl::precondition_check(_4) -> [return: bb2, unwind unreachable];
33 33 + }
34 34 +
35 35 + bb2: {
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@
29 29 }
30 30
31 31 bb1: {
32 -+ _6 = core::num::::unchecked_shl::precondition_check(_4, const core::num::::BITS) -> [return: bb2, unwind unreachable];
32 ++ _6 = core::num::::unchecked_shl::precondition_check(_4) -> [return: bb2, unwind unreachable];
33 33 + }
34 34 +
35 35 + bb2: {
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@
29 29 }
30 30
31 31 bb1: {
32 -+ _6 = core::num::::unchecked_shr::precondition_check(_4, const core::num::::BITS) -> [return: bb2, unwind unreachable];
32 ++ _6 = core::num::::unchecked_shr::precondition_check(_4) -> [return: bb2, unwind unreachable];
33 33 + }
34 34 +
35 35 + bb2: {
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@
29 29 }
30 30
31 31 bb1: {
32 -+ _6 = core::num::::unchecked_shr::precondition_check(_4, const core::num::::BITS) -> [return: bb2, unwind unreachable];
32 ++ _6 = core::num::::unchecked_shr::precondition_check(_4) -> [return: bb2, unwind unreachable];
33 33 + }
34 34 +
35 35 + bb2: {