1 #![allow(clippy::let_unit_value)]
4 let x: [i32; 3] = [1_i32, 2, 3];
6 // Check casting through multiple bindings
7 // Because it's separate, it does not check the cast back to something of the same size
8 let a = r_x as *const [i32];
9 let b = a as *const [u8];
10 let c = b as *const [u32];
13 let loss = r_x as *const [i32] as *const [u8];
15 // Cast back to same size but different type loses no data, just type conversion
16 // This is weird code but there's no reason for this lint specifically to fire *twice* on it
17 let restore = r_x as *const [i32] as *const [u8] as *const [u32];
19 // Check casting through blocks is detected
20 let loss_block_1 = { r_x as *const [i32] } as *const [u8];
26 // Check that resores of the same size are detected through blocks
27 let restore_block_1 = { r_x as *const [i32] } as *const [u8] as *const [u32];
28 let restore_block_2 = { ({ r_x as *const [i32] }) as *const [u8] } as *const [u32];
29 let restore_block_3 = {
37 // Check that the result of a long chain of casts is detected
38 let long_chain_loss = r_x as *const [i32] as *const [u32] as *const [u16] as *const [i8] as *const [u8];
39 let long_chain_restore =
40 r_x as *const [i32] as *const [u32] as *const [u16] as *const [i8] as *const [u8] as *const [u32];