summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-08-17 01:43:41 -0500
committerGitHub <noreply@github.com>2016-08-17 01:43:41 -0500
commitf64606fbddecefe681ac2d29a1bb5253d50befbf (patch)
tree577b7daaaf03f0cac349e88239b3b215c50761a8 /src
parenteab08be8164bb37ff52bfcb5e739dec58ce9434b (diff)
parented92708c1ab8b46eab62c0d96ab498784fc9f8c1 (diff)
Auto merge of #33 - emilio:union-dtor, r=Manishearth
Unions with destructors. r? @Manishearth
Diffstat (limited to 'src')
-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()) &&