Skip to content

Commit cb53194

Browse files
RalfJungscottmcm
andcommitted
clarify comment
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
1 parent c0b4b45 commit cb53194

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: compiler/rustc_const_eval/src/interpret/operator.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
324324
}
325325
}
326326

327-
/// Returns the result of the specified operation, and whether it overflowed.
327+
/// Returns the result of the specified operation.
328+
///
329+
/// Whether this produces a scalar or a pair depends on the specific `bin_op`.
328330
pub fn binary_op(
329331
&self,
330332
bin_op: mir::BinOp,

Diff for: compiler/rustc_middle/src/mir/tcx.rs

+3
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ impl BorrowKind {
297297
impl BinOp {
298298
pub fn to_hir_binop(self) -> hir::BinOpKind {
299299
match self {
300+
// HIR `+`/`-`/`*` can map to either of these MIR BinOp, depending
301+
// on whether overflow checks are enabled or not.
300302
BinOp::Add | BinOp::AddWithOverflow => hir::BinOpKind::Add,
301303
BinOp::Sub | BinOp::SubWithOverflow => hir::BinOpKind::Sub,
302304
BinOp::Mul | BinOp::MulWithOverflow => hir::BinOpKind::Mul,
@@ -313,6 +315,7 @@ impl BinOp {
313315
BinOp::Gt => hir::BinOpKind::Gt,
314316
BinOp::Le => hir::BinOpKind::Le,
315317
BinOp::Ge => hir::BinOpKind::Ge,
318+
// We don't have HIR syntax for these.
316319
BinOp::Cmp
317320
| BinOp::AddUnchecked
318321
| BinOp::SubUnchecked

0 commit comments

Comments
 (0)