about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorMichael Sullivan <sully@msully.net>2012-06-25 20:00:46 -0700
committerMichael Sullivan <sully@msully.net>2012-06-25 20:00:46 -0700
commit329eca6044fdf376a7a89ec7a96dba7a8b884cf7 (patch)
tree7008814278a066914b6ba36818388d5212ffda9f /src/libsyntax/print
parentc087aaf56b1109163126fea4c2760f8414ffbe56 (diff)
downloadrust-329eca6044fdf376a7a89ec7a96dba7a8b884cf7.tar.gz
rust-329eca6044fdf376a7a89ec7a96dba7a8b884cf7.zip
Make vectors uglier ([]/~). Sorry. Should be temporary. Closes #2725.
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pp.rs32
-rw-r--r--src/libsyntax/print/pprust.rs75
2 files changed, 54 insertions, 53 deletions
diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs
index 329dff0c4c1..5f10fe0eb47 100644
--- a/src/libsyntax/print/pp.rs
+++ b/src/libsyntax/print/pp.rs
@@ -71,7 +71,7 @@ fn tok_str(++t: token) -> str {
     }
 }
 
-fn buf_str(toks: [mut token], szs: [mut int], left: uint, right: uint,
+fn buf_str(toks: [mut token]/~, szs: [mut int]/~, left: uint, right: uint,
            lim: uint) -> str {
     let n = vec::len(toks);
     assert (n == vec::len(szs));
@@ -100,9 +100,9 @@ fn mk_printer(out: io::writer, linewidth: uint) -> printer {
     // fall behind.
     let n: uint = 3u * linewidth;
     #debug("mk_printer %u", linewidth);
-    let token: [mut token] = vec::to_mut(vec::from_elem(n, EOF));
-    let size: [mut int] = vec::to_mut(vec::from_elem(n, 0));
-    let scan_stack: [mut uint] = vec::to_mut(vec::from_elem(n, 0u));
+    let token: [mut token]/~ = vec::to_mut(vec::from_elem(n, EOF));
+    let size: [mut int]/~ = vec::to_mut(vec::from_elem(n, 0));
+    let scan_stack: [mut uint]/~ = vec::to_mut(vec::from_elem(n, 0u));
     @{out: out,
       buf_len: n,
       mut margin: linewidth as int,
@@ -206,8 +206,8 @@ type printer = @{
     mut space: int, // number of spaces left on line
     mut left: uint, // index of left side of input stream
     mut right: uint, // index of right side of input stream
-    token: [mut token], // ring-buffr stream goes through
-    size: [mut int], // ring-buffer of calculated sizes
+    token: [mut token]/~, // ring-buffr stream goes through
+    size: [mut int]/~, // ring-buffer of calculated sizes
     mut left_total: int, // running size of stream "...left"
     mut right_total: int, // running size of stream "...right"
     // pseudo-stack, really a ring too. Holds the
@@ -216,7 +216,7 @@ type printer = @{
     // BEGIN (if there is any) on top of it. Stuff is flushed off the
     // bottom as it becomes irrelevant due to the primary ring-buffer
     // advancing.
-    mut scan_stack: [mut uint],
+    mut scan_stack: [mut uint]/~,
     mut scan_stack_empty: bool, // top==bottom disambiguator
     mut top: uint, // index of top of scan_stack
     mut bottom: uint, // index of bottom of scan_stack
@@ -231,7 +231,7 @@ impl printer for printer {
     // be very careful with this!
     fn replace_last_token(t: token) { self.token[self.right] = t; }
     fn pretty_print(t: token) {
-        #debug("pp [%u,%u]", self.left, self.right);
+        #debug("pp [%u,%u]/~", self.left, self.right);
         alt t {
           EOF {
             if !self.scan_stack_empty {
@@ -248,17 +248,17 @@ impl printer for printer {
                 self.left = 0u;
                 self.right = 0u;
             } else { self.advance_right(); }
-            #debug("pp BEGIN/buffer [%u,%u]", self.left, self.right);
+            #debug("pp BEGIN/buffer [%u,%u]/~", self.left, self.right);
             self.token[self.right] = t;
             self.size[self.right] = -self.right_total;
             self.scan_push(self.right);
           }
           END {
             if self.scan_stack_empty {
-                #debug("pp END/print [%u,%u]", self.left, self.right);
+                #debug("pp END/print [%u,%u]/~", self.left, self.right);
                 self.print(t, 0);
             } else {
-                #debug("pp END/buffer [%u,%u]", self.left, self.right);
+                #debug("pp END/buffer [%u,%u]/~", self.left, self.right);
                 self.advance_right();
                 self.token[self.right] = t;
                 self.size[self.right] = -1;
@@ -272,7 +272,7 @@ impl printer for printer {
                 self.left = 0u;
                 self.right = 0u;
             } else { self.advance_right(); }
-            #debug("pp BREAK/buffer [%u,%u]", self.left, self.right);
+            #debug("pp BREAK/buffer [%u,%u]/~", self.left, self.right);
             self.check_stack(0);
             self.scan_push(self.right);
             self.token[self.right] = t;
@@ -281,10 +281,10 @@ impl printer for printer {
           }
           STRING(s, len) {
             if self.scan_stack_empty {
-                #debug("pp STRING/print [%u,%u]", self.left, self.right);
+                #debug("pp STRING/print [%u,%u]/~", self.left, self.right);
                 self.print(t, len);
             } else {
-                #debug("pp STRING/buffer [%u,%u]", self.left, self.right);
+                #debug("pp STRING/buffer [%u,%u]/~", self.left, self.right);
                 self.advance_right();
                 self.token[self.right] = t;
                 self.size[self.right] = len;
@@ -295,7 +295,7 @@ impl printer for printer {
         }
     }
     fn check_stream() {
-        #debug("check_stream [%u, %u] with left_total=%d, right_total=%d",
+        #debug("check_stream [%u, %u]/~ with left_total=%d, right_total=%d",
                self.left, self.right, self.left_total, self.right_total);
         if self.right_total - self.left_total > self.space {
             #debug("scan window is %d, longer than space on line (%d)",
@@ -347,7 +347,7 @@ impl printer for printer {
         assert (self.right != self.left);
     }
     fn advance_left(++x: token, L: int) {
-        #debug("advnce_left [%u,%u], sizeof(%u)=%d", self.left, self.right,
+        #debug("advnce_left [%u,%u]/~, sizeof(%u)=%d", self.left, self.right,
                self.left, L);
         if L >= 0 {
             self.print(x, L);
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index b38f4c35d86..0d3855b4f93 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -26,8 +26,8 @@ fn no_ann() -> pp_ann {
 type ps =
     @{s: pp::printer,
       cm: option<codemap>,
-      comments: option<[comments::cmnt]>,
-      literals: option<[comments::lit]>,
+      comments: option<[comments::cmnt]/~>,
+      literals: option<[comments::lit]/~>,
       mut cur_cmnt: uint,
       mut cur_lit: uint,
       boxes: dvec<pp::breaks>,
@@ -46,8 +46,8 @@ fn end(s: ps) {
 fn rust_printer(writer: io::writer) -> ps {
     ret @{s: pp::mk_printer(writer, default_columns),
           cm: none::<codemap>,
-          comments: none::<[comments::cmnt]>,
-          literals: none::<[comments::lit]>,
+          comments: none::<[comments::cmnt]/~>,
+          literals: none::<[comments::lit]/~>,
           mut cur_cmnt: 0u,
           mut cur_lit: 0u,
           boxes: dvec(),
@@ -97,7 +97,7 @@ fn item_to_str(i: @ast::item) -> str { ret to_str(i, print_item); }
 
 fn attr_to_str(i: ast::attribute) -> str { ret to_str(i, print_attribute); }
 
-fn typarams_to_str(tps: [ast::ty_param]) -> str {
+fn typarams_to_str(tps: [ast::ty_param]/~) -> str {
     ret to_str(tps, print_type_params)
 }
 
@@ -106,7 +106,7 @@ fn path_to_str(&&p: @ast::path) -> str {
 }
 
 fn fun_to_str(decl: ast::fn_decl, name: ast::ident,
-              params: [ast::ty_param]) -> str {
+              params: [ast::ty_param]/~) -> str {
     let buffer = io::mem_buffer();
     let s = rust_printer(io::mem_buffer_writer(buffer));
     print_fn(s, decl, name, params);
@@ -119,15 +119,15 @@ fn fun_to_str(decl: ast::fn_decl, name: ast::ident,
 #[test]
 fn test_fun_to_str() {
     let decl: ast::fn_decl = {
-        inputs: [],
+        inputs: []/~,
         output: @{id: 0,
                   node: ast::ty_nil,
                   span: ast_util::dummy_sp()},
         purity: ast::impure_fn,
         cf: ast::return_val,
-        constraints: []
+        constraints: []/~
     };
-    assert fun_to_str(decl, "a", []) == "fn a()";
+    assert fun_to_str(decl, "a", []/~) == "fn a()";
 }
 
 fn block_to_str(blk: ast::blk) -> str {
@@ -158,8 +158,8 @@ fn variant_to_str(var: ast::variant) -> str {
 fn test_variant_to_str() {
     let var = ast_util::respan(ast_util::dummy_sp(), {
         name: "principle_skinner",
-        attrs: [],
-        args: [],
+        attrs: []/~,
+        args: []/~,
         id: 0,
         disr_expr: none
     });
@@ -254,7 +254,7 @@ fn synth_comment(s: ps, text: str) {
     word(s.s, "*/");
 }
 
-fn commasep<IN>(s: ps, b: breaks, elts: [IN], op: fn(ps, IN)) {
+fn commasep<IN>(s: ps, b: breaks, elts: [IN]/~, op: fn(ps, IN)) {
     box(s, 0u, b);
     let mut first = true;
     for elts.each {|elt|
@@ -265,7 +265,7 @@ fn commasep<IN>(s: ps, b: breaks, elts: [IN], op: fn(ps, IN)) {
 }
 
 
-fn commasep_cmnt<IN>(s: ps, b: breaks, elts: [IN], op: fn(ps, IN),
+fn commasep_cmnt<IN>(s: ps, b: breaks, elts: [IN]/~, op: fn(ps, IN),
                      get_span: fn(IN) -> codemap::span) {
     box(s, 0u, b);
     let len = vec::len::<IN>(elts);
@@ -284,12 +284,12 @@ fn commasep_cmnt<IN>(s: ps, b: breaks, elts: [IN], op: fn(ps, IN),
     end(s);
 }
 
-fn commasep_exprs(s: ps, b: breaks, exprs: [@ast::expr]) {
+fn commasep_exprs(s: ps, b: breaks, exprs: [@ast::expr]/~) {
     fn expr_span(&&expr: @ast::expr) -> codemap::span { ret expr.span; }
     commasep_cmnt(s, b, exprs, print_expr, expr_span);
 }
 
-fn print_mod(s: ps, _mod: ast::_mod, attrs: [ast::attribute]) {
+fn print_mod(s: ps, _mod: ast::_mod, attrs: [ast::attribute]/~) {
     print_inner_attributes(s, attrs);
     for _mod.view_items.each {|vitem|
         print_view_item(s, vitem);
@@ -297,7 +297,7 @@ fn print_mod(s: ps, _mod: ast::_mod, attrs: [ast::attribute]) {
     for _mod.items.each {|item| print_item(s, item); }
 }
 
-fn print_native_mod(s: ps, nmod: ast::native_mod, attrs: [ast::attribute]) {
+fn print_native_mod(s: ps, nmod: ast::native_mod, attrs: [ast::attribute]/~) {
     print_inner_attributes(s, attrs);
     for nmod.view_items.each {|vitem|
         print_view_item(s, vitem);
@@ -504,7 +504,7 @@ fn print_item(s: ps, &&item: @ast::item) {
           hardbreak_if_not_bol(s);
           maybe_print_comment(s, ctor.span.lo);
           head(s, "new");
-          print_fn_args_and_ret(s, ctor.node.dec, []);
+          print_fn_args_and_ret(s, ctor.node.dec, []/~);
           space(s.s);
           print_block(s, ctor.node.body);
           option::iter(m_dtor) {|dtor|
@@ -626,7 +626,7 @@ fn print_method(s: ps, meth: @ast::method) {
     print_block_with_attrs(s, meth.body, meth.attrs);
 }
 
-fn print_outer_attributes(s: ps, attrs: [ast::attribute]) {
+fn print_outer_attributes(s: ps, attrs: [ast::attribute]/~) {
     let mut count = 0;
     for attrs.each {|attr|
         alt attr.node.style {
@@ -637,7 +637,7 @@ fn print_outer_attributes(s: ps, attrs: [ast::attribute]) {
     if count > 0 { hardbreak_if_not_bol(s); }
 }
 
-fn print_inner_attributes(s: ps, attrs: [ast::attribute]) {
+fn print_inner_attributes(s: ps, attrs: [ast::attribute]/~) {
     let mut count = 0;
     for attrs.each {|attr|
         alt attr.node.style {
@@ -685,7 +685,7 @@ fn print_block(s: ps, blk: ast::blk) {
     print_possibly_embedded_block(s, blk, block_normal, indent_unit);
 }
 
-fn print_block_with_attrs(s: ps, blk: ast::blk, attrs: [ast::attribute]) {
+fn print_block_with_attrs(s: ps, blk: ast::blk, attrs: [ast::attribute]/~) {
     print_possibly_embedded_block_(s, blk, block_normal, indent_unit, attrs);
 }
 
@@ -694,11 +694,11 @@ enum embed_type { block_macro, block_block_fn, block_normal, }
 fn print_possibly_embedded_block(s: ps, blk: ast::blk, embedded: embed_type,
                                  indented: uint) {
     print_possibly_embedded_block_(
-        s, blk, embedded, indented, []);
+        s, blk, embedded, indented, []/~);
 }
 
 fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type,
-                                  indented: uint, attrs: [ast::attribute]) {
+                                  indented: uint, attrs: [ast::attribute]/~) {
     alt blk.node.rules {
       ast::unchecked_blk { word(s.s, "unchecked"); }
       ast::unsafe_blk { word(s.s, "unsafe"); }
@@ -811,10 +811,10 @@ fn print_mac(s: ps, m: ast::mac) {
 
 fn print_vstore(s: ps, t: ast::vstore) {
     alt t {
-      ast::vstore_fixed(some(i)) { word_space(s, #fmt("/%u", i)); }
-      ast::vstore_fixed(none) { word_space(s, "/_"); }
-      ast::vstore_uniq { word_space(s, "/~"); }
-      ast::vstore_box { word_space(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) { word(s.s, "/"); print_region(s, r); }
     }
 }
@@ -1259,18 +1259,18 @@ fn print_pat(s: ps, &&pat: @ast::pat) {
 }
 
 fn print_fn(s: ps, decl: ast::fn_decl, name: ast::ident,
-            typarams: [ast::ty_param]) {
+            typarams: [ast::ty_param]/~) {
     alt decl.purity {
       ast::impure_fn { head(s, "fn") }
       _ { head(s, purity_to_str(decl.purity) + " fn") }
     }
     word(s.s, *name);
     print_type_params(s, typarams);
-    print_fn_args_and_ret(s, decl, []);
+    print_fn_args_and_ret(s, decl, []/~);
 }
 
 fn print_fn_args(s: ps, decl: ast::fn_decl,
-                 cap_items: [ast::capture_item]) {
+                 cap_items: [ast::capture_item]/~) {
     commasep(s, inconsistent, decl.inputs, print_arg);
     if cap_items.is_not_empty() {
         let mut first = decl.inputs.is_empty();
@@ -1284,7 +1284,7 @@ fn print_fn_args(s: ps, decl: ast::fn_decl,
 }
 
 fn print_fn_args_and_ret(s: ps, decl: ast::fn_decl,
-                         cap_items: [ast::capture_item]) {
+                         cap_items: [ast::capture_item]/~) {
     popen(s);
     print_fn_args(s, decl, cap_items);
     pclose(s);
@@ -1301,7 +1301,7 @@ fn print_fn_args_and_ret(s: ps, decl: ast::fn_decl,
 }
 
 fn print_fn_block_args(s: ps, decl: ast::fn_decl,
-                       cap_items: [ast::capture_item]) {
+                       cap_items: [ast::capture_item]/~) {
     word(s.s, "|");
     print_fn_args(s, decl, cap_items);
     word(s.s, "|");
@@ -1329,7 +1329,7 @@ fn print_arg_mode(s: ps, m: ast::mode) {
     if ms != "" { word(s.s, ms); }
 }
 
-fn print_bounds(s: ps, bounds: @[ast::ty_param_bound]) {
+fn print_bounds(s: ps, bounds: @[ast::ty_param_bound]/~) {
     if vec::len(*bounds) > 0u {
         word(s.s, ":");
         for vec::each(*bounds) {|bound|
@@ -1351,7 +1351,7 @@ fn print_region_param(s: ps, rp: ast::region_param) {
     }
 }
 
-fn print_type_params(s: ps, &&params: [ast::ty_param]) {
+fn print_type_params(s: ps, &&params: [ast::ty_param]/~) {
     if vec::len(params) > 0u {
         word(s.s, "<");
         fn printParam(s: ps, param: ast::ty_param) {
@@ -1408,7 +1408,7 @@ fn print_view_path(s: ps, &&vp: @ast::view_path) {
     }
 }
 
-fn print_view_paths(s: ps, vps: [@ast::view_path]) {
+fn print_view_paths(s: ps, vps: [@ast::view_path]/~) {
     commasep(s, inconsistent, vps, print_view_path);
 }
 
@@ -1480,7 +1480,7 @@ fn print_arg(s: ps, input: ast::arg) {
 
 fn print_ty_fn(s: ps, opt_proto: option<ast::proto>,
                decl: ast::fn_decl, id: option<ast::ident>,
-               tps: option<[ast::ty_param]>) {
+               tps: option<[ast::ty_param]/~>) {
     ibox(s, indent_unit);
     word(s.s, opt_proto_to_str(opt_proto));
     alt id { some(id) { word(s.s, " "); word(s.s, *id); } _ { } }
@@ -1682,7 +1682,8 @@ fn next_comment(s: ps) -> option<comments::cmnt> {
     }
 }
 
-fn constr_args_to_str<T>(f: fn@(T) -> str, args: [@ast::sp_constr_arg<T>]) ->
+fn constr_args_to_str<T>(f: fn@(T) -> str,
+                         args: [@ast::sp_constr_arg<T>]/~) ->
    str {
     let mut comma = false;
     let mut s = "(";
@@ -1727,7 +1728,7 @@ fn ty_constr_to_str(&&c: @ast::ty_constr) -> str {
                                              c.node.args);
 }
 
-fn constrs_str<T>(constrs: [T], elt: fn(T) -> str) -> str {
+fn constrs_str<T>(constrs: [T]/~, elt: fn(T) -> str) -> str {
     let mut s = "", colon = true;
     for constrs.each {|c|
         if colon { s += " : "; colon = false; } else { s += ", "; }