summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/building/custom/references.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/mir-opt/building/custom/references.rs
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/building/custom/references.rs')
-rw-r--r--tests/mir-opt/building/custom/references.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/mir-opt/building/custom/references.rs b/tests/mir-opt/building/custom/references.rs
index a1c896de0..f87f6664c 100644
--- a/tests/mir-opt/building/custom/references.rs
+++ b/tests/mir-opt/building/custom/references.rs
@@ -45,11 +45,22 @@ pub fn raw_pointer(x: *const i32) -> *const i32 {
})
}
+// EMIT_MIR references.raw_pointer_offset.built.after.mir
+#[custom_mir(dialect = "built")]
+pub fn raw_pointer_offset(x: *const i32) -> *const i32 {
+ mir!({
+ RET = Offset(x, 1_isize);
+ Return()
+ })
+}
+
fn main() {
let mut x = 5;
+ let arr = [1, 2];
assert_eq!(*mut_ref(&mut x), 5);
assert_eq!(*immut_ref(&x), 5);
unsafe {
assert_eq!(*raw_pointer(addr_of!(x)), 5);
+ assert_eq!(*raw_pointer_offset(addr_of!(arr[0])), 2);
}
}