rust/tests/codegen/issue-97217.rs
Nicholas Nethercote 72800d3b89 Run rustfmt on tests/codegen/.
Except for `simd-intrinsic/`, which has a lot of files containing
multiple types like `u8x64` which really are better when hand-formatted.

There is a surprising amount of two-space indenting in this directory.

Non-trivial changes:
- `rustfmt::skip` needed in `debug-column.rs` to preserve meaning of the
  test.
- `rustfmt::skip` used in a few places where hand-formatting read more
  nicely: `enum/enum-match.rs`
- Line number adjustments needed for the expected output of
  `debug-column.rs` and `coroutine-debug.rs`.
2024-05-31 15:56:43 +10:00

22 lines
538 B
Rust

//@ compile-flags: -C opt-level=3
//@ min-llvm-version: 17.0.2
#![crate_type = "lib"]
// Regression test for issue 97217 (the following should result in no allocations)
// CHECK-LABEL: @issue97217
#[no_mangle]
pub fn issue97217() -> i32 {
// drop_in_place should be inlined and never appear
// CHECK-NOT: drop_in_place
// __rust_alloc should be optimized out
// CHECK-NOT: __rust_alloc
let v1 = vec![5, 6, 7];
let v1_iter = v1.iter();
let total: i32 = v1_iter.sum();
println!("{}", total);
total
}