From cb5319483e0691393bd3e09a808f734321a23d20 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 22 May 2024 09:00:07 +0200 Subject: [PATCH] clarify comment Co-authored-by: scottmcm --- compiler/rustc_const_eval/src/interpret/operator.rs | 4 +++- compiler/rustc_middle/src/mir/tcx.rs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_const_eval/src/interpret/operator.rs b/compiler/rustc_const_eval/src/interpret/operator.rs index 009f94538a3..6992856053a 100644 --- a/compiler/rustc_const_eval/src/interpret/operator.rs +++ b/compiler/rustc_const_eval/src/interpret/operator.rs @@ -324,7 +324,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } } - /// Returns the result of the specified operation, and whether it overflowed. + /// Returns the result of the specified operation. + /// + /// Whether this produces a scalar or a pair depends on the specific `bin_op`. pub fn binary_op( &self, bin_op: mir::BinOp, diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index 56aba3c04ed..c191de45e70 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -297,6 +297,8 @@ impl BorrowKind { impl BinOp { pub fn to_hir_binop(self) -> hir::BinOpKind { match self { + // HIR `+`/`-`/`*` can map to either of these MIR BinOp, depending + // on whether overflow checks are enabled or not. BinOp::Add | BinOp::AddWithOverflow => hir::BinOpKind::Add, BinOp::Sub | BinOp::SubWithOverflow => hir::BinOpKind::Sub, BinOp::Mul | BinOp::MulWithOverflow => hir::BinOpKind::Mul, @@ -313,6 +315,7 @@ impl BinOp { BinOp::Gt => hir::BinOpKind::Gt, BinOp::Le => hir::BinOpKind::Le, BinOp::Ge => hir::BinOpKind::Ge, + // We don't have HIR syntax for these. BinOp::Cmp | BinOp::AddUnchecked | BinOp::SubUnchecked