]> git.proxmox.com Git - rustc.git/blob - src/libcore/tests/manually_drop.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / libcore / tests / manually_drop.rs
1 use core::mem::ManuallyDrop;
2
3 #[test]
4 fn smoke() {
5 struct TypeWithDrop;
6 impl Drop for TypeWithDrop {
7 fn drop(&mut self) {
8 unreachable!("Should not get dropped");
9 }
10 }
11
12 let x = ManuallyDrop::new(TypeWithDrop);
13 drop(x);
14
15 // also test unsizing
16 let x: Box<ManuallyDrop<[TypeWithDrop]>> =
17 Box::new(ManuallyDrop::new([TypeWithDrop, TypeWithDrop]));
18 drop(x);
19 }