Skip to content

Commit f2540aa

Browse files
committed
---
yaml --- r: 46797 b: refs/heads/auto c: a5030e7 h: refs/heads/master i: 46795: d3ed5c6 v: v3
1 parent 890af86 commit f2540aa

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
@@ -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: e09a843973f8dfc5766c0d36bb68ee1136cbf54c
17+
refs/heads/auto: a5030e7615f7d37acaee69b13f97b9ffa23159a5

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