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