Skip to content

Commit 2379302

Browse files
committed
---
yaml --- r: 47531 b: refs/heads/try c: 6bb6bab h: refs/heads/master i: 47529: 30447c7 47527: 72c257c v: v3
1 parent 6728070 commit 2379302

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: 075affa50d04c585a53d0c8e7b66bae372a72648
5+
refs/heads/try: 6bb6baba2cbcd885b53709bdd907e7053867a71e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/trans/expr.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,22 +1644,8 @@ fn trans_imm_cast(bcx: block, expr: @ast::expr,
16441644
(cast_enum, cast_integral) |
16451645
(cast_enum, cast_float) => {
16461646
let bcx = bcx;
1647-
let in_tid = match ty::get(t_in).sty {
1648-
ty::ty_enum(did, _) => did,
1649-
_ => ccx.sess.bug(~"enum cast source is not enum")
1650-
};
1651-
let variants = ty::enum_variants(ccx.tcx, in_tid);
1652-
let lldiscrim_a = if variants.len() == 1 {
1653-
// Univariants don't have a discriminant field,
1654-
// because there's only one value it could have:
1655-
C_integral(T_enum_discrim(ccx),
1656-
variants[0].disr_val as u64, True)
1657-
} else {
1658-
let llenumty = T_opaque_enum_ptr(ccx);
1659-
let av_enum = PointerCast(bcx, llexpr, llenumty);
1660-
let lldiscrim_a_ptr = GEPi(bcx, av_enum, [0u, 0u]);
1661-
Load(bcx, lldiscrim_a_ptr)
1662-
};
1647+
let repr = adt::represent_type(ccx, t_in);
1648+
let lldiscrim_a = adt::trans_cast_to_int(bcx, &repr, llexpr);
16631649
match k_out {
16641650
cast_integral => int_cast(bcx, ll_t_out,
16651651
val_ty(lldiscrim_a),

0 commit comments

Comments
 (0)