Skip to content

Commit c975e16

Browse files
Add regression test for rust-lang#97217
Closes rust-lang#97217.
1 parent 4773fbc commit c975e16

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/codegen/issue-97217.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// compile-flags: -C opt-level=3
2+
// ignore-debug: the debug assertions get in the way
3+
#![crate_type = "lib"]
4+
5+
// Regression test for issue 97217 (the following should result in no allocations)
6+
7+
// CHECK-LABEL: @issue97217
8+
#[no_mangle]
9+
pub fn issue97217() -> i32 {
10+
// drop_in_place should be inlined and never appear
11+
// CHECK-NOT: drop_in_place
12+
13+
// __rust_alloc should be optimized out
14+
// CHECK-NOT: __rust_alloc
15+
16+
let v1 = vec![5, 6, 7];
17+
let v1_iter = v1.iter();
18+
let total: i32 = v1_iter.sum();
19+
println!("{}",total);
20+
total
21+
}

0 commit comments

Comments
 (0)