rustc: Find the correct outer scope in trans_block

This commit is contained in:
Brian Anderson 2011-05-17 22:52:18 -04:00
parent 40b511a7c5
commit 879a952a37
3 changed files with 23 additions and 1 deletions

View file

@ -6171,6 +6171,9 @@ fn trans_block(&@block_ctxt cx, &ast::block b) -> result {
alt (b.node.expr) {
case (some[@ast::expr](?e)) {
// Hold onto the context for this scope since we'll need it to
// find the outer scope
auto scope_bcx = bcx;
r = trans_expr(bcx, e);
bcx = r.bcx;
@ -6212,7 +6215,8 @@ 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)];
auto outer_scope_cx = find_outer_scope_cx(scope_bcx);
outer_scope_cx.cleanups += [clean(cleanup)];
r = res(bcx, load_if_immediate(bcx,
res_alloca.val, r_ty));

View file

@ -0,0 +1,5 @@
// xfail-stage0
fn main() {
auto x = {{[10]}};
}

View file

@ -0,0 +1,13 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
fn main() {
auto x = if (false) {
[0u]
} else if (true) {
[10u]
} else {
[0u]
};
}