summaryrefslogtreecommitdiff
path: root/src/codegen/struct_layout.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen/struct_layout.rs')
-rw-r--r--src/codegen/struct_layout.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/codegen/struct_layout.rs b/src/codegen/struct_layout.rs
index 657be0b4..ddac1b0a 100644
--- a/src/codegen/struct_layout.rs
+++ b/src/codegen/struct_layout.rs
@@ -20,6 +20,7 @@ pub struct StructLayoutTracker<'a> {
is_packed: bool,
known_type_layout: Option<Layout>,
is_rust_union: bool,
+ can_copy_union_fields: bool,
latest_offset: usize,
padding_count: usize,
latest_field_layout: Option<Layout>,
@@ -90,8 +91,8 @@ impl<'a> StructLayoutTracker<'a> {
) -> Self {
let known_type_layout = ty.layout(ctx);
let is_packed = comp.is_packed(ctx, known_type_layout.as_ref());
- let is_rust_union = comp.is_union() &&
- comp.can_be_rust_union(ctx, known_type_layout.as_ref());
+ let (is_rust_union, can_copy_union_fields) =
+ comp.is_rust_union(ctx, known_type_layout.as_ref(), name);
StructLayoutTracker {
name,
ctx,
@@ -99,6 +100,7 @@ impl<'a> StructLayoutTracker<'a> {
is_packed,
known_type_layout,
is_rust_union,
+ can_copy_union_fields,
latest_offset: 0,
padding_count: 0,
latest_field_layout: None,
@@ -107,6 +109,10 @@ impl<'a> StructLayoutTracker<'a> {
}
}
+ pub fn can_copy_union_fields(&self) -> bool {
+ self.can_copy_union_fields
+ }
+
pub fn is_rust_union(&self) -> bool {
self.is_rust_union
}