summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-06-28 14:04:13 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-06-30 09:19:02 -0700
commit8fe6fc11de4d6bfbffd8b961f5f1f24a338601d5 (patch)
treedad32e62eb08d71c621bfb573c57f89c2aae6814 /src/libsyntax/parse
parent2b3569a1b39097481877cf8fee538c78099c5acd (diff)
downloadrust-8fe6fc11de4d6bfbffd8b961f5f1f24a338601d5.tar.gz
rust-8fe6fc11de4d6bfbffd8b961f5f1f24a338601d5.zip
Change char::escape_{default,unicode} to take callbacks instead of allocating
strings
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/token.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 94147825da4..a50fa416832 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -16,7 +16,6 @@ use util::interner::StrInterner;
 use util::interner;
 
 use std::cast;
-use std::char;
 use std::cmp::Equiv;
 use std::local_data;
 use std::rand;
@@ -166,7 +165,12 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
 
       /* Literals */
       LIT_INT(c, ast::ty_char) => {
-        ~"'" + char::escape_default(c as char) + "'"
+          let mut res = ~"'";
+          do (c as char).escape_default |c| {
+              res.push_char(c);
+          }
+          res.push_char('\'');
+          res
       }
       LIT_INT(i, t) => {
           i.to_str() + ast_util::int_ty_to_str(t)