rust/tests/mir-opt/dest-prop/simple.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
661 B
Rust
Raw Normal View History

// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
2020-05-24 19:37:09 +00:00
//! Copy of `nrvo-simple.rs`, to ensure that full dest-prop handles it too.
//@ test-mir-pass: DestinationPropagation
2020-09-12 13:10:51 +00:00
// EMIT_MIR simple.nrvo.DestinationPropagation.diff
2020-05-24 19:37:09 +00:00
fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] {
2024-04-14 09:36:24 +00:00
// CHECK-LABEL: fn nrvo(
// CHECK: debug init => [[init:_.*]];
2024-06-26 17:39:37 +00:00
// CHECK: debug buf => [[buf:_.*]];
// CHECK: [[buf]] = [const 0_u8; 1024];
2024-08-18 22:51:53 +00:00
// CHECK-NOT: {{_.*}} = copy [[init]];
2024-04-14 09:36:24 +00:00
// CHECK: move [[init]](move {{_.*}})
2024-08-18 22:51:53 +00:00
// CHECK: {{_.*}} = copy [[buf]]
2020-05-24 19:37:09 +00:00
let mut buf = [0; 1024];
init(&mut buf);
buf
}
fn main() {
let _ = nrvo(|buf| {
buf[4] = 4;
});
}