]> git.lizzy.rs Git - rust.git/blob - src/test/ui/union/union-manuallydrop-rpass.rs
Merge commit '61eb38aeda6cb54b93b872bf503d70084c4d621c' into clippyup
[rust.git] / src / test / ui / union / union-manuallydrop-rpass.rs
1 #![allow(dead_code)]
2 // run-pass
3
4 use std::mem::needs_drop;
5 use std::mem::ManuallyDrop;
6
7 struct NeedDrop;
8
9 impl Drop for NeedDrop {
10     fn drop(&mut self) {}
11 }
12
13 union UnionOk1<T> {
14     empty: (),
15     value: ManuallyDrop<T>,
16 }
17
18 union UnionOk2 {
19     value: ManuallyDrop<NeedDrop>,
20 }
21
22 #[allow(dead_code)]
23 union UnionOk3<T: Copy> {
24     empty: (),
25     value: T,
26 }
27
28 trait Foo { }
29
30 trait ImpliesCopy : Copy { }
31
32 #[allow(dead_code)]
33 union UnionOk4<T: ImpliesCopy> {
34     value: T,
35 }
36
37 fn main() {
38     // NeedDrop should not make needs_drop true
39     assert!(!needs_drop::<UnionOk1<NeedDrop>>());
40     assert!(!needs_drop::<UnionOk3<&dyn Foo>>());
41 }