summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-08-16 23:37:29 -0700
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-08-16 23:42:13 -0700
commita388080636cb54158e176f0fee8a343ce28f3c9f (patch)
tree6d5d5feadfc2757552afe381365c07f7e4515842
parenteab08be8164bb37ff52bfcb5e739dec58ce9434b (diff)
types: Don't avoid the destructor check when looking at unions.
This is kind of unfortunate, but we weren't taking into account explicit destructors.
-rw-r--r--src/types.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/types.rs b/src/types.rs
index 30a4f454..9eaa3eb8 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -681,13 +681,17 @@ impl CompInfo {
if self.no_copy {
return false;
}
+
+ // NOTE: Take into account that while unions in C and C++ are copied by
+ // default, the may have an explicit destructor in C++, so we can't
+ // defer this check just for the union case.
+ if self.has_destructor() {
+ return false;
+ }
+
match self.kind {
CompKind::Union => true,
CompKind::Struct => {
- if self.has_destructor() {
- return false;
- }
-
// With template args, use a safe subset of the types,
// since copyability depends on the types itself.
self.ref_template.as_ref().map_or(true, |t| t.can_derive_copy()) &&