Skip to content

Commit

Permalink
MIR operators: clarify Shl/Shr handling of negative offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed May 15, 2024
1 parent ac385a5 commit 0afd50e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1480,13 +1480,17 @@ pub enum BinOp {
BitOr,
/// The `<<` operator (shift left)
///
/// The offset is truncated to the size of the first operand and made unsigned before shifting.
/// The offset is (uniquely) determined as follows:
/// - it is "equal modulo LHS::BITS" to the RHS
/// - it is in the range `0..LHS::BITS`
Shl,
/// Like `Shl`, but is UB if the RHS >= LHS::BITS or RHS < 0
ShlUnchecked,
/// The `>>` operator (shift right)
///
/// The offset is truncated to the size of the first operand and made unsigned before shifting.
/// The offset is (uniquely) determined as follows:
/// - it is "equal modulo LHS::BITS" to the RHS
/// - it is in the range `0..LHS::BITS`
///
/// This is an arithmetic shift if the LHS is signed
/// and a logical shift if the LHS is unsigned.
Expand Down

0 comments on commit 0afd50e

Please sign in to comment.