about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-08-17 14:09:20 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-08-17 15:14:13 -0700
commitea549e7a71964625f1eb24d7432f222c407d9999 (patch)
treec2402391dd25c87ae06c86e8999e66ccb9556f88 /src/libsyntax
parent8f01343f011e555bad1a11f7abfadcb7682a4627 (diff)
downloadrust-ea549e7a71964625f1eb24d7432f222c407d9999.tar.gz
rust-ea549e7a71964625f1eb24d7432f222c407d9999.zip
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
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast_map.rs13
1 files changed, 12 insertions, 1 deletions
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