1 //! Test casts for alignment issues
3 #![feature(rustc_private)]
6 #[warn(clippy::cast_ptr_alignment)]
7 #[allow(clippy::no_effect, clippy::unnecessary_operation, clippy::cast_lossless)]
9 /* These should be warned against */
11 // cast to more-strictly-aligned type
12 (&1u8 as *const u8) as *const u16;
13 (&mut 1u8 as *mut u8) as *mut u16;
15 /* These should be ok */
19 // cast to less-strictly-aligned type
20 (&1u16 as *const u16) as *const u8;
21 (&mut 1u16 as *mut u16) as *mut u8;
22 // For c_void, we should trust the user. See #2677
23 (&1u32 as *const u32 as *const std::os::raw::c_void) as *const u32;
24 (&1u32 as *const u32 as *const libc::c_void) as *const u32;
25 // For ZST, we should trust the user. See #4256
26 (&1u32 as *const u32 as *const ()) as *const u32;