Skip to content

Commit 2be7639

Browse files
authored
Merge pull request #8 from stogaru/verify/ptr_mut_unit_types
Added unit type proofs for mut ptr
2 parents ce13e8f + dec8c30 commit 2be7639

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

library/core/src/ptr/mut_ptr.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2218,5 +2218,31 @@ impl<T: ?Sized> PartialOrd for *mut T {
22182218
#[unstable(feature = "kani", issue = "none")]
22192219
mod verify {
22202220
use crate::kani;
2221-
2221+
macro_rules! generate_unit_harness {
2222+
($fn_name:ident, $proof_name:ident) => {
2223+
#[allow(unused)]
2224+
#[kani::proof_for_contract(<*mut ()>::$fn_name)]
2225+
pub fn $proof_name() {
2226+
let mut test_val: () = ();
2227+
let test_ptr: *mut () = &mut test_val;
2228+
let count: usize = kani::any();
2229+
unsafe {
2230+
test_ptr.$fn_name(count);
2231+
}
2232+
}
2233+
};
2234+
}
2235+
generate_unit_harness!(add, check_mut_add_unit);
2236+
generate_unit_harness!(sub, check_mut_sub_unit);
2237+
2238+
#[allow(unused)]
2239+
#[kani::proof_for_contract(<*mut ()>::offset)]
2240+
pub fn check_mut_offset_unit() {
2241+
let mut test_val: () = ();
2242+
let test_ptr: *mut () = &mut test_val;
2243+
let count: isize = kani::any();
2244+
unsafe {
2245+
test_ptr.offset(count);
2246+
}
2247+
}
22222248
}

0 commit comments

Comments
 (0)