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.
This commit is contained in:
parent
4539b3f6ab
commit
fbfd8552ab
2 changed files with 22 additions and 0 deletions
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue