Skip to content

Commit 5f6ccf6

Browse files
committed
document BinOp behavior quirks in the corresponding enum
1 parent 94c9c22 commit 5f6ccf6

File tree

1 file changed

+8
-0
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+8
-0
lines changed

compiler/rustc_middle/src/mir/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2246,8 +2246,12 @@ pub enum BinOp {
22462246
/// The `*` operator (multiplication)
22472247
Mul,
22482248
/// The `/` operator (division)
2249+
///
2250+
/// Division by zero is UB.
22492251
Div,
22502252
/// The `%` operator (modulus)
2253+
///
2254+
/// Using zero as the modulus (second operand) is UB.
22512255
Rem,
22522256
/// The `^` operator (bitwise xor)
22532257
BitXor,
@@ -2256,8 +2260,12 @@ pub enum BinOp {
22562260
/// The `|` operator (bitwise or)
22572261
BitOr,
22582262
/// The `<<` operator (shift left)
2263+
///
2264+
/// The offset is truncated to the size of the first operand before shifting.
22592265
Shl,
22602266
/// The `>>` operator (shift right)
2267+
///
2268+
/// The offset is truncated to the size of the first operand before shifting.
22612269
Shr,
22622270
/// The `==` operator (equality)
22632271
Eq,

0 commit comments

Comments
 (0)