Skip to content

Commit afab330

Browse files
committed
C-like enums are not always immediate
1 parent fcfbfde commit afab330

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/librustc/middle/trans/expr.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,9 +1726,14 @@ fn trans_imm_cast(bcx: @mut Block, expr: &ast::Expr,
17261726
(cast_enum, cast_float) => {
17271727
let bcx = bcx;
17281728
let repr = adt::represent_type(ccx, t_in);
1729-
let slot = Alloca(bcx, ll_t_in, "");
1730-
Store(bcx, llexpr, slot);
1731-
let lldiscrim_a = adt::trans_get_discr(bcx, repr, slot, Some(Type::i64()));
1729+
let llexpr_ptr;
1730+
if type_is_immediate(ccx, t_in) {
1731+
llexpr_ptr = Alloca(bcx, ll_t_in, "");
1732+
Store(bcx, llexpr, llexpr_ptr);
1733+
} else {
1734+
llexpr_ptr = llexpr;
1735+
}
1736+
let lldiscrim_a = adt::trans_get_discr(bcx, repr, llexpr_ptr, Some(Type::i64()));
17321737
match k_out {
17331738
cast_integral => int_cast(bcx, ll_t_out,
17341739
val_ty(lldiscrim_a),

0 commit comments

Comments
 (0)