diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-09-20 13:53:46 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-10-11 10:43:55 +0200 |
| commit | 7e1a65dce1d13d02de8e0ffafad15538556cb7b9 (patch) | |
| tree | 4259558cfe37824e5f1ee8ca3b78a5b841b23d8b | |
| parent | fb23a5cf3bda8d4d5ee89be4c1777d28a1061f9b (diff) | |
| download | rust-7e1a65dce1d13d02de8e0ffafad15538556cb7b9.tar.gz rust-7e1a65dce1d13d02de8e0ffafad15538556cb7b9.zip | |
Ensure we do not treat all unions as not having any drop glue.
| -rw-r--r-- | src/test/ui/union/union-custom-drop.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/union/union-custom-drop.stderr | 28 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/test/ui/union/union-custom-drop.rs b/src/test/ui/union/union-custom-drop.rs new file mode 100644 index 00000000000..8f816cc1b73 --- /dev/null +++ b/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() {} diff --git a/src/test/ui/union/union-custom-drop.stderr b/src/test/ui/union/union-custom-drop.stderr new file mode 100644 index 00000000000..8e4e5dd40fd --- /dev/null +++ b/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`. |
