Include capture clauses when generating metadata.

This may fix the bug that's blocking Issue #2441.
This commit is contained in:
Eric Holk 2012-05-29 16:11:15 -07:00
parent 6abddca18b
commit f49b891ce5
4 changed files with 18 additions and 10 deletions

View File

@ -427,12 +427,17 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
expr_alt(fld.fold_expr(expr), vec::map(arms, fld.fold_arm), mode)
}
expr_fn(proto, decl, body, captures) {
expr_fn(proto, fold_fn_decl(decl, fld),
fld.fold_block(body), captures)
expr_fn(proto, fold_fn_decl(decl, fld),
fld.fold_block(body),
@((*captures).map({|cap_item|
@({id: fld.new_id((*cap_item).id)
with *cap_item})})))
}
expr_fn_block(decl, body, captures) {
expr_fn_block(fold_fn_decl(decl, fld), fld.fold_block(body),
captures)
@((*captures).map({|cap_item|
@({id: fld.new_id((*cap_item).id)
with *cap_item})})))
}
expr_block(blk) { expr_block(fld.fold_block(blk)) }
expr_move(el, er) {

View File

@ -252,7 +252,11 @@ fn visit_ids(item: ast::inlined_item, vfn: fn@(ast::node_id)) {
vfn(m.self_id);
vec::iter(tps) {|tp| vfn(tp.id)}
}
visit::fk_anon(*) | visit::fk_fn_block(*) {
visit::fk_anon(_, capture_clause)
| visit::fk_fn_block(capture_clause) {
for vec::each(*capture_clause) {|clause|
vfn(clause.id);
}
}
}

View File

@ -67,6 +67,9 @@ fn compute_capture_vars(tcx: ty::ctxt,
// first add entries for anything explicitly named in the cap clause
for (*cap_clause).each { |cap_item|
#debug("Doing capture var: %s (%?)",
cap_item.name, cap_item.id);
let cap_def = tcx.def_map.get(cap_item.id);
let cap_def_id = ast_util::def_id_of_def(cap_def).node;
if cap_item.is_move {

View File

@ -1,5 +1,3 @@
// xfail-test :(
/**
An implementation of the Graph500 Bread First Search problem in Rust.
@ -267,8 +265,7 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
}
}
let graph_arc = arc::shared_arc(copy graph);
let graph = *graph_arc;
let (res, graph) = arc::shared_arc(copy graph);
let mut i = 0u;
while par::any(colors, is_gray) {
@ -277,8 +274,7 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
i += 1u;
let old_len = colors.len();
let colors_arc = arc::shared_arc(copy colors);
let color = *colors_arc;
let (res, color) = arc::shared_arc(copy colors);
colors = par::mapi(colors) {|i, c|
let c : color = c;