rust/tests/codegen/issues/issue-15953.rs
Josh Triplett a105cd6066 Use field init shorthand where possible
Field init shorthand allows writing initializers like `tcx: tcx` as
`tcx`. The compiler already uses it extensively. Fix the last few places
where it isn't yet used.
2024-12-17 14:33:10 -08:00

30 lines
489 B
Rust

// Test that llvm generates `memcpy` for moving a value
// inside a function and moving an argument.
struct Foo {
x: Vec<i32>,
}
#[inline(never)]
#[no_mangle]
// CHECK: memcpy
fn interior(x: Vec<i32>) -> Vec<i32> {
let Foo { x } = Foo { x };
x
}
#[inline(never)]
#[no_mangle]
// CHECK: memcpy
fn exterior(x: Vec<i32>) -> Vec<i32> {
x
}
fn main() {
let x = interior(Vec::new());
println!("{:?}", x);
let x = exterior(Vec::new());
println!("{:?}", x);
}