Skip to content

Commit

Permalink
clarify comment
Browse files Browse the repository at this point in the history
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
  • Loading branch information
RalfJung and scottmcm committed May 22, 2024
1 parent c0b4b45 commit cb53194
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_const_eval/src/interpret/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit cb53194

Please sign in to comment.