summaryrefslogtreecommitdiffstats
path: root/tests/ui/issues/issue-11004.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/issues/issue-11004.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/issues/issue-11004.rs')
-rw-r--r--tests/ui/issues/issue-11004.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/issues/issue-11004.rs b/tests/ui/issues/issue-11004.rs
new file mode 100644
index 000000000..10ef1f5e3
--- /dev/null
+++ b/tests/ui/issues/issue-11004.rs
@@ -0,0 +1,27 @@
+use std::mem;
+
+struct A { x: i32, y: f64 }
+
+#[cfg(not(works))]
+unsafe fn access(n:*mut A) -> (i32, f64) {
+ let x : i32 = n.x; //~ no field `x` on type `*mut A`
+ let y : f64 = n.y; //~ no field `y` on type `*mut A`
+ (x, y)
+}
+
+#[cfg(works)]
+unsafe fn access(n:*mut A) -> (i32, f64) {
+ let x : i32 = (*n).x;
+ let y : f64 = (*n).y;
+ (x, y)
+}
+
+fn main() {
+ let a : A = A { x: 3, y: 3.14 };
+ let p : &A = &a;
+ let (x,y) = unsafe {
+ let n : *mut A = mem::transmute(p);
+ access(n)
+ };
+ println!("x: {}, y: {}", x, y);
+}