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