Tweak implementation of overflow checking assertions

Extract and reuse logic controlling behaviour of overflow checking
assertions instead of duplicating it three times.
This commit is contained in:
Tomasz Miąsko 2023-03-16 00:00:00 +00:00
parent e386217dd9
commit 27b430bcb3
7 changed files with 19 additions and 41 deletions

View file

@ -646,8 +646,7 @@ pub enum TerminatorKind<'tcx> {
/// When overflow checking is disabled and this is run-time MIR (as opposed to compile-time MIR
/// that is used for CTFE), the following variants of this terminator behave as `goto target`:
/// - `OverflowNeg(..)`,
/// - `Overflow(op, ..)` if op is a "checkable" operation (add, sub, mul, shl, shr, but NOT
/// div or rem).
/// - `Overflow(op, ..)` if op is add, sub, mul, shl, shr, but NOT div or rem.
Assert {
cond: Operand<'tcx>,
expected: bool,