use std::mem; unsafe fn foo() -> (i8, *const (), Option) { let i = mem::transmute(bar); //~^ ERROR cannot transmute between types of different sizes, or dependently-sized types let p = mem::transmute(foo); //~^ ERROR can't transmute zero-sized type let of = mem::transmute(main); //~^ ERROR can't transmute zero-sized type (i, p, of) } unsafe fn bar() { // Error as usual if the resulting type is not pointer-sized. mem::transmute::<_, u8>(main); //~^ ERROR cannot transmute between types of different sizes, or dependently-sized types mem::transmute::<_, *mut ()>(foo); //~^ ERROR can't transmute zero-sized type mem::transmute::<_, fn()>(bar); //~^ ERROR can't transmute zero-sized type // No error if a coercion would otherwise occur. mem::transmute::(main); } unsafe fn baz() { mem::transmute::<_, *mut ()>(Some(foo)); //~^ ERROR can't transmute zero-sized type mem::transmute::<_, fn()>(Some(bar)); //~^ ERROR can't transmute zero-sized type mem::transmute::<_, Option>(Some(baz)); //~^ ERROR can't transmute zero-sized type // No error if a coercion would otherwise occur. mem::transmute::, usize>(Some(main)); } fn main() { unsafe { foo(); bar(); baz(); } }