File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
src/librustc/middle/trans Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -1209,6 +1209,14 @@ fn C_struct(elts: &[ValueRef]) -> ValueRef {
1209
1209
}
1210
1210
}
1211
1211
1212
+ fn C_packed_struct(elts: &[ValueRef]) -> ValueRef {
1213
+ unsafe {
1214
+ do vec::as_imm_buf(elts) |ptr, len| {
1215
+ llvm::LLVMConstStruct(ptr, len as c_uint, True)
1216
+ }
1217
+ }
1218
+ }
1219
+
1212
1220
fn C_named_struct(T: TypeRef, elts: &[ValueRef]) -> ValueRef {
1213
1221
unsafe {
1214
1222
do vec::as_imm_buf(elts) |ptr, len| {
Original file line number Diff line number Diff line change @@ -455,15 +455,14 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
455
455
let discrim = base:: get_discrim_val ( cx, e. span , tid, vid) ;
456
456
let c_args = C_struct ( args. map ( |a| const_expr ( cx, * a) ) ) ;
457
457
458
- let fields = if !degen {
459
- ~[ discrim, c_args]
458
+ // FIXME (#1645): enum body alignment is generaly wrong.
459
+ if !degen {
460
+ C_packed_struct ( ~[ discrim, c_args] )
460
461
} else if size == 0 {
461
- ~[ discrim]
462
+ C_struct ( ~[ discrim] )
462
463
} else {
463
- ~[ c_args]
464
- } ;
465
-
466
- C_struct ( fields)
464
+ C_struct ( ~[ c_args] )
465
+ }
467
466
}
468
467
_ => cx. sess . span_bug ( e. span , ~"expected a struct def")
469
468
}
You can’t perform that action at this time.
0 commit comments