]> git.lizzy.rs Git - rust.git/blob - src/libcore/tests/manually_drop.rs
Rollup merge of #68288 - RalfJung:fmt, r=oli-obk
[rust.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 }