Skip to content

Commit 1c9c2b1

Browse files
committed
Make verify_into_array actually exercise Box::into_array
The previous body called b.try_into(), which goes through the TryFrom<Box<[T]>> for Box<[T;N]> impl (which uses boxed_slice_as_array_unchecked, not into_array). The TryFrom path is already covered separately by verify_try_from_slice_to_array. Now the harness calls b.into_array() directly and asserts on the recovered array contents, providing direct coverage of the Box::<[T]>::into_array spec function (Challenge 29).
1 parent 9eeed4c commit 1c9c2b1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

library/alloc/src/boxed.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,8 +2305,10 @@ mod verify {
23052305
#[kani::proof]
23062306
fn verify_into_array() {
23072307
let b: Box<[i32]> = Box::from([1, 2, 3]);
2308-
let r: Result<Box<[i32; 3]>, _> = b.try_into();
2309-
assert!(r.is_ok());
2308+
let opt: Option<Box<[i32; 3]>> = b.into_array();
2309+
assert!(opt.is_some());
2310+
let arr = opt.unwrap();
2311+
assert!(arr[0] == 1 && arr[1] == 2 && arr[2] == 3);
23102312
}
23112313

23122314
#[kani::proof]

0 commit comments

Comments
 (0)