Skip to content

Commit b71c7ba

Browse files
author
bors-servo
authored
Auto merge of #554 - emilio:union-pad, r=fitzgen
codegen: Don't pad union fields. Fixes #553
2 parents d57616c + 0e76c8c commit b71c7ba

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/codegen/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,9 +1136,11 @@ impl CodeGenerator for CompInfo {
11361136
}
11371137
};
11381138

1139-
if let Some(padding_field) =
1140-
struct_layout.pad_field(&field_name, field_ty, field.offset()) {
1141-
fields.push(padding_field);
1139+
if !is_union {
1140+
if let Some(padding_field) =
1141+
struct_layout.pad_field(&field_name, field_ty, field.offset()) {
1142+
fields.push(padding_field);
1143+
}
11421144
}
11431145

11441146
let is_private = field.annotations()

0 commit comments

Comments
 (0)