Skip to content

Commit db3a197

Browse files
committed
Make Arc verification harnesses exercise their named functions
verify_into_array previously called a.try_into(), which goes through the TryFrom impl, not Arc::into_array. The TryFrom path is already covered by verify_try_from. Rewrite verify_into_array to call a.into_array() directly. Add verify_into_inner_with_allocator (none existed before): call Arc::into_inner_with_allocator(a) and reconstruct via from_inner_in (matching how the TryFrom impl uses the helper). Both functions are listed in the Challenge 27 (Arc) success criteria.
1 parent 24aff31 commit db3a197

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

library/alloc/src/sync.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4769,8 +4769,19 @@ mod verify {
47694769
#[kani::proof]
47704770
fn verify_into_array() {
47714771
let a: Arc<[i32]> = Arc::from([1, 2, 3]);
4772-
let r: Result<Arc<[i32; 3]>, _> = a.try_into();
4773-
assert!(r.is_ok());
4772+
let opt: Option<Arc<[i32; 3]>> = a.into_array();
4773+
assert!(opt.is_some());
4774+
let arr = opt.unwrap();
4775+
assert!(arr[0] == 1 && arr[1] == 2 && arr[2] == 3);
4776+
}
4777+
4778+
#[kani::proof]
4779+
fn verify_into_inner_with_allocator() {
4780+
let a = Arc::new_in(42i32, Global);
4781+
let (ptr, alloc) = Arc::into_inner_with_allocator(a);
4782+
// Reconstruct so the allocation is dropped correctly.
4783+
let a2 = unsafe { Arc::from_inner_in(ptr, alloc) };
4784+
assert!(*a2 == 42);
47744785
}
47754786

47764787
#[kani::proof]

0 commit comments

Comments
 (0)