From f49b891ce534101695bb012982cf50d21665feef Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Tue, 29 May 2012 16:11:15 -0700 Subject: [PATCH] Include capture clauses when generating metadata. This may fix the bug that's blocking Issue #2441. --- src/librustsyntax/fold.rs | 11 ++++++++--- src/rustc/middle/astencode.rs | 6 +++++- src/rustc/middle/capture.rs | 3 +++ src/test/bench/graph500-bfs.rs | 8 ++------ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/librustsyntax/fold.rs b/src/librustsyntax/fold.rs index 9a6afd830ba..ecdb8d328fb 100644 --- a/src/librustsyntax/fold.rs +++ b/src/librustsyntax/fold.rs @@ -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) { diff --git a/src/rustc/middle/astencode.rs b/src/rustc/middle/astencode.rs index 5a43611b276..4d412447797 100644 --- a/src/rustc/middle/astencode.rs +++ b/src/rustc/middle/astencode.rs @@ -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); + } } } diff --git a/src/rustc/middle/capture.rs b/src/rustc/middle/capture.rs index d6edd2b935d..64dafc09a7c 100644 --- a/src/rustc/middle/capture.rs +++ b/src/rustc/middle/capture.rs @@ -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 { diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index 45f43f551ce..0779179326a 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -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;