summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/copy-prop/move_projection.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/copy-prop/move_projection.rs')
-rw-r--r--tests/mir-opt/copy-prop/move_projection.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs
new file mode 100644
index 000000000..2a1bbae99
--- /dev/null
+++ b/tests/mir-opt/copy-prop/move_projection.rs
@@ -0,0 +1,34 @@
+// 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