summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/building/custom/simple_assign.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/building/custom/simple_assign.rs')
-rw-r--r--tests/mir-opt/building/custom/simple_assign.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/mir-opt/building/custom/simple_assign.rs b/tests/mir-opt/building/custom/simple_assign.rs
new file mode 100644
index 000000000..db041aab2
--- /dev/null
+++ b/tests/mir-opt/building/custom/simple_assign.rs
@@ -0,0 +1,39 @@
+#![feature(custom_mir, core_intrinsics)]
+
+extern crate core;
+use core::intrinsics::mir::*;
+
+// EMIT_MIR simple_assign.simple.built.after.mir
+#[custom_mir(dialect = "built")]
+pub fn simple(x: i32) -> i32 {
+ mir!(
+ let temp1: i32;
+ let temp2: _;
+
+ {
+ StorageLive(temp1);
+ temp1 = x;
+ Goto(exit)
+ }
+
+ exit = {
+ temp2 = Move(temp1);
+ StorageDead(temp1);
+ RET = temp2;
+ Return()
+ }
+ )
+}
+
+// EMIT_MIR simple_assign.simple_ref.built.after.mir
+#[custom_mir(dialect = "built")]
+pub fn simple_ref(x: &mut i32) -> &mut i32 {
+ mir!({
+ RET = Move(x);
+ Return()
+ })
+}
+
+fn main() {
+ assert_eq!(5, simple(5));
+}