Simplify the `unchecked_sh[lr]` ub-checks a bit · rust-lang/rust@0c84361

6 files changed

lines changed

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.

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.

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: {

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: {

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: {

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: {