diff options
| author | Brian Anderson <andersrb@gmail.com> | 2011-05-15 01:51:31 -0400 |
|---|---|---|
| committer | Brian Anderson <andersrb@gmail.com> | 2011-05-17 00:46:56 -0400 |
| commit | fbfd8552ab1cd4931e1f4afd9c480dfb35c99da8 (patch) | |
| tree | a63b3e27cca75e1865b03095324d3bb316fb6cf2 /src/comp | |
| parent | 4539b3f6ab125aec0166e23c0faaa5d04d28dd30 (diff) | |
| download | rust-fbfd8552ab1cd4931e1f4afd9c480dfb35c99da8.tar.gz rust-fbfd8552ab1cd4931e1f4afd9c480dfb35c99da8.zip | |
Return a better result from blocks. Closes issue #377
Blocks return in a copy of the result of their ending expression, not the direct result of the ending expression, as that may be a local variable which gets zeroed by drop_slot.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/trans.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 600bf7e9e21..ad315df2dbf 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -6252,6 +6252,9 @@ fn trans_block(&@block_ctxt cx, &ast::block b) -> result { auto cleanup = bind drop_hoisted_ty(_, res_alloca.val, r_ty); find_outer_scope_cx(bcx).cleanups += [clean(cleanup)]; + + r = res(bcx, load_if_immediate(bcx, + res_alloca.val, r_ty)); } } } |
