diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-03-04 03:21:11 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-03-04 03:54:17 +0100 |
commit | 9134679a98703879ddd081fe14b64cfae074de4a (patch) | |
tree | 5fbfa8eb722f630ebd59c5d3213daff671882511 /src/codegen | |
parent | ed6e1bbec439e8b260e6e701379fc70d295f35fe (diff) |
codegen: Properly track alignment of unions.
This makes us not unnecessarily add repr(align) to unions.
Closes #1498.
Diffstat (limited to 'src/codegen')
-rw-r--r-- | src/codegen/mod.rs | 3 | ||||
-rw-r--r-- | src/codegen/struct_layout.rs | 6 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 2d71942c..d7f98c13 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1589,6 +1589,7 @@ impl CodeGenerator for CompInfo { // TODO(emilio): It'd be nice to unify this with the struct path // above somehow. let layout = layout.expect("Unable to get layout information?"); + struct_layout.saw_union(layout); if struct_layout.requires_explicit_align(layout) { explicit_align = Some(layout.align); @@ -1600,8 +1601,6 @@ impl CodeGenerator for CompInfo { _bindgen_union_align: #ty , } } else { - struct_layout.saw_union(layout); - quote! { pub bindgen_union_field: #ty , } diff --git a/src/codegen/struct_layout.rs b/src/codegen/struct_layout.rs index 921ab215..29d281aa 100644 --- a/src/codegen/struct_layout.rs +++ b/src/codegen/struct_layout.rs @@ -85,9 +85,9 @@ impl<'a> StructLayoutTracker<'a> { name: &'a str, ) -> Self { StructLayoutTracker { - name: name, - ctx: ctx, - comp: comp, + name, + ctx, + comp, is_packed: comp.is_packed(ctx, &ty.layout(ctx)), latest_offset: 0, padding_count: 0, |