summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/building/custom
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /tests/mir-opt/building/custom
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/building/custom')
-rw-r--r--tests/mir-opt/building/custom/projections.copy_for_deref.built.after.mir12
-rw-r--r--tests/mir-opt/building/custom/projections.rs25
-rw-r--r--tests/mir-opt/building/custom/projections.tuples.built.after.mir8
3 files changed, 34 insertions, 11 deletions
diff --git a/tests/mir-opt/building/custom/projections.copy_for_deref.built.after.mir b/tests/mir-opt/building/custom/projections.copy_for_deref.built.after.mir
new file mode 100644
index 000000000..5233d0489
--- /dev/null
+++ b/tests/mir-opt/building/custom/projections.copy_for_deref.built.after.mir
@@ -0,0 +1,12 @@
+// MIR for `copy_for_deref` after built
+
+fn copy_for_deref(_1: (&i32, i32)) -> i32 {
+ let mut _0: i32; // return place in scope 0 at $DIR/projections.rs:+0:38: +0:41
+ let mut _2: &i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ _2 = deref_copy (_1.0: &i32); // scope 0 at $DIR/projections.rs:+4:13: +4:37
+ _0 = (*_2); // scope 0 at $DIR/projections.rs:+5:13: +5:24
+ return; // scope 0 at $DIR/projections.rs:+6:13: +6:21
+ }
+}
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);
}
diff --git a/tests/mir-opt/building/custom/projections.tuples.built.after.mir b/tests/mir-opt/building/custom/projections.tuples.built.after.mir
index 65487d3c9..dec575200 100644
--- a/tests/mir-opt/building/custom/projections.tuples.built.after.mir
+++ b/tests/mir-opt/building/custom/projections.tuples.built.after.mir
@@ -2,12 +2,10 @@
fn tuples(_1: (u32, i32)) -> (u32, i32) {
let mut _0: (u32, i32); // return place in scope 0 at $DIR/projections.rs:+0:29: +0:39
- let mut _2: (u32, i32); // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
bb0: {
- (_2.0: u32) = (_1.0: u32); // scope 0 at $DIR/projections.rs:+5:13: +5:25
- (_2.1: i32) = (_1.1: i32); // scope 0 at $DIR/projections.rs:+6:13: +6:25
- _0 = _2; // scope 0 at $DIR/projections.rs:+8:13: +8:23
- return; // scope 0 at $DIR/projections.rs:+9:13: +9:21
+ (_0.0: u32) = (_1.0: u32); // scope 0 at $DIR/projections.rs:+4:13: +4:24
+ (_0.1: i32) = (_1.1: i32); // scope 0 at $DIR/projections.rs:+5:13: +5:24
+ return; // scope 0 at $DIR/projections.rs:+6:13: +6:21
}
}