]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/vec-shrink-panic.rs
Merge commit 'b71f3405606d49b9735606b479c3415a0ca9810f' into clippyup
[rust.git] / src / test / codegen / vec-shrink-panic.rs
1 // compile-flags: -O
2 // ignore-debug: the debug assertions get in the way
3 #![crate_type = "lib"]
4 #![feature(shrink_to)]
5
6 // Make sure that `Vec::shrink_to_fit` never emits panics via `RawVec::shrink_to_fit`,
7 // "Tried to shrink to a larger capacity", because the length is *always* <= capacity.
8
9 // CHECK-LABEL: @shrink_to_fit
10 #[no_mangle]
11 pub fn shrink_to_fit(vec: &mut Vec<u32>) {
12     // CHECK-NOT: panic
13     vec.shrink_to_fit();
14 }
15
16 // CHECK-LABEL: @issue71861
17 #[no_mangle]
18 pub fn issue71861(vec: Vec<u32>) -> Box<[u32]> {
19     // CHECK-NOT: panic
20     vec.into_boxed_slice()
21 }
22
23 // CHECK-LABEL: @issue75636
24 #[no_mangle]
25 pub fn issue75636<'a>(iter: &[&'a str]) -> Box<[&'a str]> {
26     // CHECK-NOT: panic
27     iter.iter().copied().collect()
28 }