summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/copy-prop/move_projection.rs
blob: c158c69e0cf8bd2b40b347ee2d2fc1289b86fca1 (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
30
31
32
33
34
35
// ignore-wasm32 compiled with panic=abort by default
// unit-test: CopyProp

#![feature(custom_mir, core_intrinsics)]
#![allow(unused_assignments)]
extern crate core;
use core::intrinsics::mir::*;

fn opaque(_: impl Sized) -> bool { true }

struct Foo(u8);

#[custom_mir(dialect = "analysis", phase = "post-cleanup")]
fn f(a: Foo) -> bool {
    mir!(
        {
            let b = a;
            // This is a move out of a copy, so must become a copy of `a.0`.
            let c = Move(b.0);
            Call(RET, bb1, opaque(Move(a)))
        }
        bb1 = {
            Call(RET, ret, opaque(Move(c)))
        }
        ret = {
            Return()
        }
    )
}

fn main() {
    assert!(f(Foo(0)));
}

// EMIT_MIR move_projection.f.CopyProp.diff