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

@@ -155,7 +155,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
/// Whether Assert(OverflowNeg) and Assert(Overflow) MIR terminators should actually
/// check for overflow.
fn ignore_checkable_overflow_assertions(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool;
fn ignore_optional_overflow_checks(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool;
/// Entry point for obtaining the MIR of anything that should get evaluated.
/// So not just functions and shims, but also const/static initializers, anonymous
@@ -474,7 +474,7 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
}
#[inline(always)]
fn ignore_checkable_overflow_assertions(_ecx: &InterpCx<$mir, $tcx, Self>) -> bool {
fn ignore_optional_overflow_checks(_ecx: &InterpCx<$mir, $tcx, Self>) -> bool {
false
}