Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 899d9b9

Browse files
committed
Fix test checking that into_boxed_slice does not panic
The memory allocation in vec might panic in the case of capacity overflow. Move the allocation outside the function to fix the test.
1 parent 77180db commit 899d9b9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/test/codegen/vec-shrink-panic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ pub fn shrink_to_fit(vec: &mut Vec<u32>) {
1515

1616
// CHECK-LABEL: @issue71861
1717
#[no_mangle]
18-
pub fn issue71861(n: usize) -> Box<[u32]> {
18+
pub fn issue71861(vec: Vec<u32>) -> Box<[u32]> {
1919
// CHECK-NOT: panic
20-
vec![0; n].into_boxed_slice()
20+
vec.into_boxed_slice()
2121
}
2222

2323
// CHECK-LABEL: @issue75636

0 commit comments

Comments
 (0)