From ea549e7a71964625f1eb24d7432f222c407d9999 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 17 Aug 2012 14:09:20 -0700 Subject: make borrowck more conservative around rvalues. this will require more temporaries, but is probably less magical. also, it means that borrowck matches trans better, so fewer crashes. bonus. Finally, stop warning about implicit copies when we are actually borrowing. Also, one test (vec-res-add) stopped failing due to #2587, and hence I added an xfail-test. Fixes #3217, #2977, #3067 --- src/libsyntax/ast_map.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index c9b6b879427..70aaa5e8be6 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -2,7 +2,7 @@ import std::map; import std::map::hashmap; import ast::*; import print::pprust; -import ast_util::path_to_ident; +import ast_util::{path_to_ident, stmt_id}; import diagnostic::span_handler; enum path_elt { path_mod(ident), path_name(ident) } @@ -39,6 +39,7 @@ enum ast_node { node_method(@method, def_id /* impl did */, @path /* path to the impl */), node_variant(variant, @item, @path), node_expr(@expr), + node_stmt(@stmt), node_export(@view_path, @path), // Locals are numbered, because the alias analysis needs to know in which // order they are introduced. @@ -65,6 +66,7 @@ fn mk_ast_map_visitor() -> vt { return visit::mk_vt(@{ visit_item: map_item, visit_expr: map_expr, + visit_stmt: map_stmt, visit_fn: map_fn, visit_local: map_local, visit_arm: map_arm, @@ -284,6 +286,11 @@ fn map_expr(ex: @expr, cx: ctx, v: vt) { visit::visit_expr(ex, cx, v); } +fn map_stmt(stmt: @stmt, cx: ctx, v: vt) { + cx.map.insert(stmt_id(*stmt), node_stmt(stmt)); + visit::visit_stmt(stmt, cx, v); +} + fn node_id_to_str(map: map, id: node_id) -> ~str { match map.find(id) { none => { @@ -313,6 +320,10 @@ fn node_id_to_str(map: map, id: node_id) -> ~str { fmt!{"expr %s (id=%?)", pprust::expr_to_str(expr), id} } + some(node_stmt(stmt)) => { + fmt!{"stmt %s (id=%?)", + pprust::stmt_to_str(*stmt), id} + } // FIXMEs are as per #2410 some(node_export(_, path)) => { fmt!{"export %s (id=%?)", // add more info here -- cgit 1.4.1-3-g733a5