Skip to content

Commit 36e2c74

Browse files
committed
---
yaml --- r: 47518 b: refs/heads/try c: a5030e7 h: refs/heads/master v: v3
1 parent e6ab6ec commit 36e2c74

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
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: e09a843973f8dfc5766c0d36bb68ee1136cbf54c
5+
refs/heads/try: a5030e7615f7d37acaee69b13f97b9ffa23159a5
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: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,15 @@ pub fn trans_const(ccx: @CrateContext, r: &Repr, discr: int,
269269
assert min <= discr && discr <= max;
270270
C_int(ccx, discr)
271271
}
272-
Univariant(ref st, _dt) => {
272+
Univariant(ref st, dt) => {
273273
assert discr == 0;
274-
// consts are never destroyed, so the dtor flag is not needed
275-
C_struct(build_const_struct(ccx, st, vals))
274+
let s = C_struct(build_const_struct(ccx, st, vals));
275+
match dt {
276+
NoDtor => s,
277+
// The actual destructor flag doesn't need to be present.
278+
// But add an extra struct layer for compatibility.
279+
DtorPresent | DtorAbsent => C_struct(~[s])
280+
}
276281
}
277282
General(ref cases) => {
278283
let case = &cases[discr as uint];
@@ -336,7 +341,9 @@ pub fn const_get_element(ccx: @CrateContext, r: &Repr, val: ValueRef,
336341
match *r {
337342
Unit(*) | CEnum(*) => ccx.sess.bug(~"element access in C-like enum \
338343
const"),
339-
Univariant(*) => const_struct_field(ccx, val, ix),
344+
Univariant(_, NoDtor) => const_struct_field(ccx, val, ix),
345+
Univariant(*) => const_struct_field(ccx, const_get_elt(ccx, val,
346+
[0]), ix),
340347
General(*) => const_struct_field(ccx, const_get_elt(ccx, val,
341348
[1, 0]), ix)
342349
}

0 commit comments

Comments
 (0)