summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/building/custom/projections.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/building/custom/projections.rs')
-rw-r--r--tests/mir-opt/building/custom/projections.rs25
1 files changed, 19 insertions, 6 deletions
diff --git a/tests/mir-opt/building/custom/projections.rs b/tests/mir-opt/building/custom/projections.rs
index 5e472e531..3c155deae 100644
--- a/tests/mir-opt/building/custom/projections.rs
+++ b/tests/mir-opt/building/custom/projections.rs
@@ -21,13 +21,10 @@ fn unions(u: U) -> i32 {
#[custom_mir(dialect = "analysis", phase = "post-cleanup")]
fn tuples(i: (u32, i32)) -> (u32, i32) {
mir!(
- // FIXME(JakobDegen): This is necessary because we can't give type hints for `RET`
- let temp: (u32, i32);
+ type RET = (u32, i32);
{
- temp.0 = i.0;
- temp.1 = i.1;
-
- RET = temp;
+ RET.0 = i.0;
+ RET.1 = i.1;
Return()
}
)
@@ -71,6 +68,19 @@ fn simple_index(a: [i32; 10], b: &[i32]) -> i32 {
})
}
+// EMIT_MIR projections.copy_for_deref.built.after.mir
+#[custom_mir(dialect = "runtime", phase = "initial")]
+fn copy_for_deref(x: (&i32, i32)) -> i32 {
+ mir!(
+ let temp: &i32;
+ {
+ temp = CopyForDeref(x.0);
+ RET = *temp;
+ Return()
+ }
+ )
+}
+
fn main() {
assert_eq!(unions(U { a: 5 }), 5);
assert_eq!(tuples((5, 6)), (5, 6));
@@ -82,4 +92,7 @@ fn main() {
assert_eq!(o, Some(10));
assert_eq!(simple_index([0; 10], &[0; 10]), 0);
+
+ let one = 1;
+ assert_eq!(copy_for_deref((&one, one)), 1);
}