]> git.lizzy.rs Git - rust.git/blob - src/test/ui/union/union-manuallydrop-rpass.rs
Rollup merge of #93385 - CraftSpider:rustdoc-ty-fixes, r=camelid
[rust.git] / src / test / ui / union / union-manuallydrop-rpass.rs
1 // run-pass
2 // revisions: mirunsafeck thirunsafeck
3 // [thirunsafeck]compile-flags: -Z thir-unsafeck
4
5 #![allow(dead_code)]
6
7 use std::mem::needs_drop;
8 use std::mem::ManuallyDrop;
9
10 struct NeedDrop;
11
12 impl Drop for NeedDrop {
13     fn drop(&mut self) {}
14 }
15
16 union UnionOk1<T> {
17     empty: (),
18     value: ManuallyDrop<T>,
19 }
20
21 union UnionOk2 {
22     value: ManuallyDrop<NeedDrop>,
23 }
24
25 #[allow(dead_code)]
26 union UnionOk3<T: Copy> {
27     empty: (),
28     value: T,
29 }
30
31 trait Foo { }
32
33 trait ImpliesCopy : Copy { }
34
35 #[allow(dead_code)]
36 union UnionOk4<T: ImpliesCopy> {
37     value: T,
38 }
39
40 fn main() {
41     // NeedDrop should not make needs_drop true
42     assert!(!needs_drop::<UnionOk1<NeedDrop>>());
43     assert!(!needs_drop::<UnionOk3<&dyn Foo>>());
44 }