summaryrefslogtreecommitdiffstats
path: root/tests/codegen/issues/issue-15953.rs
blob: 28d28428904f525543c780f237803a52982b7e2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 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 };
    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);
}