]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/copy-prop/move_projection.rs
Rollup merge of #107700 - jyn514:tools-builder, r=Mark-Simulacrum
[rust.git] / tests / mir-opt / copy-prop / move_projection.rs
1 // unit-test: CopyProp
2
3 #![feature(custom_mir, core_intrinsics)]
4 #![allow(unused_assignments)]
5 extern crate core;
6 use core::intrinsics::mir::*;
7
8 fn opaque(_: impl Sized) -> bool { true }
9
10 struct Foo(u8);
11
12 #[custom_mir(dialect = "analysis", phase = "post-cleanup")]
13 fn f(a: Foo) -> bool {
14     mir!(
15         {
16             let b = a;
17             // This is a move out of a copy, so must become a copy of `a.0`.
18             let c = Move(b.0);
19             Call(RET, bb1, opaque(Move(a)))
20         }
21         bb1 = {
22             Call(RET, ret, opaque(Move(c)))
23         }
24         ret = {
25             Return()
26         }
27     )
28 }
29
30 fn main() {
31     assert!(f(Foo(0)));
32 }
33
34 // EMIT_MIR move_projection.f.CopyProp.diff