Skip to content

Commit 52cf61f

Browse files
committed
Fix const enums better: let them have the same alignment as an "opaque enum".
1 parent 6647a34 commit 52cf61f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustc/middle/trans/consts.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,12 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
470470

471471
// FIXME (#1645): enum body alignment is generaly wrong.
472472
if !degen {
473-
C_packed_struct(~[discrim, c_args])
473+
// A packed_struct has an alignment of 1; thus,
474+
// wrapping one around c_args will misalign it the
475+
// same way we normally misalign enum bodies
476+
// without affecting its internal alignment or
477+
// changing the alignment of the enum.
478+
C_struct(~[discrim, C_packed_struct(~[c_args])])
474479
} else if size == 0 {
475480
C_struct(~[discrim])
476481
} else {

0 commit comments

Comments
 (0)