summaryrefslogtreecommitdiff
path: root/src/codegen/mod.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2020-11-28 01:33:32 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2020-11-28 03:14:51 +0100
commit19142ac6b3d8ee4fc5686d6f30b77e660026e528 (patch)
tree7be336cb2bfd34e6a8c844b868efb4332aba9c4f /src/codegen/mod.rs
parent6a5726eac514b49ec8a9f8360ed5d0d73da9feb7 (diff)
struct_layout: Fix field offset computation for packed(n) structs.
This can cause unnecessary padding to be computed otherwise at the end of the struct. With repr(packed(n)), a field can have padding to adjacent fields as long as its alignment is less than n. So reuse the code we have to align to a field layout, aligning to the struct layout instead. Fixes #1934
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r--src/codegen/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 15aea22a..0d93c491 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1650,7 +1650,7 @@ impl CodeGenerator for CompInfo {
let ty = item.expect_type();
let layout = ty.layout(ctx);
- let mut packed = self.is_packed(ctx, &layout);
+ let mut packed = self.is_packed(ctx, layout.as_ref());
let canonical_name = item.canonical_name(ctx);
let canonical_ident = ctx.rust_ident(&canonical_name);