@@ -755,6 +755,8 @@ macro_rules! nonzero_integer {
755755 #[ must_use = "this returns the result of the operation, \
756756 without modifying the original"]
757757 #[ inline( always) ]
758+ #[ ensures( |result| result. get( ) > 0 ) ]
759+ #[ ensures( |result| result. rotate_right( n) . get( ) == old( self ) . get( ) ) ]
758760 pub const fn rotate_left( self , n: u32 ) -> Self {
759761 let result = self . get( ) . rotate_left( n) ;
760762 // SAFETY: Rotating bits preserves the property int > 0.
@@ -788,6 +790,8 @@ macro_rules! nonzero_integer {
788790 #[ must_use = "this returns the result of the operation, \
789791 without modifying the original"]
790792 #[ inline( always) ]
793+ #[ ensures( |result| result. get( ) > 0 ) ]
794+ #[ ensures( |result| result. rotate_left( n) . get( ) == old( self ) . get( ) ) ]
791795 pub const fn rotate_right( self , n: u32 ) -> Self {
792796 let result = self . get( ) . rotate_right( n) ;
793797 // SAFETY: Rotating bits preserves the property int > 0.
@@ -2572,30 +2576,4 @@ mod verify {
25722576 nonzero_check_clamp_panic ! ( core:: num:: NonZeroU64 , nonzero_check_clamp_panic_for_u64) ;
25732577 nonzero_check_clamp_panic ! ( core:: num:: NonZeroU128 , nonzero_check_clamp_panic_for_u128) ;
25742578 nonzero_check_clamp_panic ! ( core:: num:: NonZeroUsize , nonzero_check_clamp_panic_for_usize) ;
2575-
2576- macro_rules! nonzero_check_rotate_left_and_right {
2577- ( $nonzero_type: ty, $nonzero_check_rotate_for: ident) => {
2578- #[ kani:: proof]
2579- pub fn $nonzero_check_rotate_for( ) {
2580- let x: $nonzero_type = kani:: any( ) ;
2581- let n: u32 = kani:: any( ) ;
2582- let result = x. rotate_left( n) . rotate_right( n) ;
2583- assert!( result == x) ;
2584- }
2585- } ;
2586- }
2587-
2588- // Use the macro to generate different versions of the function for multiple types
2589- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroI8 , nonzero_check_rotate_for_i8) ;
2590- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroI16 , nonzero_check_rotate_for_i16) ;
2591- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroI32 , nonzero_check_rotate_for_i32) ;
2592- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroI64 , nonzero_check_rotate_for_i64) ;
2593- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroI128 , nonzero_check_rotate_for_i128) ;
2594- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroIsize , nonzero_check_rotate_for_isize) ;
2595- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroU8 , nonzero_check_rotate_for_u8) ;
2596- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroU16 , nonzero_check_rotate_for_u16) ;
2597- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroU32 , nonzero_check_rotate_for_u32) ;
2598- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroU64 , nonzero_check_rotate_for_u64) ;
2599- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroU128 , nonzero_check_rotate_for_u128) ;
2600- nonzero_check_rotate_left_and_right ! ( core:: num:: NonZeroUsize , nonzero_check_rotate_for_usize) ;
26012579}
0 commit comments