about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorUrgau <urgau@numericable.fr>2024-05-05 19:14:20 +0200
committerUrgau <urgau@numericable.fr>2024-05-05 19:14:20 +0200
commitcd6a0c8c77575056f95d79ae1f5c460794e1388f (patch)
tree38d84a143a8b19d55aefc0aa932650a78c288765 /tests
parent02f7806ecd641d67c8f046b073323c7e176ee6d2 (diff)
downloadrust-cd6a0c8c77575056f95d79ae1f5c460794e1388f.tar.gz
rust-cd6a0c8c77575056f95d79ae1f5c460794e1388f.zip
Fix insufficient logic when searching for the underlying allocation
in the `invalid_reference_casting` lint, when trying to lint on
bigger memory layout casts.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/lint/reference_casting.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/ui/lint/reference_casting.rs b/tests/ui/lint/reference_casting.rs
index d6897ab7b14..3d0c36ca118 100644
--- a/tests/ui/lint/reference_casting.rs
+++ b/tests/ui/lint/reference_casting.rs
@@ -247,6 +247,14 @@ unsafe fn bigger_layout() {
     unsafe fn from_ref(this: &i32) -> &i64 {
         &*(this as *const i32 as *const i64)
     }
+
+    // https://github.com/rust-lang/rust/issues/124685
+    unsafe fn slice_index(array: &mut [u8], offset: usize) {
+        let a1 = &mut array[offset];
+        let a2 = a1 as *mut u8;
+        let a3 = a2 as *mut u64;
+        unsafe { *a3 = 3 };
+    }
 }
 
 const RAW_PTR: *mut u8 = 1 as *mut u8;