about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-05-11 13:16:41 +0200
committerGitHub <noreply@github.com>2024-05-11 13:16:41 +0200
commit8eac6d2333a11bc84f04d0a7ada0efc08f763cfe (patch)
tree0a9479750225e8c710c1104087cf45841d54bae6 /tests
parent7d7a182c291d086249365e3690554a0c1a403ac5 (diff)
parent2bb25d3f4ac8796a50f45409f3ef461ce83295f3 (diff)
downloadrust-8eac6d2333a11bc84f04d0a7ada0efc08f763cfe.tar.gz
rust-8eac6d2333a11bc84f04d0a7ada0efc08f763cfe.zip
Rollup merge of #124978 - saethlin:ref-casting_derefs, r=Urgau,Nilstrieb
Handle Deref expressions in invalid_reference_casting

Similar to https://github.com/rust-lang/rust/pull/124908

See https://github.com/rust-lang/rust/issues/124951 for context; this PR fixes the last of the known false postiive cases with this lint that we encounter in Crater.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/lint/reference_casting.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/ui/lint/reference_casting.rs b/tests/ui/lint/reference_casting.rs
index 87a682249b0..87fa42f9477 100644
--- a/tests/ui/lint/reference_casting.rs
+++ b/tests/ui/lint/reference_casting.rs
@@ -261,6 +261,13 @@ unsafe fn bigger_layout() {
         let ptr = r as *mut i32 as *mut Vec3<i32>;
         unsafe { *ptr = Vec3(0, 0, 0) }
     }
+
+    unsafe fn deref(v: &mut Vec3<i32>) {
+        let r = &mut v.0;
+        let r = &mut *r;
+        let ptr = &mut *(r as *mut i32 as *mut Vec3<i32>);
+        unsafe { *ptr = Vec3(0, 0, 0) }
+    }
 }
 
 const RAW_PTR: *mut u8 = 1 as *mut u8;