]> git.lizzy.rs Git - rust.git/commitdiff
Fix test checking that into_boxed_slice does not panic
authorTomasz Miąsko <tomasz.miasko@gmail.com>
Thu, 12 Nov 2020 00:00:00 +0000 (00:00 +0000)
committerTomasz Miąsko <tomasz.miasko@gmail.com>
Thu, 12 Nov 2020 00:00:00 +0000 (00:00 +0000)
The memory allocation in vec might panic in the case of capacity
overflow. Move the allocation outside the function to fix the test.

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

index 690c7e6d6ced238373016f1bf0c2a72effdb9aab..cee4128c650401efcdef96d140938552b44a1e76 100644 (file)
@@ -15,9 +15,9 @@ pub fn shrink_to_fit(vec: &mut Vec<u32>) {
 
 // CHECK-LABEL: @issue71861
 #[no_mangle]
 
 // CHECK-LABEL: @issue71861
 #[no_mangle]
-pub fn issue71861(n: usize) -> Box<[u32]> {
+pub fn issue71861(vec: Vec<u32>) -> Box<[u32]> {
     // CHECK-NOT: panic
     // CHECK-NOT: panic
-    vec![0; n].into_boxed_slice()
+    vec.into_boxed_slice()
 }
 
 // CHECK-LABEL: @issue75636
 }
 
 // CHECK-LABEL: @issue75636