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