#![warn(clippy::unsound_collection_transmute)] #![allow(clippy::missing_transmute_annotations)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; use std::mem::{MaybeUninit, transmute}; fn main() { unsafe { // wrong size let _ = transmute::<_, Vec>(vec![0u8]); //~^ ERROR: transmute from `std::vec::Vec` to `std::vec::Vec` with mismat //~| NOTE: `-D clippy::unsound-collection-transmute` implied by `-D warnings` // wrong layout let _ = transmute::<_, Vec<[u8; 4]>>(vec![1234u32]); //~^ ERROR: transmute from `std::vec::Vec` to `std::vec::Vec<[u8; 4]>` with m // wrong size let _ = transmute::<_, VecDeque>(VecDeque::::new()); //~^ ERROR: transmute from `std::collections::VecDeque` to `std::collections:: // wrong layout let _ = transmute::<_, VecDeque>(VecDeque::<[u8; 4]>::new()); //~^ ERROR: transmute from `std::collections::VecDeque<[u8; 4]>` to `std::collecti // wrong size let _ = transmute::<_, BinaryHeap>(BinaryHeap::::new()); //~^ ERROR: transmute from `std::collections::BinaryHeap` to `std::collections // wrong layout let _ = transmute::<_, BinaryHeap>(BinaryHeap::<[u8; 4]>::new()); //~^ ERROR: transmute from `std::collections::BinaryHeap<[u8; 4]>` to `std::collec // wrong size let _ = transmute::<_, BTreeSet>(BTreeSet::::new()); //~^ ERROR: transmute from `std::collections::BTreeSet` to `std::collections:: // wrong layout let _ = transmute::<_, BTreeSet>(BTreeSet::<[u8; 4]>::new()); //~^ ERROR: transmute from `std::collections::BTreeSet<[u8; 4]>` to `std::collecti // wrong size let _ = transmute::<_, HashSet>(HashSet::::new()); //~^ ERROR: transmute from `std::collections::HashSet` to `std::collections::H // wrong layout let _ = transmute::<_, HashSet>(HashSet::<[u8; 4]>::new()); //~^ ERROR: transmute from `std::collections::HashSet<[u8; 4]>` to `std::collectio // wrong size let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); //~^ ERROR: transmute from `std::collections::BTreeMap` to `std::collectio let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); //~^ ERROR: transmute from `std::collections::BTreeMap` to `std::collect // wrong layout let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); //~^ ERROR: transmute from `std::collections::BTreeMap` to `std::coll let _ = transmute::<_, BTreeMap>(BTreeMap::<[u8; 4], u32>::new()); //~^ ERROR: transmute from `std::collections::BTreeMap<[u8; 4], u32>` to `std::col // wrong size let _ = transmute::<_, HashMap>(HashMap::::new()); //~^ ERROR: transmute from `std::collections::HashMap` to `std::collection let _ = transmute::<_, HashMap>(HashMap::::new()); //~^ ERROR: transmute from `std::collections::HashMap` to `std::collecti // wrong layout let _ = transmute::<_, HashMap>(HashMap::::new()); //~^ ERROR: transmute from `std::collections::HashMap` to `std::colle let _ = transmute::<_, HashMap>(HashMap::<[u8; 4], u32>::new()); //~^ ERROR: transmute from `std::collections::HashMap<[u8; 4], u32>` to `std::coll let _ = transmute::<_, Vec>(Vec::>::new()); let _ = transmute::<_, Vec<*mut u32>>(Vec::>::new()); } }