]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/cast_slice_different_sizes.rs
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / cast_slice_different_sizes.rs
index 57270fcf52b52d9193f844c24ac6927f12075345..24d7eb28a197aa03b75fd663cbeda11339ee8c4a 100644 (file)
@@ -39,3 +39,44 @@ fn main() {
     let long_chain_restore =
         r_x as *const [i32] as *const [u32] as *const [u16] as *const [i8] as *const [u8] as *const [u32];
 }
+
+// foo and foo2 should not fire, they're the same size
+fn foo(x: *mut [u8]) -> *mut [u8] {
+    x as *mut [u8]
+}
+
+fn foo2(x: *mut [u8]) -> *mut [u8] {
+    x as *mut _
+}
+
+// Test that casts as part of function returns work
+fn bar(x: *mut [u16]) -> *mut [u8] {
+    x as *mut [u8]
+}
+
+fn uwu(x: *mut [u16]) -> *mut [u8] {
+    x as *mut _
+}
+
+fn bar2(x: *mut [u16]) -> *mut [u8] {
+    x as _
+}
+
+// constify
+fn bar3(x: *mut [u16]) -> *const [u8] {
+    x as _
+}
+
+// unconstify
+fn bar4(x: *const [u16]) -> *mut [u8] {
+    x as _
+}
+
+// function returns plus blocks
+fn blocks(x: *mut [u16]) -> *mut [u8] {
+    ({ x }) as _
+}
+
+fn more_blocks(x: *mut [u16]) -> *mut [u8] {
+    { ({ x }) as _ }
+}