1 #![feature(tool_lints)]
3 //! Test casts for alignment issues
9 #[warn(clippy::cast_ptr_alignment)]
10 #[allow(clippy::no_effect, clippy::unnecessary_operation, clippy::cast_lossless)]
12 /* These should be warned against */
14 // cast to more-strictly-aligned type
15 (&1u8 as *const u8) as *const u16;
16 (&mut 1u8 as *mut u8) as *mut u16;
18 /* These should be okay */
22 // cast to less-strictly-aligned type
23 (&1u16 as *const u16) as *const u8;
24 (&mut 1u16 as *mut u16) as *mut u8;
25 // For c_void, we should trust the user. See #2677
26 (&1u32 as *const u32 as *const std::os::raw::c_void) as *const u32;
27 (&1u32 as *const u32 as *const libc::c_void) as *const u32;