Skip to content

Commit 335b5bb

Browse files
committed
MIR operators: clarify Shl/Shr handling of negative offsets
1 parent ac385a5 commit 335b5bb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compiler/rustc_middle/src/mir/syntax.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1480,13 +1480,15 @@ pub enum BinOp {
14801480
BitOr,
14811481
/// The `<<` operator (shift left)
14821482
///
1483-
/// The offset is truncated to the size of the first operand and made unsigned before shifting.
1483+
/// The offset (RHS) is re-interpreted as an unsigned value of the same size and then truncated
1484+
/// to the size of the first operand before shifting.
14841485
Shl,
14851486
/// Like `Shl`, but is UB if the RHS >= LHS::BITS or RHS < 0
14861487
ShlUnchecked,
14871488
/// The `>>` operator (shift right)
14881489
///
1489-
/// The offset is truncated to the size of the first operand and made unsigned before shifting.
1490+
/// The offset (RHS) is re-interpreted as an unsigned value of the same size and then truncated
1491+
/// to the size of the first operand before shifting.
14901492
///
14911493
/// This is an arithmetic shift if the LHS is signed
14921494
/// and a logical shift if the LHS is unsigned.

0 commit comments

Comments
 (0)