about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2021-11-23 20:30:26 -0500
committerRalf Jung <post@ralfj.de>2021-11-23 20:30:26 -0500
commit5f6ccf61218fb98c2aa2cff0af83557d7ccaa5fd (patch)
tree37646745bb22e0504a8df98b80b295c2bc1e187c
parent94c9c22b39d7d82021fe342d19b5248f19335b2f (diff)
downloadrust-5f6ccf61218fb98c2aa2cff0af83557d7ccaa5fd.tar.gz
rust-5f6ccf61218fb98c2aa2cff0af83557d7ccaa5fd.zip
document BinOp behavior quirks in the corresponding enum
-rw-r--r--compiler/rustc_middle/src/mir/mod.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs
index 253ac266bed..4210e07d278 100644
--- a/compiler/rustc_middle/src/mir/mod.rs
+++ b/compiler/rustc_middle/src/mir/mod.rs
@@ -2246,8 +2246,12 @@ pub enum BinOp {
     /// The `*` operator (multiplication)
     Mul,
     /// The `/` operator (division)
+    ///
+    /// Division by zero is UB.
     Div,
     /// The `%` operator (modulus)
+    ///
+    /// Using zero as the modulus (second operand) is UB.
     Rem,
     /// The `^` operator (bitwise xor)
     BitXor,
@@ -2256,8 +2260,12 @@ pub enum BinOp {
     /// The `|` operator (bitwise or)
     BitOr,
     /// The `<<` operator (shift left)
+    ///
+    /// The offset is truncated to the size of the first operand before shifting.
     Shl,
     /// The `>>` operator (shift right)
+    ///
+    /// The offset is truncated to the size of the first operand before shifting.
     Shr,
     /// The `==` operator (equality)
     Eq,