Skip to content

Commit

Permalink
Update non_null.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhvani-Kapadia authored Nov 16, 2024
1 parent 5f0538c commit f898e60
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions library/core/src/ptr/non_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1823,14 +1823,13 @@ mod verify {
}
#[kani::proof_for_contract(NonNull::<[T]>::as_mut_ptr)]
pub fn non_null_check_as_mut_ptr() {
// Create a non-null slice pointer
const ARR_LEN: usize = 100;
let mut generator = kani::PointerGenerator::<ARR_LEN>::new();
let mut values: [i32; ARR_LEN] = [0; ARR_LEN];
let raw_ptr: *mut i32 = generator.any_in_bounds().ptr;
if let Some(ptr) = NonNull::new(raw_ptr){
let slice_ptr = NonNull::slice_from_raw_parts(ptr, values.len());
// Call as_mut_ptr
let alloc_status = generator.any_alloc_status();
let raw_ptr: *mut i32 = alloc_status.ptr as *mut i32;
let values: [i32; ARR_LEN] = kani::any();
if let Some(non_null_ptr) = NonNull::new(raw_ptr) {
let slice_ptr = NonNull::slice_from_raw_parts(non_null_ptr, values.len());
let raw_ptr = slice_ptr.as_mut_ptr();
}}
#[kani::proof_for_contract(NonNull::<T>::cast)]
Expand All @@ -1845,8 +1844,9 @@ mod verify {
pub fn non_null_check_as_non_null_ptr() {
const ARR_LEN: usize = 100;
let mut generator = kani::PointerGenerator::<ARR_LEN>::new();
let alloc_status = generator.any_alloc_status();
let raw_ptr: *mut i32 = alloc_status.ptr as *mut i32;
let mut values: [i32; ARR_LEN] = [0; ARR_LEN];
let raw_ptr: *mut i32 = generator.any_in_bounds().ptr;
if let Some(ptr) = NonNull::new(raw_ptr){
let slice_ptr = NonNull::slice_from_raw_parts(ptr, values.len());
let result = slice_ptr.as_non_null_ptr();
Expand Down

0 comments on commit f898e60

Please sign in to comment.