diff options
| author | Graydon Hoare <[email protected]> | 2010-12-08 16:43:59 -0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-12-08 16:43:59 -0800 |
| commit | 440e637edfc58f50365f658e28c86ae51c1327b2 (patch) | |
| tree | fc1b513723f4fba1b69bd29e95d3a8827f442d89 /src | |
| parent | Fix structure returns harder. (diff) | |
| download | rust-440e637edfc58f50365f658e28c86ae51c1327b2.tar.xz rust-440e637edfc58f50365f658e28c86ae51c1327b2.zip | |
Fix boxed returns harder. Un-XFAIL output-slot-variants.rs.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 1 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 11 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/Makefile b/src/Makefile index 2a41351d..442c23bc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -542,6 +542,7 @@ TEST_XFAILS_SELF := $(filter-out \ large-records.rs \ lazy-init.rs \ multiline-comment.rs \ + output-slot-variants.rs \ readalias.rs \ rec.rs \ rec-auto.rs \ diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index ef0e7143..08e98aba 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -1608,6 +1608,11 @@ impure fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result { case (some[@ast.expr](?x)) { auto t = typeck.expr_ty(x); r = trans_expr(cx, x); + + // A return is an implicit copy into a newborn anonymous + // 'return value' in the caller frame. + r.bcx = incr_all_refcnts(r.bcx, r.val, t).bcx; + if (typeck.type_is_structural(t)) { // We usually treat structurals by-pointer; in particular, // trans_expr will have given us a structure pointer. But in @@ -1615,12 +1620,6 @@ impure fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result { // value here (which makes sense; the frame is going away!) r.val = r.bcx.build.Load(r.val); } - if (typeck.type_is_boxed(t)) { - // A return is an implicit ++ on the refcount on any boxed - // value, as it is being newly referenced as the anonymous - // 'return value' from the function, in the caller frame. - r.bcx = incr_refcnt(r.bcx, r.val).bcx; - } } case (_) { /* fall through */ } } |