Skip to content

Commit 300492a

Browse files
committed
---
yaml --- r: 45014 b: refs/heads/master c: a5030e7 h: refs/heads/master v: v3
1 parent 4e4914c commit 300492a

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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e09a843973f8dfc5766c0d36bb68ee1136cbf54c
2+
refs/heads/master: a5030e7615f7d37acaee69b13f97b9ffa23159a5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3

trunk/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)