Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c84361

Browse files
committed
Simplify theunchecked_sh[lr] ub-checks a bit
1 parent48f0011 commit0c84361

6 files changed

+8
-12
lines changed

‎library/core/src/num/int_macros.rs‎

Lines changed: 2 additions & 4 deletions
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‎

Lines changed: 2 additions & 4 deletions
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‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 1 addition & 1 deletion
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)

[8]ページ先頭

©2009-2025 Movatter.jp