summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ir/analysis/derive_debug.rs4
-rw-r--r--src/ir/analysis/derive_default.rs4
-rw-r--r--src/ir/analysis/derive_hash.rs4
-rw-r--r--src/ir/analysis/derive_partial_eq.rs4
-rw-r--r--src/ir/ty.rs8
5 files changed, 20 insertions, 4 deletions
diff --git a/src/ir/analysis/derive_debug.rs b/src/ir/analysis/derive_debug.rs
index 76b889df..b7a35132 100644
--- a/src/ir/analysis/derive_debug.rs
+++ b/src/ir/analysis/derive_debug.rs
@@ -149,7 +149,9 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
let layout_can_derive = ty.layout(self.ctx).map_or(true, |l| {
l.opaque().can_trivially_derive_debug()
});
- return if layout_can_derive {
+ return if layout_can_derive &&
+ !(ty.is_union() &&
+ self.ctx.options().rust_features().untagged_union()) {
trace!(" we can trivially derive Debug for the layout");
ConstrainResult::Same
} else {
diff --git a/src/ir/analysis/derive_default.rs b/src/ir/analysis/derive_default.rs
index 34c34cfe..19f4a842 100644
--- a/src/ir/analysis/derive_default.rs
+++ b/src/ir/analysis/derive_default.rs
@@ -176,7 +176,9 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDefault<'ctx, 'gen> {
let layout_can_derive = ty.layout(self.ctx).map_or(true, |l| {
l.opaque().can_trivially_derive_default()
});
- return if layout_can_derive {
+ return if layout_can_derive &&
+ !(ty.is_union() &&
+ self.ctx.options().rust_features().untagged_union()) {
trace!(" we can trivially derive Default for the layout");
ConstrainResult::Same
} else {
diff --git a/src/ir/analysis/derive_hash.rs b/src/ir/analysis/derive_hash.rs
index d0ab3762..ee9cb23a 100644
--- a/src/ir/analysis/derive_hash.rs
+++ b/src/ir/analysis/derive_hash.rs
@@ -133,7 +133,9 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveHash<'ctx, 'gen> {
let layout_can_derive = ty.layout(self.ctx).map_or(true, |l| {
l.opaque().can_trivially_derive_hash()
});
- return if layout_can_derive {
+ return if layout_can_derive &&
+ !(ty.is_union() &&
+ self.ctx.options().rust_features().untagged_union()) {
trace!(" we can trivially derive Hash for the layout");
ConstrainResult::Same
} else {
diff --git a/src/ir/analysis/derive_partial_eq.rs b/src/ir/analysis/derive_partial_eq.rs
index 030c4c48..45ba67a5 100644
--- a/src/ir/analysis/derive_partial_eq.rs
+++ b/src/ir/analysis/derive_partial_eq.rs
@@ -136,7 +136,9 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDerivePartialEq<'ctx, 'gen> {
let layout_can_derive = ty.layout(self.ctx).map_or(true, |l| {
l.opaque().can_trivially_derive_partialeq()
});
- return if layout_can_derive {
+ return if layout_can_derive &&
+ !(ty.is_union() &&
+ self.ctx.options().rust_features().untagged_union()) {
trace!(" we can trivially derive PartialEq for the layout");
ConstrainResult::Same
} else {
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index da1cc6d7..b588dbb4 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -99,6 +99,14 @@ impl Type {
}
}
+ /// Is this a union?
+ pub fn is_union(&self) -> bool {
+ match self.kind {
+ TypeKind::Comp(ref comp) => comp.is_union(),
+ _ => false,
+ }
+ }
+
/// Is this type of kind `TypeKind::TypeParam`?
pub fn is_type_param(&self) -> bool {
match self.kind {