about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-09-14 15:20:09 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-09-14 15:22:15 -0700
commit7107b4eff51e58aa1ae5e30b073b4d788b13a2cb (patch)
treec2a529a20d4ba0986ce75ac1e4234be46e77c820 /src/libsyntax/print
parent34cece99cce373546d62aed06a7ec55d04aaa124 (diff)
downloadrust-7107b4eff51e58aa1ae5e30b073b4d788b13a2cb.tar.gz
rust-7107b4eff51e58aa1ae5e30b073b4d788b13a2cb.zip
Have parser recognize static, self region.
Fixes a bug in methods that &self couldn't be referenced in the
body. Also fixes #2479.
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 49133242d54..a4e7d12bd21 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -328,14 +328,24 @@ fn print_foreign_mod(s: ps, nmod: ast::foreign_mod,
     for nmod.items.each |item| { print_foreign_item(s, item); }
 }
 
-fn print_region(s: ps, region: @ast::region) {
+fn print_region(s: ps, region: @ast::region, sep: ~str) {
     match region.node {
-      ast::re_anon => word_space(s, ~"&"),
-      ast::re_named(name) => {
-        word(s.s, ~"&");
-        print_ident(s, name);
-      }
+        ast::re_anon => {
+            word_space(s, ~"&");
+            return;
+        }
+        ast::re_static => {
+            word_space(s, ~"&static")
+        }
+        ast::re_self => {
+            word_space(s, ~"&self")
+        }
+        ast::re_named(name) => {
+            word(s.s, ~"&");
+            print_ident(s, name);
+        }
     }
+    word(s.s, sep);
 }
 
 fn print_type(s: ps, &&ty: @ast::ty) {
@@ -362,11 +372,8 @@ fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) {
       }
       ast::ty_ptr(mt) => { word(s.s, ~"*"); print_mt(s, mt); }
       ast::ty_rptr(region, mt) => {
-        match region.node {
-          ast::re_anon => word(s.s, ~"&"),
-          _ => { print_region(s, region); word(s.s, ~"/"); }
-        }
-        print_mt(s, mt);
+          print_region(s, region, ~"/");
+          print_mt(s, mt);
       }
       ast::ty_rec(fields) => {
         word(s.s, ~"{");
@@ -961,18 +968,11 @@ fn print_mac(s: ps, m: ast::mac) {
 
 fn print_vstore(s: ps, t: ast::vstore) {
     match t {
-      ast::vstore_fixed(Some(i)) => word(s.s, fmt!("%u", i)),
-      ast::vstore_fixed(None) => word(s.s, ~"_"),
-      ast::vstore_uniq => word(s.s, ~"~"),
-      ast::vstore_box => word(s.s, ~"@"),
-      ast::vstore_slice(r) => match r.node {
-        ast::re_anon => word(s.s, ~"&"),
-        ast::re_named(name) => {
-            word(s.s, ~"&");
-            print_ident(s, name);
-            word(s.s, ~".");
-        }
-      }
+        ast::vstore_fixed(Some(i)) => word(s.s, fmt!("%u", i)),
+        ast::vstore_fixed(None) => word(s.s, ~"_"),
+        ast::vstore_uniq => word(s.s, ~"~"),
+        ast::vstore_box => word(s.s, ~"@"),
+        ast::vstore_slice(r) => print_region(s, r, ~"/")
     }
 }
 
@@ -1455,7 +1455,7 @@ fn print_path(s: ps, &&path: @ast::path, colons_before_params: bool) {
           None => { /* ok */ }
           Some(r) => {
             word(s.s, ~"/");
-            print_region(s, r);
+            print_region(s, r, ~"");
           }
         }