This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
compiler/rustc_middle/src/mir Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -1272,13 +1272,18 @@ pub enum BinOp {
12721272 Mul ,
12731273 /// The `/` operator (division)
12741274 ///
1275- /// Division by zero is UB, because the compiler should have inserted checks
1276- /// prior to this.
1275+ /// For integer types, division by zero is UB, as is `MIN / -1` for signed.
1276+ /// The compiler should have inserted checks prior to this.
1277+ ///
1278+ /// Floating-point division by zero is safe, and does not need guards.
12771279 Div ,
12781280 /// The `%` operator (modulus)
12791281 ///
1280- /// Using zero as the modulus (second operand) is UB, because the compiler
1281- /// should have inserted checks prior to this.
1282+ /// For integer types, using zero as the modulus (second operand) is UB,
1283+ /// as is `MIN % -1` for signed.
1284+ /// The compiler should have inserted checks prior to this.
1285+ ///
1286+ /// Floating-point remainder by zero is safe, and does not need guards.
12821287 Rem ,
12831288 /// The `^` operator (bitwise xor)
12841289 BitXor ,
You can’t perform that action at this time.
0 commit comments