Skip to content

Commit 440e637

Browse files
committed
Fix boxed returns harder. Un-XFAIL output-slot-variants.rs.
1 parent 652ae9f commit 440e637

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ TEST_XFAILS_SELF := $(filter-out \
542542
large-records.rs \
543543
lazy-init.rs \
544544
multiline-comment.rs \
545+
output-slot-variants.rs \
545546
readalias.rs \
546547
rec.rs \
547548
rec-auto.rs \

src/comp/middle/trans.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,19 +1608,18 @@ impure fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
16081608
case (some[@ast.expr](?x)) {
16091609
auto t = typeck.expr_ty(x);
16101610
r = trans_expr(cx, x);
1611+
1612+
// A return is an implicit copy into a newborn anonymous
1613+
// 'return value' in the caller frame.
1614+
r.bcx = incr_all_refcnts(r.bcx, r.val, t).bcx;
1615+
16111616
if (typeck.type_is_structural(t)) {
16121617
// We usually treat structurals by-pointer; in particular,
16131618
// trans_expr will have given us a structure pointer. But in
16141619
// this case we're about to return. LLVM wants a first-class
16151620
// value here (which makes sense; the frame is going away!)
16161621
r.val = r.bcx.build.Load(r.val);
16171622
}
1618-
if (typeck.type_is_boxed(t)) {
1619-
// A return is an implicit ++ on the refcount on any boxed
1620-
// value, as it is being newly referenced as the anonymous
1621-
// 'return value' from the function, in the caller frame.
1622-
r.bcx = incr_refcnt(r.bcx, r.val).bcx;
1623-
}
16241623
}
16251624
case (_) { /* fall through */ }
16261625
}

0 commit comments

Comments
 (0)