Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contracts and Harnesses for core::ptr::byte_offset_from #186

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Runs rust format on the file
  • Loading branch information
stogaru committed Nov 28, 2024
commit 6aacbb852d05e649b1a0171c1a99875b882f08a9
10 changes: 5 additions & 5 deletions library/core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ mod verify {
check_const_offset_from_tuple_4_arr
);

// Proof for contact of byte_offset_from to verify unit type
// Proof for contact of byte_offset_from to verify unit type
#[kani::proof_for_contract(<*const ()>::byte_offset_from)]
pub fn check_const_byte_offset_from_unit() {
let val: () = ();
Expand All @@ -2081,7 +2081,7 @@ mod verify {
}
}

// generate proofs for contracts for byte_offset_from to verify int and composite
// generate proofs for contracts for byte_offset_from to verify int and composite
// types
// - `$type`: pointee type
// - `$proof_name1`: name of the harness for single element
Expand Down Expand Up @@ -2222,7 +2222,8 @@ mod verify {
const gen_size: usize = mem::size_of::<$type>();
let mut generator1 = PointerGenerator::<{ gen_size * ARRAY_LEN }>::new();
let mut generator2 = PointerGenerator::<{ gen_size * ARRAY_LEN }>::new();
let ptr1: *const [$type] = generator1.any_in_bounds().ptr as *const [$type; SLICE_LEN];
let ptr1: *const [$type] =
generator1.any_in_bounds().ptr as *const [$type; SLICE_LEN];
let ptr2: *const [$type] = if kani::any() {
generator1.any_alloc_status().ptr as *const [$type; SLICE_LEN]
} else {
Expand All @@ -2235,7 +2236,7 @@ mod verify {
}
};
}

generate_const_byte_offset_from_slice_harness!(u8, check_const_byte_offset_from_u8_slice);
generate_const_byte_offset_from_slice_harness!(u16, check_const_byte_offset_from_u16_slice);
generate_const_byte_offset_from_slice_harness!(u32, check_const_byte_offset_from_u32_slice);
Expand All @@ -2248,5 +2249,4 @@ mod verify {
generate_const_byte_offset_from_slice_harness!(i64, check_const_byte_offset_from_i64_slice);
generate_const_byte_offset_from_slice_harness!(i128, check_const_byte_offset_from_i128_slice);
generate_const_byte_offset_from_slice_harness!(isize, check_const_byte_offset_from_isize_slice);

}
4 changes: 2 additions & 2 deletions library/core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2389,7 +2389,7 @@ pub mod verify {
}
}

// generate proofs for contracts for byte_offset_from to verify int and composite
// generate proofs for contracts for byte_offset_from to verify int and composite
// types
// - `$type`: pointee type
// - `$proof_name1`: name of the harness for single element
Expand Down Expand Up @@ -2543,7 +2543,7 @@ pub mod verify {
}
};
}

generate_mut_byte_offset_from_slice_harness!(u8, check_mut_byte_offset_from_u8_slice);
generate_mut_byte_offset_from_slice_harness!(u16, check_mut_byte_offset_from_u16_slice);
generate_mut_byte_offset_from_slice_harness!(u32, check_mut_byte_offset_from_u32_slice);
Expand Down
Loading