Skip to content

Commit f49b891

Browse files
committed
Include capture clauses when generating metadata.
This may fix the bug that's blocking Issue #2441.
1 parent 6abddca commit f49b891

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

src/librustsyntax/fold.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,17 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
427427
expr_alt(fld.fold_expr(expr), vec::map(arms, fld.fold_arm), mode)
428428
}
429429
expr_fn(proto, decl, body, captures) {
430-
expr_fn(proto, fold_fn_decl(decl, fld),
431-
fld.fold_block(body), captures)
430+
expr_fn(proto, fold_fn_decl(decl, fld),
431+
fld.fold_block(body),
432+
@((*captures).map({|cap_item|
433+
@({id: fld.new_id((*cap_item).id)
434+
with *cap_item})})))
432435
}
433436
expr_fn_block(decl, body, captures) {
434437
expr_fn_block(fold_fn_decl(decl, fld), fld.fold_block(body),
435-
captures)
438+
@((*captures).map({|cap_item|
439+
@({id: fld.new_id((*cap_item).id)
440+
with *cap_item})})))
436441
}
437442
expr_block(blk) { expr_block(fld.fold_block(blk)) }
438443
expr_move(el, er) {

src/rustc/middle/astencode.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,11 @@ fn visit_ids(item: ast::inlined_item, vfn: fn@(ast::node_id)) {
252252
vfn(m.self_id);
253253
vec::iter(tps) {|tp| vfn(tp.id)}
254254
}
255-
visit::fk_anon(*) | visit::fk_fn_block(*) {
255+
visit::fk_anon(_, capture_clause)
256+
| visit::fk_fn_block(capture_clause) {
257+
for vec::each(*capture_clause) {|clause|
258+
vfn(clause.id);
259+
}
256260
}
257261
}
258262

src/rustc/middle/capture.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ fn compute_capture_vars(tcx: ty::ctxt,
6767
// first add entries for anything explicitly named in the cap clause
6868

6969
for (*cap_clause).each { |cap_item|
70+
#debug("Doing capture var: %s (%?)",
71+
cap_item.name, cap_item.id);
72+
7073
let cap_def = tcx.def_map.get(cap_item.id);
7174
let cap_def_id = ast_util::def_id_of_def(cap_def).node;
7275
if cap_item.is_move {

src/test/bench/graph500-bfs.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// xfail-test :(
2-
31
/**
42
53
An implementation of the Graph500 Bread First Search problem in Rust.
@@ -267,8 +265,7 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
267265
}
268266
}
269267

270-
let graph_arc = arc::shared_arc(copy graph);
271-
let graph = *graph_arc;
268+
let (res, graph) = arc::shared_arc(copy graph);
272269

273270
let mut i = 0u;
274271
while par::any(colors, is_gray) {
@@ -277,8 +274,7 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
277274
i += 1u;
278275
let old_len = colors.len();
279276

280-
let colors_arc = arc::shared_arc(copy colors);
281-
let color = *colors_arc;
277+
let (res, color) = arc::shared_arc(copy colors);
282278

283279
colors = par::mapi(colors) {|i, c|
284280
let c : color = c;

0 commit comments

Comments
 (0)