#![warn(clippy::transmute_undefined_repr)] #![allow(clippy::unit_arg)] fn value() -> T { unimplemented!() } struct Empty; struct Ty(T); struct Ty2(T, U); #[repr(C)] struct Ty2C(T, U); fn main() { unsafe { let _: () = core::mem::transmute(value::()); let _: Empty = core::mem::transmute(value::<()>()); let _: Ty = core::mem::transmute(value::()); let _: Ty = core::mem::transmute(value::()); let _: Ty2C = core::mem::transmute(value::>()); // Lint, Ty2 is unordered let _: Ty2 = core::mem::transmute(value::>()); // Lint, Ty2 is unordered let _: Ty2 = core::mem::transmute(value::>>()); // Ok, Ty2 types are the same let _: Ty> = core::mem::transmute(value::>()); // Ok, Ty2 types are the same let _: Ty2 = core::mem::transmute(value::>>()); // Lint, different Ty2 instances let _: Ty> = core::mem::transmute(value::>()); // Lint, different Ty2 instances let _: Ty<&()> = core::mem::transmute(value::<&()>()); let _: &() = core::mem::transmute(value::>()); let _: &Ty2 = core::mem::transmute(value::>>()); // Lint, different Ty2 instances let _: Ty<&Ty2> = core::mem::transmute(value::<&Ty2>()); // Lint, different Ty2 instances let _: Ty = core::mem::transmute(value::<&Ty2>()); // Ok, pointer to usize conversion let _: &Ty2 = core::mem::transmute(value::>()); // Ok, pointer to usize conversion let _: Ty<[u8; 8]> = core::mem::transmute(value::>()); // Ok, transmute to byte array let _: Ty2 = core::mem::transmute(value::>()); // Ok, transmute from byte array // issue #8417 let _: Ty2C, ()> = core::mem::transmute(value::>()); // Ok, Ty2 types are the same let _: Ty2 = core::mem::transmute(value::, ()>>()); // Ok, Ty2 types are the same } }