Skip to content

Commit

Permalink
Ensure we do not treat all unions as not having any drop glue.
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Oct 11, 2019
1 parent fb23a5c commit 7e1a65d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/ui/union/union-custom-drop.rs
@@ -0,0 +1,19 @@
// test for a union with a field that's a union with a manual impl Drop
// Ensures we do not treat all unions as not having any drop glue.

#![feature(untagged_unions)]

union Foo {
bar: Bar, //~ ERROR unions may not contain fields that need dropping
}

union Bar {
a: i32,
b: u32,
}

impl Drop for Bar {
fn drop(&mut self) {}
}

fn main() {}
28 changes: 28 additions & 0 deletions src/test/ui/union/union-custom-drop.stderr
@@ -0,0 +1,28 @@
error[E0601]: `main` function not found in crate `union_custom_drop`
--> $DIR/union-custom-drop.rs:4:1
|
LL | / #![feature(untagged_unions)]
LL | |
LL | | union Foo {
LL | | bar: Bar,
... |
LL | | }
LL | | }
| |_^ consider adding a `main` function to `$DIR/union-custom-drop.rs`

error[E0740]: unions may not contain fields that need dropping
--> $DIR/union-custom-drop.rs:7:5
|
LL | bar: Bar,
| ^^^^^^^^
|
note: `std::mem::ManuallyDrop` can be used to wrap the type
--> $DIR/union-custom-drop.rs:7:5
|
LL | bar: Bar,
| ^^^^^^^^

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0601, E0740.
For more information about an error, try `rustc --explain E0601`.

0 comments on commit 7e1a65d

Please sign in to comment.