about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorJames Miller <bladeon@gmail.com>2013-07-06 12:47:42 +1200
committerJames Miller <bladeon@gmail.com>2013-07-07 22:51:09 +1200
commit97c5a44d3e805652a54a5693bbf2ab6d44db993b (patch)
treed80edf6d0f724bcb435200078501f2564bd9f5f9 /src/libsyntax/print
parent62c83bb17be9a47799d702a9470aa7a84012c782 (diff)
downloadrust-97c5a44d3e805652a54a5693bbf2ab6d44db993b.tar.gz
rust-97c5a44d3e805652a54a5693bbf2ab6d44db993b.zip
De-share trait_ref
Also, makes the pretty-printer use & instead of @ as much as possible,
which will help with later changes, though in the interim has produced
some... interesting constructs.
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs151
1 files changed, 75 insertions, 76 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index d50eb8453d2..d90055caffb 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -34,9 +34,9 @@ use std::uint;
 // The @ps is stored here to prevent recursive type.
 pub enum ann_node<'self> {
     node_block(@ps, &'self ast::blk),
-    node_item(@ps, @ast::item),
-    node_expr(@ps, @ast::expr),
-    node_pat(@ps, @ast::pat),
+    node_item(@ps, &'self ast::item),
+    node_expr(@ps, &'self ast::expr),
+    node_pat(@ps, &'self ast::pat),
 }
 pub struct pp_ann {
     pre: @fn(ann_node),
@@ -106,7 +106,7 @@ pub static default_columns: uint = 78u;
 pub fn print_crate(cm: @CodeMap,
                    intr: @ident_interner,
                    span_diagnostic: @diagnostic::span_handler,
-                   crate: @ast::crate,
+                   crate: &ast::crate,
                    filename: @str,
                    in: @io::Reader,
                    out: @io::Writer,
@@ -136,21 +136,21 @@ pub fn print_crate(cm: @CodeMap,
     print_crate_(s, crate);
 }
 
-pub fn print_crate_(s: @ps, crate: @ast::crate) {
+pub fn print_crate_(s: @ps, crate: &ast::crate) {
     print_mod(s, &crate.node.module, crate.node.attrs);
     print_remaining_comments(s);
     eof(s.s);
 }
 
-pub fn ty_to_str(ty: @ast::Ty, intr: @ident_interner) -> ~str {
+pub fn ty_to_str(ty: &ast::Ty, intr: @ident_interner) -> ~str {
     to_str(ty, print_type, intr)
 }
 
-pub fn pat_to_str(pat: @ast::pat, intr: @ident_interner) -> ~str {
+pub fn pat_to_str(pat: &ast::pat, intr: @ident_interner) -> ~str {
     to_str(pat, print_irrefutable_pat, intr)
 }
 
-pub fn expr_to_str(e: @ast::expr, intr: @ident_interner) -> ~str {
+pub fn expr_to_str(e: &ast::expr, intr: @ident_interner) -> ~str {
     to_str(e, print_expr, intr)
 }
 
@@ -158,19 +158,19 @@ pub fn lifetime_to_str(e: &ast::Lifetime, intr: @ident_interner) -> ~str {
     to_str(e, print_lifetime, intr)
 }
 
-pub fn tt_to_str(tt: ast::token_tree, intr: @ident_interner) -> ~str {
-    to_str(&tt, print_tt, intr)
+pub fn tt_to_str(tt: &ast::token_tree, intr: @ident_interner) -> ~str {
+    to_str(tt, print_tt, intr)
 }
 
 pub fn tts_to_str(tts: &[ast::token_tree], intr: @ident_interner) -> ~str {
-    to_str(tts, print_tts, intr)
+    to_str(&tts, print_tts, intr)
 }
 
 pub fn stmt_to_str(s: &ast::stmt, intr: @ident_interner) -> ~str {
     to_str(s, print_stmt, intr)
 }
 
-pub fn item_to_str(i: @ast::item, intr: @ident_interner) -> ~str {
+pub fn item_to_str(i: &ast::item, intr: @ident_interner) -> ~str {
     to_str(i, print_item, intr)
 }
 
@@ -208,11 +208,11 @@ pub fn block_to_str(blk: &ast::blk, intr: @ident_interner) -> ~str {
     }
 }
 
-pub fn meta_item_to_str(mi: @ast::meta_item, intr: @ident_interner) -> ~str {
+pub fn meta_item_to_str(mi: &ast::meta_item, intr: @ident_interner) -> ~str {
     to_str(mi, print_meta_item, intr)
 }
 
-pub fn attribute_to_str(attr: ast::attribute, intr: @ident_interner) -> ~str {
+pub fn attribute_to_str(attr: &ast::attribute, intr: @ident_interner) -> ~str {
     to_str(attr, print_attribute, intr)
 }
 
@@ -314,30 +314,30 @@ pub fn synth_comment(s: @ps, text: ~str) {
     word(s.s, "*/");
 }
 
-pub fn commasep<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN)) {
+pub fn commasep<T>(s: @ps, b: breaks, elts: &[T], op: &fn(@ps, &T)) {
     box(s, 0u, b);
     let mut first = true;
     for elts.iter().advance |elt| {
         if first { first = false; } else { word_space(s, ","); }
-        op(s, copy *elt);
+        op(s, elt);
     }
     end(s);
 }
 
 
-pub fn commasep_cmnt<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN),
-                               get_span: &fn(IN) -> codemap::span) {
+pub fn commasep_cmnt<T>(s: @ps, b: breaks, elts: &[T], op: &fn(@ps, &T),
+                               get_span: &fn(&T) -> codemap::span) {
     box(s, 0u, b);
     let len = elts.len();
     let mut i = 0u;
     for elts.iter().advance |elt| {
-        maybe_print_comment(s, get_span(copy *elt).hi);
-        op(s, copy *elt);
+        maybe_print_comment(s, get_span(elt).hi);
+        op(s, elt);
         i += 1u;
         if i < len {
             word(s.s, ",");
-            maybe_print_trailing_comment(s, get_span(copy *elt),
-                                         Some(get_span(copy elts[i]).hi));
+            maybe_print_trailing_comment(s, get_span(elt),
+                                         Some(get_span(&elts[i]).hi));
             space_if_not_bol(s);
         }
     }
@@ -345,8 +345,7 @@ pub fn commasep_cmnt<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN),
 }
 
 pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::expr]) {
-    fn expr_span(expr: @ast::expr) -> codemap::span { return expr.span; }
-    commasep_cmnt(s, b, exprs, print_expr, expr_span);
+    commasep_cmnt(s, b, exprs, |p, &e| print_expr(p, e), |e| e.span);
 }
 
 pub fn print_mod(s: @ps, _mod: &ast::_mod, attrs: &[ast::attribute]) {
@@ -373,7 +372,7 @@ pub fn print_opt_lifetime(s: @ps, lifetime: &Option<ast::Lifetime>) {
     }
 }
 
-pub fn print_type(s: @ps, ty: @ast::Ty) {
+pub fn print_type(s: @ps, ty: &ast::Ty) {
     maybe_print_comment(s, ty.span.lo);
     ibox(s, 0u);
     match ty.node {
@@ -399,7 +398,7 @@ pub fn print_type(s: @ps, ty: @ast::Ty) {
       }
       ast::ty_tup(ref elts) => {
         popen(s);
-        commasep(s, inconsistent, *elts, print_type);
+        commasep(s, inconsistent, *elts, |p, &t| print_type(p, t));
         if elts.len() == 1 {
             word(s.s, ",");
         }
@@ -443,7 +442,7 @@ pub fn print_type(s: @ps, ty: @ast::Ty) {
     end(s);
 }
 
-pub fn print_foreign_item(s: @ps, item: @ast::foreign_item) {
+pub fn print_foreign_item(s: @ps, item: &ast::foreign_item) {
     hardbreak_if_not_bol(s);
     maybe_print_comment(s, item.span.lo);
     print_outer_attributes(s, item.attrs);
@@ -470,7 +469,7 @@ pub fn print_foreign_item(s: @ps, item: @ast::foreign_item) {
     }
 }
 
-pub fn print_item(s: @ps, item: @ast::item) {
+pub fn print_item(s: @ps, item: &ast::item) {
     hardbreak_if_not_bol(s);
     maybe_print_comment(s, item.span.lo);
     print_outer_attributes(s, item.attrs);
@@ -560,7 +559,7 @@ pub fn print_item(s: @ps, item: @ast::item) {
           print_struct(s, struct_def, generics, item.ident, item.span);
       }
 
-      ast::item_impl(ref generics, opt_trait, ty, ref methods) => {
+      ast::item_impl(ref generics, ref opt_trait, ty, ref methods) => {
         head(s, visibility_qualified(item.vis, "impl"));
         if generics.is_parameterized() {
             print_generics(s, generics);
@@ -568,12 +567,12 @@ pub fn print_item(s: @ps, item: @ast::item) {
         }
 
         match opt_trait {
-            Some(t) => {
+            &Some(ref t) => {
                 print_trait_ref(s, t);
                 space(s.s);
                 word_space(s, "for");
             }
-            None => ()
+            &None => ()
         };
 
         print_type(s, ty);
@@ -618,7 +617,7 @@ pub fn print_item(s: @ps, item: @ast::item) {
         print_ident(s, item.ident);
         cbox(s, indent_unit);
         popen(s);
-        print_tts(s, *tts);
+        print_tts(s, &(tts.as_slice()));
         pclose(s);
         end(s);
       }
@@ -681,7 +680,7 @@ pub fn print_visibility(s: @ps, vis: ast::visibility) {
 }
 
 pub fn print_struct(s: @ps,
-                    struct_def: @ast::struct_def,
+                    struct_def: &ast::struct_def,
                     generics: &ast::Generics,
                     ident: ast::ident,
                     span: codemap::span) {
@@ -738,7 +737,7 @@ pub fn print_struct(s: @ps,
 /// expression arguments as expressions). It can be done! I think.
 pub fn print_tt(s: @ps, tt: &ast::token_tree) {
     match *tt {
-      ast::tt_delim(ref tts) => print_tts(s, *tts),
+      ast::tt_delim(ref tts) => print_tts(s, &(tts.as_slice())),
       ast::tt_tok(_, ref tk) => {
           word(s.s, parse::token::to_str(s.intr, tk));
       }
@@ -759,7 +758,7 @@ pub fn print_tt(s: @ps, tt: &ast::token_tree) {
     }
 }
 
-pub fn print_tts(s: @ps, tts: &[ast::token_tree]) {
+pub fn print_tts(s: @ps, tts: & &[ast::token_tree]) {
     ibox(s, 0);
     for tts.iter().enumerate().advance |(i, tt)| {
         if i != 0 {
@@ -777,7 +776,7 @@ pub fn print_variant(s: @ps, v: &ast::variant) {
             print_ident(s, v.node.name);
             if !args.is_empty() {
                 popen(s);
-                fn print_variant_arg(s: @ps, arg: ast::variant_arg) {
+                fn print_variant_arg(s: @ps, arg: &ast::variant_arg) {
                     print_type(s, arg.ty);
                 }
                 commasep(s, consistent, *args, print_variant_arg);
@@ -817,7 +816,7 @@ pub fn print_trait_method(s: @ps, m: &ast::trait_method) {
     }
 }
 
-pub fn print_method(s: @ps, meth: @ast::method) {
+pub fn print_method(s: @ps, meth: &ast::method) {
     hardbreak_if_not_bol(s);
     maybe_print_comment(s, meth.span.lo);
     print_outer_attributes(s, meth.attrs);
@@ -832,7 +831,7 @@ pub fn print_outer_attributes(s: @ps, attrs: &[ast::attribute]) {
     let mut count = 0;
     for attrs.iter().advance |attr| {
         match attr.node.style {
-          ast::attr_outer => { print_attribute(s, *attr); count += 1; }
+          ast::attr_outer => { print_attribute(s, attr); count += 1; }
           _ => {/* fallthrough */ }
         }
     }
@@ -844,7 +843,7 @@ pub fn print_inner_attributes(s: @ps, attrs: &[ast::attribute]) {
     for attrs.iter().advance |attr| {
         match attr.node.style {
           ast::attr_inner => {
-            print_attribute(s, *attr);
+            print_attribute(s, attr);
             if !attr.node.is_sugared_doc {
                 word(s.s, ";");
             }
@@ -856,11 +855,11 @@ pub fn print_inner_attributes(s: @ps, attrs: &[ast::attribute]) {
     if count > 0 { hardbreak_if_not_bol(s); }
 }
 
-pub fn print_attribute(s: @ps, attr: ast::attribute) {
+pub fn print_attribute(s: @ps, attr: &ast::attribute) {
     hardbreak_if_not_bol(s);
     maybe_print_comment(s, attr.span.lo);
     if attr.node.is_sugared_doc {
-        let meta = attr::attr_meta(attr);
+        let meta = attr::attr_meta(*attr);
         let comment = attr::get_meta_item_value_str(meta).get();
         word(s.s, comment);
     } else {
@@ -963,7 +962,7 @@ pub fn print_possibly_embedded_block_(s: @ps,
     (s.ann.post)(ann_node);
 }
 
-pub fn print_if(s: @ps, test: @ast::expr, blk: &ast::blk,
+pub fn print_if(s: @ps, test: &ast::expr, blk: &ast::blk,
                 elseopt: Option<@ast::expr>, chk: bool) {
     head(s, "if");
     if chk { word_nbsp(s, "check"); }
@@ -1009,7 +1008,7 @@ pub fn print_mac(s: @ps, m: &ast::mac) {
         print_path(s, pth, false);
         word(s.s, "!");
         popen(s);
-        print_tts(s, *tts);
+        print_tts(s, &tts.as_slice());
         pclose(s);
       }
     }
@@ -1088,15 +1087,15 @@ pub fn print_call_post(s: @ps,
     }
 }
 
-pub fn print_expr(s: @ps, expr: @ast::expr) {
-    fn print_field(s: @ps, field: ast::field) {
+pub fn print_expr(s: @ps, expr: &ast::expr) {
+    fn print_field(s: @ps, field: &ast::field) {
         ibox(s, indent_unit);
         print_ident(s, field.node.ident);
         word_space(s, ":");
         print_expr(s, field.node.expr);
         end(s);
     }
-    fn get_span(field: ast::field) -> codemap::span { return field.span; }
+    fn get_span(field: &ast::field) -> codemap::span { return field.span; }
 
     maybe_print_comment(s, expr.span.lo);
     ibox(s, indent_unit);
@@ -1173,7 +1172,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
         print_ident(s, ident);
         if tys.len() > 0u {
             word(s.s, "::<");
-            commasep(s, inconsistent, *tys, print_type);
+            commasep(s, inconsistent, *tys, |p, &e| print_type(p, e));
             word(s.s, ">");
         }
         print_call_post(s, sugar, &blk, &mut base_args);
@@ -1349,7 +1348,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
         print_ident(s, id);
         if tys.len() > 0u {
             word(s.s, "::<");
-            commasep(s, inconsistent, *tys, print_type);
+            commasep(s, inconsistent, *tys, |p, &e| print_type(p, e));
             word(s.s, ">");
         }
       }
@@ -1434,7 +1433,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
     end(s);
 }
 
-pub fn print_local_decl(s: @ps, loc: @ast::local) {
+pub fn print_local_decl(s: @ps, loc: &ast::local) {
     print_irrefutable_pat(s, loc.node.pat);
     match loc.node.ty.node {
       ast::ty_infer => (),
@@ -1442,7 +1441,7 @@ pub fn print_local_decl(s: @ps, loc: @ast::local) {
     }
 }
 
-pub fn print_decl(s: @ps, decl: @ast::decl) {
+pub fn print_decl(s: @ps, decl: &ast::decl) {
     maybe_print_comment(s, decl.span.lo);
     match decl.node {
       ast::decl_local(ref loc) => {
@@ -1454,7 +1453,7 @@ pub fn print_decl(s: @ps, decl: @ast::decl) {
             word_nbsp(s, "mut");
         }
 
-        fn print_local(s: @ps, loc: @ast::local) {
+        fn print_local(s: @ps, loc: &ast::local) {
             ibox(s, indent_unit);
             print_local_decl(s, loc);
             end(s);
@@ -1479,7 +1478,7 @@ pub fn print_ident(s: @ps, ident: ast::ident) {
     word(s.s, ident_to_str(&ident));
 }
 
-pub fn print_for_decl(s: @ps, loc: @ast::local, coll: @ast::expr) {
+pub fn print_for_decl(s: @ps, loc: &ast::local, coll: &ast::expr) {
     print_local_decl(s, loc);
     space(s.s);
     word_space(s, "in");
@@ -1511,7 +1510,7 @@ fn print_path_(s: @ps, path: &ast::Path, colons_before_params: bool,
                 }
             }
 
-            commasep(s, inconsistent, path.types, print_type);
+            commasep(s, inconsistent, path.types, |p, &e| print_type(p, e));
 
             word(s.s, ">");
         }
@@ -1527,15 +1526,15 @@ pub fn print_bounded_path(s: @ps, path: &ast::Path,
     print_path_(s, path, false, bounds)
 }
 
-pub fn print_irrefutable_pat(s: @ps, pat: @ast::pat) {
+pub fn print_irrefutable_pat(s: @ps, pat: &ast::pat) {
     print_pat(s, pat, false)
 }
 
-pub fn print_refutable_pat(s: @ps, pat: @ast::pat) {
+pub fn print_refutable_pat(s: @ps, pat: &ast::pat) {
     print_pat(s, pat, true)
 }
 
-pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
+pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) {
     maybe_print_comment(s, pat.span.lo);
     let ann_node = node_pat(s, pat);
     (s.ann.pre)(ann_node);
@@ -1570,7 +1569,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
             if !args.is_empty() {
               popen(s);
               commasep(s, inconsistent, *args,
-                       |s, p| print_pat(s, p, refutable));
+                       |s, &p| print_pat(s, p, refutable));
               pclose(s);
             } else { }
           }
@@ -1579,14 +1578,14 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
       ast::pat_struct(ref path, ref fields, etc) => {
         print_path(s, path, true);
         word(s.s, "{");
-        fn print_field(s: @ps, f: ast::field_pat, refutable: bool) {
+        fn print_field(s: @ps, f: &ast::field_pat, refutable: bool) {
             cbox(s, indent_unit);
             print_ident(s, f.ident);
             word_space(s, ":");
             print_pat(s, f.pat, refutable);
             end(s);
         }
-        fn get_span(f: ast::field_pat) -> codemap::span { return f.pat.span; }
+        fn get_span(f: &ast::field_pat) -> codemap::span { return f.pat.span; }
         commasep_cmnt(s, consistent, *fields,
                       |s, f| print_field(s,f,refutable),
                       get_span);
@@ -1598,7 +1597,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
       }
       ast::pat_tup(ref elts) => {
         popen(s);
-        commasep(s, inconsistent, *elts, |s, p| print_pat(s, p, refutable));
+        commasep(s, inconsistent, *elts, |s, &p| print_pat(s, p, refutable));
         if elts.len() == 1 {
             word(s.s, ",");
         }
@@ -1625,7 +1624,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
       }
       ast::pat_vec(ref before, slice, ref after) => {
         word(s.s, "[");
-        do commasep(s, inconsistent, *before) |s, p| {
+        do commasep(s, inconsistent, *before) |s, &p| {
             print_pat(s, p, refutable);
         }
         for slice.iter().advance |&p| {
@@ -1634,7 +1633,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
             print_pat(s, p, refutable);
             if !after.is_empty() { word_space(s, ","); }
         }
-        do commasep(s, inconsistent, *after) |s, p| {
+        do commasep(s, inconsistent, *after) |s, &p| {
             print_pat(s, p, refutable);
         }
         word(s.s, "]");
@@ -1643,8 +1642,8 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
     (s.ann.post)(ann_node);
 }
 
-pub fn explicit_self_to_str(explicit_self: ast::explicit_self_, intr: @ident_interner) -> ~str {
-    to_str(explicit_self, |a, b| { print_explicit_self(a, b); () }, intr)
+pub fn explicit_self_to_str(explicit_self: &ast::explicit_self_, intr: @ident_interner) -> ~str {
+    to_str(explicit_self, |a, &b| { print_explicit_self(a, b); () }, intr)
 }
 
 // Returns whether it printed anything
@@ -1748,7 +1747,7 @@ pub fn print_bounds(s: @ps, bounds: &OptVec<ast::TyParamBound>,
             }
 
             match *bound {
-                TraitTyParamBound(tref) => print_trait_ref(s, tref),
+                TraitTyParamBound(ref tref) => print_trait_ref(s, tref),
                 RegionTyParamBound => word(s.s, "'static"),
             }
         }
@@ -1784,12 +1783,12 @@ pub fn print_generics(s: @ps, generics: &ast::Generics) {
         }
 
         commasep(s, inconsistent, ints,
-                 |s, i| print_item(s, generics, i));
+                 |s, &i| print_item(s, generics, i));
         word(s.s, ">");
     }
 }
 
-pub fn print_meta_item(s: @ps, item: @ast::meta_item) {
+pub fn print_meta_item(s: @ps, item: &ast::meta_item) {
     ibox(s, indent_unit);
     match item.node {
       ast::meta_word(name) => word(s.s, name),
@@ -1804,8 +1803,8 @@ pub fn print_meta_item(s: @ps, item: @ast::meta_item) {
         commasep(
             s,
             consistent,
-            /* FIXME (#2543) */ copy *items,
-            print_meta_item
+            items.as_slice(),
+            |p, &i| print_meta_item(p, i)
         );
         pclose(s);
       }
@@ -1813,7 +1812,7 @@ pub fn print_meta_item(s: @ps, item: @ast::meta_item) {
     end(s);
 }
 
-pub fn print_view_path(s: @ps, vp: @ast::view_path) {
+pub fn print_view_path(s: @ps, vp: &ast::view_path) {
     match vp.node {
       ast::view_path_simple(ident, ref path, _) => {
         if path.idents[path.idents.len()-1u] != ident {
@@ -1841,7 +1840,7 @@ pub fn print_view_path(s: @ps, vp: @ast::view_path) {
 }
 
 pub fn print_view_paths(s: @ps, vps: &[@ast::view_path]) {
-    commasep(s, inconsistent, vps, print_view_path);
+    commasep(s, inconsistent, vps, |p, &vp| print_view_path(p, vp));
 }
 
 pub fn print_view_item(s: @ps, item: &ast::view_item) {
@@ -1855,7 +1854,7 @@ pub fn print_view_item(s: @ps, item: &ast::view_item) {
             print_ident(s, id);
             if !mta.is_empty() {
                 popen(s);
-                commasep(s, consistent, *mta, print_meta_item);
+                commasep(s, consistent, *mta, |p, &i| print_meta_item(p, i));
                 pclose(s);
             }
         }
@@ -2003,7 +2002,7 @@ pub fn print_remaining_comments(s: @ps) {
     }
 }
 
-pub fn print_literal(s: @ps, lit: @ast::lit) {
+pub fn print_literal(s: @ps, lit: &ast::lit) {
     maybe_print_comment(s, lit.span.lo);
     match next_lit(s, lit.span.lo) {
       Some(ref ltrl) => {
@@ -2056,7 +2055,7 @@ pub fn print_literal(s: @ps, lit: @ast::lit) {
     }
 }
 
-pub fn lit_to_str(l: @ast::lit) -> ~str {
+pub fn lit_to_str(l: &ast::lit) -> ~str {
     return to_str(l, print_literal, parse::token::mk_fake_ident_interner());
 }
 
@@ -2139,10 +2138,10 @@ pub fn print_string(s: @ps, st: &str) {
     word(s.s, "\"");
 }
 
-pub fn to_str<T: Copy>(t: T, f: @fn(@ps, T), intr: @ident_interner) -> ~str {
+pub fn to_str<T>(t: &T, f: &fn(@ps, &T), intr: @ident_interner) -> ~str {
     do io::with_str_writer |wr| {
         let s = rust_printer(wr, intr);
-        f(s, copy t);
+        f(s, t);
         eof(s.s);
     }
 }