diff options
| author | Ralf Jung <post@ralfj.de> | 2024-05-15 08:22:53 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-05-15 10:25:39 +0200 |
| commit | 0afd50e8524aee0e9f23d4881bc7cac687c23ddf (patch) | |
| tree | 5521009180d2e69c6f51c8bbb44a031e89ae5275 | |
| parent | ac385a5af6d9fa8399a0cec799833cd28324abf8 (diff) | |
| download | rust-0afd50e8524aee0e9f23d4881bc7cac687c23ddf.tar.gz rust-0afd50e8524aee0e9f23d4881bc7cac687c23ddf.zip | |
MIR operators: clarify Shl/Shr handling of negative offsets
| -rw-r--r-- | compiler/rustc_middle/src/mir/syntax.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 4278ce823d0..e124b478f41 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -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. |
