diff options
Diffstat (limited to 'compiler/rustc_middle/src/mir/tcx.rs')
| -rw-r--r-- | compiler/rustc_middle/src/mir/tcx.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index e1ae2e08666..56aba3c04ed 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -297,9 +297,9 @@ impl BorrowKind { impl BinOp { pub fn to_hir_binop(self) -> hir::BinOpKind { match self { - BinOp::Add => hir::BinOpKind::Add, - BinOp::Sub => hir::BinOpKind::Sub, - BinOp::Mul => hir::BinOpKind::Mul, + BinOp::Add | BinOp::AddWithOverflow => hir::BinOpKind::Add, + BinOp::Sub | BinOp::SubWithOverflow => hir::BinOpKind::Sub, + BinOp::Mul | BinOp::MulWithOverflow => hir::BinOpKind::Mul, BinOp::Div => hir::BinOpKind::Div, BinOp::Rem => hir::BinOpKind::Rem, BinOp::BitXor => hir::BinOpKind::BitXor, @@ -314,9 +314,6 @@ impl BinOp { BinOp::Le => hir::BinOpKind::Le, BinOp::Ge => hir::BinOpKind::Ge, BinOp::Cmp - | BinOp::AddWithOverflow - | BinOp::SubWithOverflow - | BinOp::MulWithOverflow | BinOp::AddUnchecked | BinOp::SubUnchecked | BinOp::MulUnchecked @@ -338,6 +335,11 @@ impl BinOp { }) } + /// Returns whether this is a `FooWithOverflow` + pub fn is_overflowing(self) -> bool { + self.overflowing_to_wrapping().is_some() + } + /// If this is a `Foo`, return `Some(FooWithOverflow)`. pub fn wrapping_to_overflowing(self) -> Option<BinOp> { Some(match self { |
