Skip to content

Commit 74b84b0

Browse files
committed
---
yaml --- r: 46810 b: refs/heads/auto c: 6bb6bab h: refs/heads/master v: v3
1 parent 0a117ea commit 74b84b0

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
@@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 075affa50d04c585a53d0c8e7b66bae372a72648
17+
refs/heads/auto: 6bb6baba2cbcd885b53709bdd907e7053867a71e

branches/auto/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)