Skip to content

Commit ae678de

Browse files
committed
added limits to multiplication proofs, reduced duplicacy in code by using macros to generate proof harnesses
1 parent 864afa6 commit ae678de

File tree

3 files changed

+103
-315
lines changed

3 files changed

+103
-315
lines changed

library/core/src/num/int_macros.rs

-3
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ macro_rules! int_impl {
512512
#[inline(always)]
513513
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
514514
#[requires(!self.overflowing_add(rhs).1)]
515-
#[ensures(|ret| *ret >= $SelfT::MIN && *ret <= $SelfT::MAX)]
516515
pub const unsafe fn unchecked_add(self, rhs: Self) -> Self {
517516
assert_unsafe_precondition!(
518517
check_language_ub,
@@ -818,7 +817,6 @@ macro_rules! int_impl {
818817
#[inline(always)]
819818
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
820819
#[requires(!self.overflowing_mul(rhs).1)]
821-
#[ensures(|ret| *ret >= $SelfT::MIN && *ret <= $SelfT::MAX)]
822820
pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self {
823821
assert_unsafe_precondition!(
824822
check_language_ub,
@@ -1428,7 +1426,6 @@ macro_rules! int_impl {
14281426
#[inline(always)]
14291427
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
14301428
#[requires(rhs < <$ActualT>::BITS)] // i.e. requires the right hand side of the shift (rhs) to be less than the number of bits in the type. This prevents undefined behavior.
1431-
#[ensures(|ret| *ret >= $SelfT::MIN && *ret <= $SelfT::MAX)] // ensures result is within range after bit shift
14321429
pub const unsafe fn unchecked_shr(self, rhs: u32) -> Self {
14331430
assert_unsafe_precondition!(
14341431
check_language_ub,

0 commit comments

Comments
 (0)