MIR operators: clarify Shl/Shr handling of negative offsets

This commit is contained in:
Ralf Jung 2024-05-15 08:22:53 +02:00
parent ac385a5af6
commit 0afd50e852

View File

@ -1480,13 +1480,17 @@ pub enum BinOp {
BitOr, BitOr,
/// The `<<` operator (shift left) /// 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, Shl,
/// Like `Shl`, but is UB if the RHS >= LHS::BITS or RHS < 0 /// Like `Shl`, but is UB if the RHS >= LHS::BITS or RHS < 0
ShlUnchecked, ShlUnchecked,
/// The `>>` operator (shift right) /// 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 /// This is an arithmetic shift if the LHS is signed
/// and a logical shift if the LHS is unsigned. /// and a logical shift if the LHS is unsigned.