Skip to content

Commit 7d2a0ef

Browse files
committed
---
yaml --- r: 47519 b: refs/heads/try c: b673b26 h: refs/heads/master i: 47517: e6ab6ec 47515: 130801a 47511: a7501fa 47503: 2695ce6 47487: 89cdea9 v: v3
1 parent 36e2c74 commit 7d2a0ef

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
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: a5030e7615f7d37acaee69b13f97b9ffa23159a5
5+
refs/heads/try: b673b26f03043f974682efceffbf40df9cf4bc84
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,27 @@ fn load_discr(bcx: block, scrutinee: ValueRef, min: int, max: int)
159159
}
160160
}
161161

162-
pub fn trans_switch(bcx: block, r: &Repr, scrutinee: ValueRef) ->
163-
(_match::branch_kind, Option<ValueRef>) {
162+
pub fn trans_switch(bcx: block, r: &Repr, scrutinee: ValueRef)
163+
-> (_match::branch_kind, Option<ValueRef>) {
164164
match *r {
165-
CEnum(min, max) => {
166-
(_match::switch, Some(load_discr(bcx, scrutinee, min, max)))
165+
CEnum(*) | General(*) => {
166+
(_match::switch, Some(trans_cast_to_int(bcx, r, scrutinee)))
167167
}
168168
Unit(*) | Univariant(*) => {
169169
(_match::single, None)
170170
}
171-
General(ref cases) => {
172-
(_match::switch, Some(load_discr(bcx, scrutinee, 0,
173-
(cases.len() - 1) as int)))
174-
}
171+
}
172+
}
173+
174+
pub fn trans_cast_to_int(bcx: block, r: &Repr, scrutinee: ValueRef)
175+
-> ValueRef {
176+
match *r {
177+
Unit(the_disc) => C_int(bcx.ccx(), the_disc),
178+
CEnum(min, max) => load_discr(bcx, scrutinee, min, max),
179+
Univariant(*) => bcx.ccx().sess.bug(~"type has no explicit \
180+
discriminant"),
181+
General(ref cases) => load_discr(bcx, scrutinee, 0,
182+
(cases.len() - 1) as int)
175183
}
176184
}
177185

0 commit comments

Comments
 (0)