Skip to content

Commit 879a952

Browse files
committed
rustc: Find the correct outer scope in trans_block
1 parent 40b511a commit 879a952

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/comp/middle/trans.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6171,6 +6171,9 @@ fn trans_block(&@block_ctxt cx, &ast::block b) -> result {
61716171

61726172
alt (b.node.expr) {
61736173
case (some[@ast::expr](?e)) {
6174+
// Hold onto the context for this scope since we'll need it to
6175+
// find the outer scope
6176+
auto scope_bcx = bcx;
61746177
r = trans_expr(bcx, e);
61756178
bcx = r.bcx;
61766179

@@ -6212,7 +6215,8 @@ fn trans_block(&@block_ctxt cx, &ast::block b) -> result {
62126215

62136216
auto cleanup = bind drop_hoisted_ty(_, res_alloca.val,
62146217
r_ty);
6215-
find_outer_scope_cx(bcx).cleanups += [clean(cleanup)];
6218+
auto outer_scope_cx = find_outer_scope_cx(scope_bcx);
6219+
outer_scope_cx.cleanups += [clean(cleanup)];
62166220

62176221
r = res(bcx, load_if_immediate(bcx,
62186222
res_alloca.val, r_ty));

src/test/run-pass/expr-block-ref.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// xfail-stage0
2+
3+
fn main() {
4+
auto x = {{[10]}};
5+
}

src/test/run-pass/expr-elseif-ref2.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// xfail-stage0
2+
// xfail-stage1
3+
// xfail-stage2
4+
5+
fn main() {
6+
auto x = if (false) {
7+
[0u]
8+
} else if (true) {
9+
[10u]
10+
} else {
11+
[0u]
12+
};
13+
}

0 commit comments

Comments
 (0)