File tree 2 files changed +47
-0
lines changed
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ // test for a union with a field that's a union with a manual impl Drop
2
+ // Ensures we do not treat all unions as not having any drop glue.
3
+
4
+ #![ feature( untagged_unions) ]
5
+
6
+ union Foo {
7
+ bar : Bar , //~ ERROR unions may not contain fields that need dropping
8
+ }
9
+
10
+ union Bar {
11
+ a : i32 ,
12
+ b : u32 ,
13
+ }
14
+
15
+ impl Drop for Bar {
16
+ fn drop ( & mut self ) { }
17
+ }
18
+
19
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0601]: `main` function not found in crate `union_custom_drop`
2
+ --> $DIR/union-custom-drop.rs:4:1
3
+ |
4
+ LL | / #![feature(untagged_unions)]
5
+ LL | |
6
+ LL | | union Foo {
7
+ LL | | bar: Bar,
8
+ ... |
9
+ LL | | }
10
+ LL | | }
11
+ | |_^ consider adding a `main` function to `$DIR/union-custom-drop.rs`
12
+
13
+ error[E0740]: unions may not contain fields that need dropping
14
+ --> $DIR/union-custom-drop.rs:7:5
15
+ |
16
+ LL | bar: Bar,
17
+ | ^^^^^^^^
18
+ |
19
+ note: `std::mem::ManuallyDrop` can be used to wrap the type
20
+ --> $DIR/union-custom-drop.rs:7:5
21
+ |
22
+ LL | bar: Bar,
23
+ | ^^^^^^^^
24
+
25
+ error: aborting due to 2 previous errors
26
+
27
+ Some errors have detailed explanations: E0601, E0740.
28
+ For more information about an error, try `rustc --explain E0601`.
You can’t perform that action at this time.
0 commit comments