diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2024-05-15 14:21:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-15 14:21:39 +0200 |
| commit | 8d38f2fb11d3536639d1aa0d641e60e1f7dfe64e (patch) | |
| tree | 5165480f4b9a400d480b7866030d59b3815d70a1 | |
| parent | 2659ff3882ea57c680a6bfc6533e95be346ed9ad (diff) | |
| parent | 0afd50e8524aee0e9f23d4881bc7cac687c23ddf (diff) | |
| download | rust-8d38f2fb11d3536639d1aa0d641e60e1f7dfe64e.tar.gz rust-8d38f2fb11d3536639d1aa0d641e60e1f7dfe64e.zip | |
Rollup merge of #125137 - RalfJung:mir-sh, r=scottmcm
MIR operators: clarify Shl/Shr handling of negative offsets "made unsigned" was not fully clear (made unsigned how? by using `abs`? no), so let's say "re-interpreted as an unsigned value of the same size" instead. r? `@scottmcm`
| -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. |
