Skip to content

Commit 3a45f87

Browse files
committed
rustc: Record the parent blocks of locals
1 parent de79caa commit 3a45f87

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/rustc/middle/region.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@ fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) {
269269
}
270270
}
271271

272+
fn resolve_local(local: @ast::local, cx: ctxt, visitor: visit::vt<ctxt>) {
273+
alt cx.parent {
274+
pa_block(blk_id) {
275+
cx.region_map.rvalue_to_block.insert(local.node.id, blk_id);
276+
}
277+
_ { cx.sess.span_bug(local.span, "local outside of block?!"); }
278+
}
279+
visit::visit_local(local, cx, visitor);
280+
}
281+
272282
fn resolve_item(item: @ast::item, cx: ctxt, visitor: visit::vt<ctxt>) {
273283
// Items create a new outer block scope as far as we're concerned.
274284
let parent = alt item.node {
@@ -304,7 +314,8 @@ fn resolve_crate(sess: session, def_map: resolve::def_map, crate: @ast::crate)
304314
visit_ty: resolve_ty,
305315
visit_arm: resolve_arm,
306316
visit_pat: resolve_pat,
307-
visit_expr: resolve_expr
317+
visit_expr: resolve_expr,
318+
visit_local: resolve_local
308319
with *visit::default_visitor()
309320
});
310321
visit::visit_crate(*crate, cx, visitor);

0 commit comments

Comments
 (0)