Skip to content

Commit

Permalink
Disable check_grow_impl as we cannot currently express the necessary …
Browse files Browse the repository at this point in the history
…precondition
  • Loading branch information
tautschnig committed Oct 18, 2024
1 parent d28ca19 commit d640ef6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions library/alloc/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,17 @@ mod verify {
let _ = Global.alloc_impl(kani::any(), kani::any());
}

// unsafe fn grow_impl(&self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocError>
#[kani::proof_for_contract(Global::grow_impl)]
pub fn check_grow_impl() {
let raw_ptr = kani::any::<usize>() as *mut u8;
unsafe {
let n = NonNull::new_unchecked(raw_ptr);
let _ = Global.grow_impl(n, kani::any(), kani::any(), kani::any());
}
}
// TODO: Kani correctly detects that the precondition is too weak. We'd need a way to express
// that ptr either points to a ZST (we can do this), or else is heap-allocated (we cannot).
// // unsafe fn grow_impl(&self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocError>
// #[kani::proof_for_contract(Global::grow_impl)]
// pub fn check_grow_impl() {
// let raw_ptr = kani::any::<usize>() as *mut u8;
// unsafe {
// let n = NonNull::new_unchecked(raw_ptr);
// let _ = Global.grow_impl(n, kani::any(), kani::any(), kani::any());
// }
// }

// TODO: disabled as Kani does not currently support contracts on traits. See
// https://github.com/model-checking/kani/issues/1997
Expand Down

0 comments on commit d640ef6

Please sign in to comment.