Skip to content

Commit ddd07e8

Browse files
committed
Trim width-duplicate harnesses to tighten the diff
Drop six per-width variants whose proofs are identical modulo the type token, keeping one representative each: from_raw keeps u32, assume_init keeps u32, write keeps u32, new_uninit_slice keeps u8 (the widest layout-valid length domain), from_slice keeps u32. The ThinBox new/deref pair keeps both u8 and u64 since align-1 and align-8 exercise different header-offset arithmetic. Every function keeps at least one harness; coverage is unchanged.
1 parent ebe118c commit ddd07e8

2 files changed

Lines changed: 1 addition & 77 deletions

File tree

‎library/alloc/src/boxed.rs‎

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,15 +2447,6 @@ mod verify {
24472447

24482448
use super::*;
24492449

2450-
#[kani::proof_for_contract(Box::<u8>::from_raw)]
2451-
fn check_pfc_from_raw_u8() {
2452-
let v: u8 = kani::any();
2453-
let raw = Box::into_raw(Box::new(v));
2454-
kani::cover(true, "non-vacuity witness: the assumed input space is non-empty");
2455-
let back = unsafe { Box::from_raw(raw) };
2456-
assert_eq!(*back, v);
2457-
}
2458-
24592450
#[kani::proof_for_contract(Box::<u32>::from_raw)]
24602451
fn check_pfc_from_raw_u32() {
24612452
let v: u32 = kani::any();
@@ -2465,15 +2456,6 @@ mod verify {
24652456
assert_eq!(*back, v);
24662457
}
24672458

2468-
#[kani::proof_for_contract(Box::<u64>::from_raw)]
2469-
fn check_pfc_from_raw_u64() {
2470-
let v: u64 = kani::any();
2471-
let raw = Box::into_raw(Box::new(v));
2472-
kani::cover(true, "non-vacuity witness: the assumed input space is non-empty");
2473-
let back = unsafe { Box::from_raw(raw) };
2474-
assert_eq!(*back, v);
2475-
}
2476-
24772459
#[kani::proof_for_contract(Box::<u32>::from_non_null)]
24782460
fn check_pfc_from_non_null_u32() {
24792461
let v: u32 = kani::any();
@@ -2545,24 +2527,6 @@ mod verify {
25452527
assert!(core::ptr::addr_eq(&raw const *init, addr));
25462528
}
25472529

2548-
// The `proof_for_contract` target is spelled with the impl's own generic
2549-
// parameters (`MaybeUninit<T>`, `A`) — concrete turbofish arguments do not
2550-
// resolve against this impl's structured self-type at this kani version.
2551-
// The constructed space is every possible u64 value (v is symbolic) in a
2552-
// fresh Global allocation — the documented precondition (an initialized
2553-
// box) admits nothing else; the allocation address is abstracted by Kani.
2554-
#[kani::proof_for_contract(Box::<core::mem::MaybeUninit<T>, A>::assume_init)]
2555-
fn check_assume_init_u64() {
2556-
let v: u64 = kani::any();
2557-
let mut u: Box<core::mem::MaybeUninit<u64>> = Box::new_uninit();
2558-
u.write(v);
2559-
let addr = &raw const *u;
2560-
kani::cover(true, "non-vacuity witness: the assumed input space is non-empty");
2561-
let init: Box<u64> = unsafe { u.assume_init() };
2562-
assert_eq!(*init, v);
2563-
assert!(core::ptr::addr_eq(&raw const *init, addr));
2564-
}
2565-
25662530
// The `proof_for_contract` target is spelled with the impl's own generic
25672531
// parameters (`MaybeUninit<T>`, `A`) — concrete turbofish arguments do not
25682532
// resolve against this impl's structured self-type at this kani version.
@@ -2666,16 +2630,6 @@ mod verify {
26662630
assert!(core::ptr::addr_eq(s.as_ptr(), addr));
26672631
}
26682632

2669-
#[kani::proof]
2670-
fn check_new_uninit_slice_u32() {
2671-
let n = symbolic_len::<u32>();
2672-
kani::cover(true, "non-vacuity witness: the assumed input space is non-empty");
2673-
kani::cover(n == 0, "zero-length slice constructed");
2674-
kani::cover(n > 0, "non-empty slice constructed");
2675-
let b: Box<[core::mem::MaybeUninit<u32>]> = Box::new_uninit_slice(n);
2676-
assert_eq!(b.len(), n);
2677-
}
2678-
26792633
#[kani::proof]
26802634
fn check_new_zeroed_slice_u8() {
26812635
let n = symbolic_len::<u8>();
@@ -2856,17 +2810,6 @@ mod verify {
28562810
assert!(core::ptr::addr_eq(&raw const *b, addr));
28572811
}
28582812

2859-
#[kani::proof]
2860-
fn check_write_u64() {
2861-
let v: u64 = kani::any();
2862-
let u: Box<core::mem::MaybeUninit<u64>> = Box::new_uninit();
2863-
let addr = &raw const *u;
2864-
kani::cover(true, "non-vacuity witness: the assumed input space is non-empty");
2865-
let b = Box::write(u, v);
2866-
assert_eq!(*b, v);
2867-
assert!(core::ptr::addr_eq(&raw const *b, addr));
2868-
}
2869-
28702813
#[kani::proof]
28712814
fn check_into_non_null_u32() {
28722815
let v: u32 = kani::any();

‎library/alloc/src/boxed/convert.rs‎

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -831,25 +831,6 @@ mod verify {
831831
assert!(core::ptr::addr_eq(&raw const *d, addr));
832832
}
833833

834-
#[kani::proof]
835-
fn check_from_slice_u8() {
836-
let arr: [u8; 8] = kani::any();
837-
// n <= 8 mirrors the fixed 8-element source array, not a tractability cap.
838-
let n = kani::any_where(|n: &usize| *n <= 8);
839-
kani::cover(true, "non-vacuity witness: the assumed input space is non-empty");
840-
kani::cover(n == 0, "empty slice");
841-
kani::cover(n > 0, "non-empty slice");
842-
let b: Box<[u8]> = Box::from(&arr[..n]);
843-
assert_eq!(b.len(), n);
844-
// A whole-slice `assert_eq!` compiles to a memcmp-style comparison that
845-
// CBMC unwinds far past this n<=8 bound; a symbolic-index single read
846-
// gives the same per-element guarantee without the unbounded unwind.
847-
if n > 0 {
848-
let i: usize = kani::any_where(|i: &usize| *i < n);
849-
assert_eq!(b[i], arr[i]);
850-
}
851-
}
852-
853834
#[kani::proof]
854835
fn check_from_slice_u32() {
855836
let arr: [u32; 8] = kani::any();
@@ -895,7 +876,7 @@ mod verify {
895876
let bytes: Box<[u8]> = Box::from(b);
896877
assert_eq!(bytes.len(), n);
897878
assert!(core::ptr::addr_eq(&raw const *bytes as *const u8, addr));
898-
// Symbolic-index single-byte read (see check_from_slice_u8) stands in
879+
// Symbolic-index single-byte read (see check_from_slice_u32) stands in
899880
// for a whole-slice equality assert. `bytes` is the end of the
900881
// from(&str)->from(Box<str>) pipeline, so comparing it directly to the
901882
// original source covers both conversions transitively.

0 commit comments

Comments
 (0)