6 use std::mem::transmute as my_transmute;
7 use std::vec::Vec as MyVec;
9 fn my_vec() -> MyVec<i32> {
13 #[allow(needless_lifetimes)]
14 #[deny(useless_transmute)]
15 unsafe fn _generic<'a, T, U: 'a>(t: &'a T) {
16 let _: &'a T = core::intrinsics::transmute(t);
17 //~^ ERROR transmute from a type (`&'a T`) to itself
19 let _: &'a U = core::intrinsics::transmute(t);
22 #[deny(useless_transmute)]
25 let _: Vec<i32> = core::intrinsics::transmute(my_vec());
26 //~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to itself
28 let _: Vec<i32> = core::mem::transmute(my_vec());
29 //~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to itself
31 let _: Vec<i32> = std::intrinsics::transmute(my_vec());
32 //~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to itself
34 let _: Vec<i32> = std::mem::transmute(my_vec());
35 //~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to itself
37 let _: Vec<i32> = my_transmute(my_vec());
38 //~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to itself
40 let _: Vec<u32> = core::intrinsics::transmute(my_vec());
41 let _: Vec<u32> = core::mem::transmute(my_vec());
42 let _: Vec<u32> = std::intrinsics::transmute(my_vec());
43 let _: Vec<u32> = std::mem::transmute(my_vec());
44 let _: Vec<u32> = my_transmute(my_vec());
48 #[deny(crosspointer_transmute)]
50 let mut vec: Vec<i32> = vec![];
51 let vec_const_ptr: *const Vec<i32> = &vec as *const Vec<i32>;
52 let vec_mut_ptr: *mut Vec<i32> = &mut vec as *mut Vec<i32>;
55 let _: Vec<i32> = core::intrinsics::transmute(vec_const_ptr);
56 //~^ ERROR transmute from a type (`*const collections::vec::Vec<i32>`) to the type that it points to (`collections::vec::Vec<i32>`)
58 let _: Vec<i32> = core::intrinsics::transmute(vec_mut_ptr);
59 //~^ ERROR transmute from a type (`*mut collections::vec::Vec<i32>`) to the type that it points to (`collections::vec::Vec<i32>`)
61 let _: *const Vec<i32> = core::intrinsics::transmute(my_vec());
62 //~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to a pointer to that type (`*const collections::vec::Vec<i32>`)
64 let _: *mut Vec<i32> = core::intrinsics::transmute(my_vec());
65 //~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to a pointer to that type (`*mut collections::vec::Vec<i32>`)