about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorMichael Sullivan <sully@msully.net>2012-07-13 22:57:48 -0700
committerMichael Sullivan <sully@msully.net>2012-07-14 01:03:43 -0700
commit92743dc2a6a14d042d4b278e4a4dde5ca198c886 (patch)
tree2626211c99906387257880f127f96fee66a0bb4e /src/libsyntax/parse
parent5c5065e8bdd1a7b28810fea4b940577ff17c112c (diff)
downloadrust-92743dc2a6a14d042d4b278e4a4dde5ca198c886.tar.gz
rust-92743dc2a6a14d042d4b278e4a4dde5ca198c886.zip
Move the world over to using the new style string literals and types. Closes #2907.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/attr.rs2
-rw-r--r--src/libsyntax/parse/comments.rs80
-rw-r--r--src/libsyntax/parse/common.rs46
-rw-r--r--src/libsyntax/parse/eval.rs22
-rw-r--r--src/libsyntax/parse/lexer.rs56
-rw-r--r--src/libsyntax/parse/parser.rs294
-rw-r--r--src/libsyntax/parse/token.rs160
7 files changed, 331 insertions, 329 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index b10a05d8ca4..995feff0b70 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -56,7 +56,7 @@ impl parser_attr for parser {
                 let attr = ::attr::mk_sugared_doc_attr(
                         *self.get_str(s), self.span.lo, self.span.hi);
                 if attr.node.style != ast::attr_outer {
-                  self.fatal("expected outer comment");
+                  self.fatal(~"expected outer comment");
                 }
                 attrs += ~[attr];
                 self.bump();
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index aa3e808f63e..737307bb648 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -18,28 +18,28 @@ enum cmnt_style {
     blank_line, // Just a manual blank line "\n\n", for layout
 }
 
-type cmnt = {style: cmnt_style, lines: ~[str], pos: uint};
+type cmnt = {style: cmnt_style, lines: ~[~str], pos: uint};
 
-fn is_doc_comment(s: str) -> bool {
-    s.starts_with("///") ||
-    s.starts_with("//!") ||
-    s.starts_with("/**") ||
-    s.starts_with("/*!")
+fn is_doc_comment(s: ~str) -> bool {
+    s.starts_with(~"///") ||
+    s.starts_with(~"//!") ||
+    s.starts_with(~"/**") ||
+    s.starts_with(~"/*!")
 }
 
-fn doc_comment_style(comment: str) -> ast::attr_style {
+fn doc_comment_style(comment: ~str) -> ast::attr_style {
     assert is_doc_comment(comment);
-    if comment.starts_with("//!") || comment.starts_with("/*!") {
+    if comment.starts_with(~"//!") || comment.starts_with(~"/*!") {
         ast::attr_inner
     } else {
         ast::attr_outer
     }
 }
 
-fn strip_doc_comment_decoration(comment: str) -> str {
+fn strip_doc_comment_decoration(comment: ~str) -> ~str {
 
     /// remove whitespace-only lines from the start/end of lines
-    fn vertical_trim(lines: ~[str]) -> ~[str] {
+    fn vertical_trim(lines: ~[~str]) -> ~[~str] {
         let mut i = 0u, j = lines.len();
         while i < j && lines[i].trim().is_empty() {
             i += 1u;
@@ -51,7 +51,7 @@ fn strip_doc_comment_decoration(comment: str) -> str {
     }
 
     // drop leftmost columns that contain only values in chars
-    fn block_trim(lines: ~[str], chars: str, max: option<uint>) -> ~[str] {
+    fn block_trim(lines: ~[~str], chars: ~str, max: option<uint>) -> ~[~str] {
 
         let mut i = max.get_default(uint::max_value);
         for lines.each |line| {
@@ -72,31 +72,31 @@ fn strip_doc_comment_decoration(comment: str) -> str {
         ret do lines.map |line| {
             let chars = str::chars(line);
             if i > chars.len() {
-                ""
+                ~""
             } else {
                 str::from_chars(chars.slice(i, chars.len()))
             }
         };
     }
 
-    if comment.starts_with("//") {
+    if comment.starts_with(~"//") {
         ret comment.slice(3u, comment.len()).trim();
     }
 
-    if comment.starts_with("/*") {
+    if comment.starts_with(~"/*") {
         let lines = str::lines_any(comment.slice(3u, comment.len() - 2u));
         let lines = vertical_trim(lines);
-        let lines = block_trim(lines, "\t ", none);
-        let lines = block_trim(lines, "*", some(1u));
-        let lines = block_trim(lines, "\t ", none);
-        ret str::connect(lines, "\n");
+        let lines = block_trim(lines, ~"\t ", none);
+        let lines = block_trim(lines, ~"*", some(1u));
+        let lines = block_trim(lines, ~"\t ", none);
+        ret str::connect(lines, ~"\n");
     }
 
-    fail "not a doc-comment: " + comment;
+    fail ~"not a doc-comment: " + comment;
 }
 
-fn read_to_eol(rdr: string_reader) -> str {
-    let mut val = "";
+fn read_to_eol(rdr: string_reader) -> ~str {
+    let mut val = ~"";
     while rdr.curr != '\n' && !is_eof(rdr) {
         str::push_char(val, rdr.curr);
         bump(rdr);
@@ -105,7 +105,7 @@ fn read_to_eol(rdr: string_reader) -> str {
     ret val;
 }
 
-fn read_one_line_comment(rdr: string_reader) -> str {
+fn read_one_line_comment(rdr: string_reader) -> ~str {
     let val = read_to_eol(rdr);
     assert ((val[0] == '/' as u8 && val[1] == '/' as u8) ||
             (val[0] == '#' as u8 && val[1] == '!' as u8));
@@ -120,7 +120,7 @@ fn consume_non_eol_whitespace(rdr: string_reader) {
 
 fn push_blank_line_comment(rdr: string_reader, &comments: ~[cmnt]) {
     #debug(">>> blank-line comment");
-    let v: ~[str] = ~[];
+    let v: ~[~str] = ~[];
     vec::push(comments, {style: blank_line, lines: v, pos: rdr.chpos});
 }
 
@@ -151,7 +151,7 @@ fn read_line_comments(rdr: string_reader, code_to_the_left: bool,
                                                         &comments: ~[cmnt]) {
     #debug(">>> line comments");
     let p = rdr.chpos;
-    let mut lines: ~[str] = ~[];
+    let mut lines: ~[~str] = ~[];
     while rdr.curr == '/' && nextch(rdr) == '/' {
         let line = read_one_line_comment(rdr);
         log(debug, line);
@@ -171,22 +171,22 @@ fn read_line_comments(rdr: string_reader, code_to_the_left: bool,
     }
 }
 
-fn all_whitespace(s: str, begin: uint, end: uint) -> bool {
+fn all_whitespace(s: ~str, begin: uint, end: uint) -> bool {
     let mut i: uint = begin;
     while i != end { if !is_whitespace(s[i] as char) { ret false; } i += 1u; }
     ret true;
 }
 
-fn trim_whitespace_prefix_and_push_line(&lines: ~[str],
-                                        s: str, col: uint) unsafe {
+fn trim_whitespace_prefix_and_push_line(&lines: ~[~str],
+                                        s: ~str, col: uint) unsafe {
     let mut s1;
     let len = str::len(s);
     if all_whitespace(s, 0u, uint::min(len, col)) {
         if col < len {
             s1 = str::slice(s, col, len);
-        } else { s1 = ""; }
+        } else { s1 = ~""; }
     } else { s1 = s; }
-    log(debug, "pushing line: " + s1);
+    log(debug, ~"pushing line: " + s1);
     vec::push(lines, s1);
 }
 
@@ -194,7 +194,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
                                                         &comments: ~[cmnt]) {
     #debug(">>> block comment");
     let p = rdr.chpos;
-    let mut lines: ~[str] = ~[];
+    let mut lines: ~[~str] = ~[];
     let mut col: uint = rdr.col;
     bump(rdr);
     bump(rdr);
@@ -211,27 +211,27 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
         ret;
     }
 
-    let mut curr_line = "/*";
+    let mut curr_line = ~"/*";
     let mut level: int = 1;
     while level > 0 {
         #debug("=== block comment level %d", level);
-        if is_eof(rdr) {(rdr as reader).fatal("unterminated block comment");}
+        if is_eof(rdr) {(rdr as reader).fatal(~"unterminated block comment");}
         if rdr.curr == '\n' {
             trim_whitespace_prefix_and_push_line(lines, curr_line, col);
-            curr_line = "";
+            curr_line = ~"";
             bump(rdr);
         } else {
             str::push_char(curr_line, rdr.curr);
             if rdr.curr == '/' && nextch(rdr) == '*' {
                 bump(rdr);
                 bump(rdr);
-                curr_line += "*";
+                curr_line += ~"*";
                 level += 1;
             } else {
                 if rdr.curr == '*' && nextch(rdr) == '/' {
                     bump(rdr);
                     bump(rdr);
-                    curr_line += "/";
+                    curr_line += ~"/";
                     level -= 1;
                 } else { bump(rdr); }
             }
@@ -268,14 +268,14 @@ fn consume_comment(rdr: string_reader, code_to_the_left: bool,
     #debug("<<< consume comment");
 }
 
-type lit = {lit: str, pos: uint};
+type lit = {lit: ~str, pos: uint};
 
 fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler,
-                                path: str,
+                                path: ~str,
                                 srdr: io::reader) ->
    {cmnts: ~[cmnt], lits: ~[lit]} {
     let src = @str::from_bytes(srdr.read_whole_stream());
-    let itr = @interner::mk::<@str/~>(
+    let itr = @interner::mk::<@~str>(
         |x| str::hash(*x),
         |x,y| str::eq(*x, *y)
     );
@@ -308,9 +308,9 @@ fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler,
         if token::is_lit(tok) {
             let s = get_str_from(rdr, bstart);
             vec::push(literals, {lit: s, pos: sp.lo});
-            log(debug, "tok lit: " + s);
+            log(debug, ~"tok lit: " + s);
         } else {
-            log(debug, "tok: " + token::to_str(*rdr.interner, tok));
+            log(debug, ~"tok: " + token::to_str(*rdr.interner, tok));
         }
         first_read = false;
     }
diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs
index 9e5f2ac2c9b..79ac3aeaf8b 100644
--- a/src/libsyntax/parse/common.rs
+++ b/src/libsyntax/parse/common.rs
@@ -18,7 +18,7 @@ fn seq_sep_none() -> seq_sep {
     ret {sep: option::none, trailing_sep_allowed: false};
 }
 
-fn token_to_str(reader: reader, ++token: token::token) -> str {
+fn token_to_str(reader: reader, ++token: token::token) -> ~str {
     token::to_str(*reader.interner(), token)
 }
 
@@ -28,23 +28,23 @@ impl parser_common for parser {
     fn unexpected_last(t: token::token) -> ! {
         self.span_fatal(
             copy self.last_span,
-            "unexpected token: `" + token_to_str(self.reader, t) + "`");
+            ~"unexpected token: `" + token_to_str(self.reader, t) + ~"`");
     }
 
     fn unexpected() -> ! {
-        self.fatal("unexpected token: `"
-                   + token_to_str(self.reader, self.token) + "`");
+        self.fatal(~"unexpected token: `"
+                   + token_to_str(self.reader, self.token) + ~"`");
     }
 
     fn expect(t: token::token) {
         if self.token == t {
             self.bump();
         } else {
-            let mut s: str = "expected `";
+            let mut s: ~str = ~"expected `";
             s += token_to_str(self.reader, t);
-            s += "` but found `";
+            s += ~"` but found `";
             s += token_to_str(self.reader, self.token);
-            self.fatal(s + "`");
+            self.fatal(s + ~"`");
         }
     }
 
@@ -52,10 +52,10 @@ impl parser_common for parser {
         alt copy self.token {
           token::IDENT(i, _) { self.bump(); ret self.get_str(i); }
           token::ACTUALLY(token::w_ident(*)) { self.bug(
-              "ident interpolation not converted to real token"); }
-          _ { self.fatal("expected ident, found `"
+              ~"ident interpolation not converted to real token"); }
+          _ { self.fatal(~"expected ident, found `"
                          + token_to_str(self.reader, self.token)
-                         + "`"); }
+                         + ~"`"); }
         }
     }
 
@@ -76,13 +76,13 @@ impl parser_common for parser {
     }
 
     // A sanity check that the word we are asking for is a known keyword
-    fn require_keyword(word: str) {
+    fn require_keyword(word: ~str) {
         if !self.keywords.contains_key(word) {
             self.bug(#fmt("unknown keyword: %s", word));
         }
     }
 
-    fn token_is_keyword(word: str, ++tok: token::token) -> bool {
+    fn token_is_keyword(word: ~str, ++tok: token::token) -> bool {
         self.require_keyword(word);
         alt tok {
           token::IDENT(sid, false) { str::eq(word, *self.get_str(sid)) }
@@ -90,7 +90,7 @@ impl parser_common for parser {
         }
     }
 
-    fn is_keyword(word: str) -> bool {
+    fn is_keyword(word: ~str) -> bool {
         self.token_is_keyword(word, self.token)
     }
 
@@ -103,7 +103,7 @@ impl parser_common for parser {
         }
     }
 
-    fn eat_keyword(word: str) -> bool {
+    fn eat_keyword(word: ~str) -> bool {
         self.require_keyword(word);
 
         // FIXME (#13042): this gratuitous use of @ is to
@@ -119,16 +119,16 @@ impl parser_common for parser {
         }
     }
 
-    fn expect_keyword(word: str) {
+    fn expect_keyword(word: ~str) {
         self.require_keyword(word);
         if !self.eat_keyword(word) {
-            self.fatal("expected `" + word + "`, found `" +
+            self.fatal(~"expected `" + word + ~"`, found `" +
                        token_to_str(self.reader, self.token) +
-                       "`");
+                       ~"`");
         }
     }
 
-    fn is_restricted_keyword(word: str) -> bool {
+    fn is_restricted_keyword(word: ~str) -> bool {
         self.restricted_keywords.contains_key(word)
     }
 
@@ -142,9 +142,9 @@ impl parser_common for parser {
         }
     }
 
-    fn check_restricted_keywords_(w: str) {
+    fn check_restricted_keywords_(w: ~str) {
         if self.is_restricted_keyword(w) {
-            self.fatal("found `" + w + "` in restricted position");
+            self.fatal(~"found `" + w + ~"` in restricted position");
         }
     }
 
@@ -154,11 +154,11 @@ impl parser_common for parser {
         } else if self.token == token::BINOP(token::SHR) {
             self.swap(token::GT, self.span.lo + 1u, self.span.hi);
         } else {
-            let mut s: str = "expected `";
+            let mut s: ~str = ~"expected `";
             s += token_to_str(self.reader, token::GT);
-            s += "`, found `";
+            s += ~"`, found `";
             s += token_to_str(self.reader, self.token);
-            s += "`";
+            s += ~"`";
             self.fatal(s);
         }
     }
diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs
index 54a2abf20c9..125dc809079 100644
--- a/src/libsyntax/parse/eval.rs
+++ b/src/libsyntax/parse/eval.rs
@@ -9,7 +9,7 @@ type ctx =
 
 fn eval_crate_directives(cx: ctx,
                          cdirs: ~[@ast::crate_directive],
-                         prefix: str,
+                         prefix: ~str,
                          &view_items: ~[@ast::view_item],
                          &items: ~[@ast::item]) {
     for cdirs.each |sub_cdir| {
@@ -18,11 +18,11 @@ fn eval_crate_directives(cx: ctx,
 }
 
 fn eval_crate_directives_to_mod(cx: ctx, cdirs: ~[@ast::crate_directive],
-                                prefix: str, suffix: option<str>)
+                                prefix: ~str, suffix: option<~str>)
     -> (ast::_mod, ~[ast::attribute]) {
     #debug("eval crate prefix: %s", prefix);
     #debug("eval crate suffix: %s",
-           option::get_default(suffix, "none"));
+           option::get_default(suffix, ~"none"));
     let (cview_items, citems, cattrs)
         = parse_companion_mod(cx, prefix, suffix);
     let mut view_items: ~[@ast::view_item] = ~[];
@@ -43,17 +43,17 @@ companion mod is a .rs file with the same name as the directory.
 We build the path to the companion mod by combining the prefix and the
 optional suffix then adding the .rs extension.
 */
-fn parse_companion_mod(cx: ctx, prefix: str, suffix: option<str>)
+fn parse_companion_mod(cx: ctx, prefix: ~str, suffix: option<~str>)
     -> (~[@ast::view_item], ~[@ast::item], ~[ast::attribute]) {
 
-    fn companion_file(+prefix: str, suffix: option<str>) -> str {
+    fn companion_file(+prefix: ~str, suffix: option<~str>) -> ~str {
         ret alt suffix {
           option::some(s) { path::connect(prefix, s) }
           option::none { prefix }
-        } + ".rs";
+        } + ~".rs";
     }
 
-    fn file_exists(path: str) -> bool {
+    fn file_exists(path: ~str) -> bool {
         // Crude, but there's no lib function for this and I'm not
         // up to writing it just now
         alt io::file_reader(path) {
@@ -78,8 +78,8 @@ fn parse_companion_mod(cx: ctx, prefix: str, suffix: option<str>)
     }
 }
 
-fn cdir_path_opt(id: ast::ident, attrs: ~[ast::attribute]) -> @str/~ {
-    alt ::attr::first_attr_value_str_by_name(attrs, "path") {
+fn cdir_path_opt(id: ast::ident, attrs: ~[ast::attribute]) -> @~str {
+    alt ::attr::first_attr_value_str_by_name(attrs, ~"path") {
       some(d) {
         ret d;
       }
@@ -87,12 +87,12 @@ fn cdir_path_opt(id: ast::ident, attrs: ~[ast::attribute]) -> @str/~ {
     }
 }
 
-fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
+fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: ~str,
                         &view_items: ~[@ast::view_item],
                         &items: ~[@ast::item]) {
     alt cdir.node {
       ast::cdir_src_mod(id, attrs) {
-        let file_path = cdir_path_opt(@(*id + ".rs"), attrs);
+        let file_path = cdir_path_opt(@(*id + ~".rs"), attrs);
         let full_path =
             if path::path_is_absolute(*file_path) {
                 *file_path
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index d7f9fc12840..7afdc301b02 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -12,22 +12,22 @@ export string_reader_as_reader, tt_reader_as_reader;
 iface reader {
     fn is_eof() -> bool;
     fn next_token() -> {tok: token::token, sp: span};
-    fn fatal(str) -> !;
+    fn fatal(~str) -> !;
     fn span_diag() -> span_handler;
-    fn interner() -> @interner<@str/~>;
+    fn interner() -> @interner<@~str>;
     fn peek() -> {tok: token::token, sp: span};
     fn dup() -> reader;
 }
 
 type string_reader = @{
     span_diagnostic: span_handler,
-    src: @str/~,
+    src: @~str,
     mut col: uint,
     mut pos: uint,
     mut curr: char,
     mut chpos: uint,
     filemap: codemap::filemap,
-    interner: @interner<@str/~>,
+    interner: @interner<@~str>,
     /* cached: */
     mut peek_tok: token::token,
     mut peek_span: span
@@ -35,7 +35,7 @@ type string_reader = @{
 
 fn new_string_reader(span_diagnostic: span_handler,
                      filemap: codemap::filemap,
-                     itr: @interner<@str/~>) -> string_reader {
+                     itr: @interner<@~str>) -> string_reader {
     let r = new_low_level_string_reader(span_diagnostic, filemap, itr);
     string_advance_token(r); /* fill in peek_* */
     ret r;
@@ -44,7 +44,7 @@ fn new_string_reader(span_diagnostic: span_handler,
 /* For comments.rs, which hackily pokes into 'pos' and 'curr' */
 fn new_low_level_string_reader(span_diagnostic: span_handler,
                                filemap: codemap::filemap,
-                               itr: @interner<@str/~>)
+                               itr: @interner<@~str>)
     -> string_reader {
     let r = @{span_diagnostic: span_diagnostic, src: filemap.src,
               mut col: 0u, mut pos: 0u, mut curr: -1 as char,
@@ -75,11 +75,11 @@ impl string_reader_as_reader of reader for string_reader {
         string_advance_token(self);
         ret ret_val;
     }
-    fn fatal(m: str) -> ! {
+    fn fatal(m: ~str) -> ! {
         self.span_diagnostic.span_fatal(copy self.peek_span, m)
     }
     fn span_diag() -> span_handler { self.span_diagnostic }
-    fn interner() -> @interner<@str/~> { self.interner }
+    fn interner() -> @interner<@~str> { self.interner }
     fn peek() -> {tok: token::token, sp: span} {
         {tok: self.peek_tok, sp: self.peek_span}
     }
@@ -97,11 +97,11 @@ impl tt_reader_as_reader of reader for tt_reader {
         }
         tt_next_token(self)
     }
-    fn fatal(m: str) -> ! {
+    fn fatal(m: ~str) -> ! {
         self.sp_diag.span_fatal(copy self.cur_span, m);
     }
     fn span_diag() -> span_handler { self.sp_diag }
-    fn interner() -> @interner<@str/~> { self.interner }
+    fn interner() -> @interner<@~str> { self.interner }
     fn peek() -> {tok: token::token, sp: span} {
         { tok: self.cur_tok, sp: self.cur_span }
     }
@@ -125,7 +125,7 @@ fn string_advance_token(&&r: string_reader) {
 
 }
 
-fn get_str_from(rdr: string_reader, start: uint) -> str unsafe {
+fn get_str_from(rdr: string_reader, start: uint) -> ~str unsafe {
     // I'm pretty skeptical about this subtraction. What if there's a
     // multi-byte character before the mark?
     ret str::slice(*rdr.src, start - 1u, rdr.pos - 1u);
@@ -211,7 +211,7 @@ fn consume_any_line_comment(rdr: string_reader)
             // line comments starting with "///" or "//!" are doc-comments
             if rdr.curr == '/' || rdr.curr == '!' {
                 let start_chpos = rdr.chpos - 2u;
-                let mut acc = "//";
+                let mut acc = ~"//";
                 while rdr.curr != '\n' && !is_eof(rdr) {
                     str::push_char(acc, rdr.curr);
                     bump(rdr);
@@ -250,15 +250,15 @@ fn consume_block_comment(rdr: string_reader)
     // block comments starting with "/**" or "/*!" are doc-comments
     if rdr.curr == '*' || rdr.curr == '!' {
         let start_chpos = rdr.chpos - 2u;
-        let mut acc = "/*";
+        let mut acc = ~"/*";
         while !(rdr.curr == '*' && nextch(rdr) == '/') && !is_eof(rdr) {
             str::push_char(acc, rdr.curr);
             bump(rdr);
         }
         if is_eof(rdr) {
-            rdr.fatal("unterminated block doc-comment");
+            rdr.fatal(~"unterminated block doc-comment");
         } else {
-            acc += "*/";
+            acc += ~"*/";
             bump(rdr);
             bump(rdr);
             ret some({
@@ -270,7 +270,7 @@ fn consume_block_comment(rdr: string_reader)
 
     let mut level: int = 1;
     while level > 0 {
-        if is_eof(rdr) { rdr.fatal("unterminated block comment"); }
+        if is_eof(rdr) { rdr.fatal(~"unterminated block comment"); }
         if rdr.curr == '/' && nextch(rdr) == '*' {
             bump(rdr);
             bump(rdr);
@@ -288,9 +288,9 @@ fn consume_block_comment(rdr: string_reader)
     ret consume_whitespace_and_comments(rdr);
 }
 
-fn scan_exponent(rdr: string_reader) -> option<str> {
+fn scan_exponent(rdr: string_reader) -> option<~str> {
     let mut c = rdr.curr;
-    let mut rslt = "";
+    let mut rslt = ~"";
     if c == 'e' || c == 'E' {
         str::push_char(rslt, c);
         bump(rdr);
@@ -302,12 +302,12 @@ fn scan_exponent(rdr: string_reader) -> option<str> {
         let exponent = scan_digits(rdr, 10u);
         if str::len(exponent) > 0u {
             ret some(rslt + exponent);
-        } else { rdr.fatal("scan_exponent: bad fp literal"); }
-    } else { ret none::<str>; }
+        } else { rdr.fatal(~"scan_exponent: bad fp literal"); }
+    } else { ret none::<~str>; }
 }
 
-fn scan_digits(rdr: string_reader, radix: uint) -> str {
-    let mut rslt = "";
+fn scan_digits(rdr: string_reader, radix: uint) -> ~str {
+    let mut rslt = ~"";
     loop {
         let c = rdr.curr;
         if c == '_' { bump(rdr); again; }
@@ -366,7 +366,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token {
                       else { either::right(ast::ty_u64) };
         }
         if str::len(num_str) == 0u {
-            rdr.fatal("no valid digits found for number");
+            rdr.fatal(~"no valid digits found for number");
         }
         let parsed = option::get(u64::from_str_radix(num_str, base as u64));
         alt tp {
@@ -379,7 +379,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token {
         is_float = true;
         bump(rdr);
         let dec_part = scan_digits(rdr, 10u);
-        num_str += "." + dec_part;
+        num_str += ~"." + dec_part;
     }
     alt scan_exponent(rdr) {
       some(s) {
@@ -414,7 +414,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token {
                              ast::ty_f);
     } else {
         if str::len(num_str) == 0u {
-            rdr.fatal("no valid digits found for number");
+            rdr.fatal(~"no valid digits found for number");
         }
         let parsed = option::get(u64::from_str_radix(num_str, base as u64));
 
@@ -440,7 +440,7 @@ fn scan_numeric_escape(rdr: string_reader, n_hex_digits: uint) -> char {
 }
 
 fn next_token_inner(rdr: string_reader) -> token::token {
-    let mut accum_str = "";
+    let mut accum_str = ~"";
     let mut c = rdr.curr;
     if (c >= 'a' && c <= 'z')
         || (c >= 'A' && c <= 'Z')
@@ -455,7 +455,7 @@ fn next_token_inner(rdr: string_reader) -> token::token {
             bump(rdr);
             c = rdr.curr;
         }
-        if str::eq(accum_str, "_") { ret token::UNDERSCORE; }
+        if str::eq(accum_str, ~"_") { ret token::UNDERSCORE; }
         let is_mod_name = c == ':' && nextch(rdr) == ':';
 
         // FIXME: perform NFKC normalization here. (Issue #2253)
@@ -578,7 +578,7 @@ fn next_token_inner(rdr: string_reader) -> token::token {
             }
         }
         if rdr.curr != '\'' {
-            rdr.fatal("unterminated character constant");
+            rdr.fatal(~"unterminated character constant");
         }
         bump(rdr); // advance curr past token
         ret token::LIT_INT(c2 as i64, ast::ty_char);
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 784044a2df0..1c34894eb98 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -160,8 +160,8 @@ class parser {
     let mut restriction: restriction;
     let mut quote_depth: uint; // not (yet) related to the quasiquoter
     let reader: reader;
-    let keywords: hashmap<str, ()>;
-    let restricted_keywords: hashmap<str, ()>;
+    let keywords: hashmap<~str, ()>;
+    let restricted_keywords: hashmap<~str, ()>;
 
     new(sess: parse_sess, cfg: ast::crate_cfg, +rdr: reader, ftype: file_type)
     {
@@ -220,29 +220,29 @@ class parser {
         }
         ret copy self.buffer[(self.buffer_start + dist - 1) & 3].tok;
     }
-    fn fatal(m: str) -> ! {
+    fn fatal(m: ~str) -> ! {
         self.sess.span_diagnostic.span_fatal(copy self.span, m)
     }
-    fn span_fatal(sp: span, m: str) -> ! {
+    fn span_fatal(sp: span, m: ~str) -> ! {
         self.sess.span_diagnostic.span_fatal(sp, m)
     }
-    fn bug(m: str) -> ! {
+    fn bug(m: ~str) -> ! {
         self.sess.span_diagnostic.span_bug(copy self.span, m)
     }
-    fn warn(m: str) {
+    fn warn(m: ~str) {
         self.sess.span_diagnostic.span_warn(copy self.span, m)
     }
-    fn get_str(i: token::str_num) -> @str/~ {
+    fn get_str(i: token::str_num) -> @~str {
         interner::get(*self.reader.interner(), i)
     }
     fn get_id() -> node_id { next_node_id(self.sess) }
 
     fn parse_ty_fn(purity: ast::purity) -> ty_ {
-        let proto = if self.eat_keyword("extern") {
-            self.expect_keyword("fn");
+        let proto = if self.eat_keyword(~"extern") {
+            self.expect_keyword(~"fn");
             ast::proto_bare
         } else {
-            self.expect_keyword("fn");
+            self.expect_keyword(~"fn");
             self.parse_fn_ty_proto()
         };
         ty_fn(proto, self.parse_ty_fn_decl(purity))
@@ -259,7 +259,7 @@ class parser {
                 let name = self.parse_value_ident();
                 p.bump();
                 name
-            } else { @""/~ };
+            } else { @~"" };
 
             {mode: mode, ty: p.parse_ty(false), ident: name,
              id: p.get_id()}
@@ -317,8 +317,8 @@ class parser {
                            vis: vis})
               }
 
-              _ { p.fatal("expected `;` or `}` but found `" +
-                          token_to_str(p.reader, p.token) + "`");
+              _ { p.fatal(~"expected `;` or `}` but found `" +
+                          token_to_str(p.reader, p.token) + ~"`");
                 }
             }
         }
@@ -345,7 +345,7 @@ class parser {
     fn ident_index(args: ~[arg], i: ident) -> uint {
         let mut j = 0u;
         for args.each |a| { if a.ident == i { ret j; } j += 1u; }
-        self.fatal("unbound variable `" + *i + "` in constraint arg");
+        self.fatal(~"unbound variable `" + *i + ~"` in constraint arg");
     }
 
     fn parse_type_constr_arg() -> @ty_constr_arg {
@@ -431,7 +431,7 @@ class parser {
         }
     }
 
-    fn region_from_name(s: option<@str/~>) -> @region {
+    fn region_from_name(s: option<@~str>) -> @region {
         let r = alt s {
           some (string) { re_named(string) }
           none { re_anon }
@@ -538,19 +538,19 @@ class parser {
             let region = self.parse_region_with_sep();
             let mt = self.parse_mt();
             ty_rptr(region, mt)
-        } else if self.eat_keyword("pure") {
+        } else if self.eat_keyword(~"pure") {
             self.parse_ty_fn(ast::pure_fn)
-        } else if self.eat_keyword("unsafe") {
+        } else if self.eat_keyword(~"unsafe") {
             self.parse_ty_fn(ast::unsafe_fn)
-        } else if self.is_keyword("fn") {
+        } else if self.is_keyword(~"fn") {
             self.parse_ty_fn(ast::impure_fn)
-        } else if self.eat_keyword("extern") {
-            self.expect_keyword("fn");
+        } else if self.eat_keyword(~"extern") {
+            self.expect_keyword(~"fn");
             ty_fn(proto_bare, self.parse_ty_fn_decl(ast::impure_fn))
         } else if self.token == token::MOD_SEP || is_ident(self.token) {
             let path = self.parse_path_with_tps(colons_before_params);
             ty_path(path, self.get_id())
-        } else { self.fatal("expected type"); };
+        } else { self.fatal(~"expected type"); };
 
         let sp = mk_sp(lo, self.last_span.hi);
         ret @{id: self.get_id(),
@@ -588,9 +588,9 @@ class parser {
             @{id: p.get_id(), is_move: is_move, name: ident, span: sp}
         }
 
-        if self.eat_keyword("move") {
+        if self.eat_keyword(~"move") {
             either::right(parse_capture_item(self, true))
-        } else if self.eat_keyword("copy") {
+        } else if self.eat_keyword(~"copy") {
             either::right(parse_capture_item(self, false))
         } else {
             parse_arg_fn(self)
@@ -642,7 +642,7 @@ class parser {
                 some(mac_aq(mk_sp(lo,hi), e))
               }
               _ {
-                self.fatal("expected `(` or unsuffixed integer literal");
+                self.fatal(~"expected `(` or unsuffixed integer literal");
               }
             }
           }
@@ -692,9 +692,9 @@ class parser {
 
     fn parse_lit() -> lit {
         let lo = self.span.lo;
-        let lit = if self.eat_keyword("true") {
+        let lit = if self.eat_keyword(~"true") {
             lit_bool(true)
-        } else if self.eat_keyword("false") {
+        } else if self.eat_keyword(~"false") {
             lit_bool(false)
         } else {
             let tok = self.token;
@@ -753,7 +753,7 @@ class parser {
             // Hack: avoid parsing vstores like /@ and /~.  This is painful
             // because the notation for region bounds and the notation for
             // vstores is... um... the same.  I guess that's my fault.  This
-            // is still not ideal as for str/& we end up parsing more than we
+            // is still not ideal as for &str we end up parsing more than we
             // ought to and have to sort it out later.
             if self.token == token::BINOP(token::SLASH)
                 && self.look_ahead(1u) == token::BINOP(token::AND) {
@@ -781,9 +781,9 @@ class parser {
     }
 
     fn parse_mutability() -> mutability {
-        if self.eat_keyword("mut") {
+        if self.eat_keyword(~"mut") {
             m_mutbl
-        } else if self.eat_keyword("const") {
+        } else if self.eat_keyword(~"const") {
             m_const
         } else {
             m_imm
@@ -866,7 +866,7 @@ class parser {
             ret self.mk_pexpr(lo, hi, expr_tup(es));
         } else if self.token == token::LBRACE {
             self.bump();
-            if self.is_keyword("mut") ||
+            if self.is_keyword(~"mut") ||
                 is_plain_ident(self.token)
                 && self.look_ahead(1u) == token::COLON {
                 let mut fields = ~[self.parse_field(token::COLON)];
@@ -874,11 +874,11 @@ class parser {
                 while self.token != token::RBRACE {
                     // optional comma before "with"
                     if self.token == token::COMMA
-                        && self.token_is_keyword("with",
+                        && self.token_is_keyword(~"with",
                                                  self.look_ahead(1u)) {
                         self.bump();
                     }
-                    if self.eat_keyword("with") {
+                    if self.eat_keyword(~"with") {
                         base = some(self.parse_expr()); break;
                     }
                     self.expect(token::COMMA);
@@ -897,36 +897,38 @@ class parser {
             }
         } else if token::is_bar(self.token) {
             ret pexpr(self.parse_lambda_expr());
-        } else if self.eat_keyword("new") {
+        } else if self.eat_keyword(~"new") {
             self.expect(token::LPAREN);
             let r = self.parse_expr();
             self.expect(token::RPAREN);
             let v = self.parse_expr();
             ret self.mk_pexpr(lo, self.span.hi,
                               expr_new(r, self.get_id(), v));
-        } else if self.eat_keyword("if") {
+        } else if self.eat_keyword(~"if") {
             ret pexpr(self.parse_if_expr());
-        } else if self.eat_keyword("for") {
-            ret pexpr(self.parse_sugary_call_expr("for", expr_loop_body));
-        } else if self.eat_keyword("do") {
-            ret pexpr(self.parse_sugary_call_expr("do", expr_do_body));
-        } else if self.eat_keyword("while") {
+        } else if self.eat_keyword(~"for") {
+            ret pexpr(self.parse_sugary_call_expr(~"for", expr_loop_body));
+        } else if self.eat_keyword(~"do") {
+            ret pexpr(self.parse_sugary_call_expr(~"do", expr_do_body));
+        } else if self.eat_keyword(~"while") {
             ret pexpr(self.parse_while_expr());
-        } else if self.eat_keyword("loop") {
+        } else if self.eat_keyword(~"loop") {
             ret pexpr(self.parse_loop_expr());
-        } else if self.eat_keyword("alt") {
+        } else if self.eat_keyword(~"alt") {
             ret pexpr(self.parse_alt_expr());
-        } else if self.eat_keyword("fn") {
+        } else if self.eat_keyword(~"fn") {
             let proto = self.parse_fn_ty_proto();
             alt proto {
-              proto_bare { self.fatal("fn expr are deprecated, use fn@"); }
-              proto_any { self.fatal("fn* cannot be used in an expression"); }
+              proto_bare { self.fatal(~"fn expr are deprecated, use fn@"); }
+              proto_any {
+                self.fatal(~"fn* cannot be used in an expression");
+              }
               _ { /* fallthrough */ }
             }
             ret pexpr(self.parse_fn_expr(proto));
-        } else if self.eat_keyword("unchecked") {
+        } else if self.eat_keyword(~"unchecked") {
             ret pexpr(self.parse_block_expr(lo, unchecked_blk));
-        } else if self.eat_keyword("unsafe") {
+        } else if self.eat_keyword(~"unsafe") {
             ret pexpr(self.parse_block_expr(lo, unsafe_blk));
         } else if self.token == token::LBRACKET {
             self.bump();
@@ -958,13 +960,13 @@ class parser {
             let ex_ext = self.parse_syntax_ext();
             hi = ex_ext.span.hi;
             ex = ex_ext.node;
-        } else if self.eat_keyword("fail") {
+        } else if self.eat_keyword(~"fail") {
             if can_begin_expr(self.token) {
                 let e = self.parse_expr();
                 hi = e.span.hi;
                 ex = expr_fail(some(e));
             } else { ex = expr_fail(none); }
-        } else if self.eat_keyword("log") {
+        } else if self.eat_keyword(~"log") {
             self.expect(token::LPAREN);
             let lvl = self.parse_expr();
             self.expect(token::COMMA);
@@ -972,18 +974,18 @@ class parser {
             ex = expr_log(2, lvl, e);
             hi = self.span.hi;
             self.expect(token::RPAREN);
-        } else if self.eat_keyword("assert") {
+        } else if self.eat_keyword(~"assert") {
             let e = self.parse_expr();
             ex = expr_assert(e);
             hi = e.span.hi;
-        } else if self.eat_keyword("check") {
+        } else if self.eat_keyword(~"check") {
             /* Should be a predicate (pure boolean function) applied to
             arguments that are all either slot variables or literals.
             but the typechecker enforces that. */
             let e = self.parse_expr();
             hi = e.span.hi;
             ex = expr_check(checked_expr, e);
-        } else if self.eat_keyword("claim") {
+        } else if self.eat_keyword(~"claim") {
             /* Same rules as check, except that if check-claims
             is enabled (a command-line flag), then the parser turns
             claims into check */
@@ -991,25 +993,25 @@ class parser {
             let e = self.parse_expr();
             hi = e.span.hi;
             ex = expr_check(claimed_expr, e);
-        } else if self.eat_keyword("ret") {
+        } else if self.eat_keyword(~"ret") {
             if can_begin_expr(self.token) {
                 let e = self.parse_expr();
                 hi = e.span.hi;
                 ex = expr_ret(some(e));
             } else { ex = expr_ret(none); }
-        } else if self.eat_keyword("break") {
+        } else if self.eat_keyword(~"break") {
             ex = expr_break;
             hi = self.span.hi;
-        } else if self.eat_keyword("again") {
+        } else if self.eat_keyword(~"again") {
             ex = expr_again;
             hi = self.span.hi;
-        } else if self.eat_keyword("copy") {
+        } else if self.eat_keyword(~"copy") {
             let e = self.parse_expr();
             ex = expr_copy(e);
             hi = e.span.hi;
         } else if self.token == token::MOD_SEP ||
-            is_ident(self.token) && !self.is_keyword("true") &&
-            !self.is_keyword("false") {
+            is_ident(self.token) && !self.is_keyword(~"true") &&
+            !self.is_keyword(~"false") {
             let pth = self.parse_path_with_tps(true);
 
             /* `!`, as an operator, is prefix, so we know this isn't that */
@@ -1065,7 +1067,7 @@ class parser {
     fn parse_syntax_ext_naked(lo: uint) -> @expr {
         alt self.token {
           token::IDENT(_, _) {}
-          _ { self.fatal("expected a syntax expander name"); }
+          _ { self.fatal(~"expected a syntax expander name"); }
         }
         let pth = self.parse_path_without_tps();
         //temporary for a backwards-compatible cycle:
@@ -1093,7 +1095,7 @@ class parser {
                 alt (self.token) {
                   token::LBRACE {depth += 1u;}
                   token::RBRACE {depth -= 1u;}
-                  token::EOF {self.fatal("unexpected EOF in macro body");}
+                  token::EOF {self.fatal(~"unexpected EOF in macro body");}
                   _ {}
                 }
                 self.bump();
@@ -1181,7 +1183,7 @@ class parser {
                 self.bump();
                 ret (some(sep), zerok);
             } else {
-                self.fatal("expected `*` or `+`");
+                self.fatal(~"expected `*` or `+`");
             }
         }
     }
@@ -1201,11 +1203,11 @@ class parser {
             alt p.token {
               token::RPAREN | token::RBRACE | token::RBRACKET
               if !delim_ok {
-                p.fatal("incorrect close delimiter: `"
-                           + token_to_str(p.reader, p.token) + "`");
+                p.fatal(~"incorrect close delimiter: `"
+                           + token_to_str(p.reader, p.token) + ~"`");
               }
               token::EOF {
-                p.fatal("file ended in the middle of a macro invocation");
+                p.fatal(~"file ended in the middle of a macro invocation");
               }
               /* we ought to allow different depths of unquotation */
               token::DOLLAR if p.quote_depth > 0u {
@@ -1280,7 +1282,7 @@ class parser {
                 let ms = self.parse_matcher_subseq(name_idx, token::LPAREN,
                                                    token::RPAREN);
                 if ms.len() == 0u {
-                    self.fatal("repetition body must be nonempty");
+                    self.fatal(~"repetition body must be nonempty");
                 }
                 let (sep, zerok) = self.parse_sep_and_zerok();
                 mtc_rep(ms, sep, zerok)
@@ -1411,7 +1413,7 @@ class parser {
           }
           _ {}
         }
-        if as_prec > min_prec && self.eat_keyword("as") {
+        if as_prec > min_prec && self.eat_keyword(~"as") {
             let rhs = self.parse_ty(true);
             let _as =
                 self.mk_pexpr(lhs.span.lo, rhs.span.hi, expr_cast(lhs, rhs));
@@ -1474,7 +1476,7 @@ class parser {
         let thn = self.parse_block();
         let mut els: option<@expr> = none;
         let mut hi = thn.span.hi;
-        if self.eat_keyword("else") {
+        if self.eat_keyword(~"else") {
             let elexpr = self.parse_else_expr();
             els = some(elexpr);
             hi = elexpr.span.hi;
@@ -1483,7 +1485,7 @@ class parser {
     }
 
     fn parse_if_expr() -> @expr {
-        if self.eat_keyword("check") {
+        if self.eat_keyword(~"check") {
             let q = self.parse_if_expr_1();
             ret self.mk_expr(q.lo, q.hi,
                              expr_if_check(q.cond, q.then, q.els));
@@ -1560,7 +1562,7 @@ class parser {
     }
 
     fn parse_else_expr() -> @expr {
-        if self.eat_keyword("if") {
+        if self.eat_keyword(~"if") {
             ret self.parse_if_expr();
         } else {
             let blk = self.parse_block();
@@ -1568,7 +1570,7 @@ class parser {
         }
     }
 
-    fn parse_sugary_call_expr(keyword: str,
+    fn parse_sugary_call_expr(keyword: ~str,
                               ctor: fn(+@expr) -> expr_) -> @expr {
         let lo = self.last_span;
         // Parse the callee `foo` in
@@ -1625,7 +1627,7 @@ class parser {
 
     fn parse_alt_expr() -> @expr {
         let lo = self.last_span.lo;
-        let mode = if self.eat_keyword("check") { alt_check }
+        let mode = if self.eat_keyword(~"check") { alt_check }
         else { alt_exhaustive };
         let discriminant = self.parse_expr();
         self.expect(token::LBRACE);
@@ -1633,7 +1635,7 @@ class parser {
         while self.token != token::RBRACE {
             let pats = self.parse_pats();
             let mut guard = none;
-            if self.eat_keyword("if") { guard = some(self.parse_expr()); }
+            if self.eat_keyword(~"if") { guard = some(self.parse_expr()); }
             if self.token == token::FAT_ARROW { self.bump(); }
             let blk = self.parse_block();
             vec::push(arms, {pats: pats, guard: guard, body: blk});
@@ -1736,9 +1738,9 @@ class parser {
                 if self.token == token::UNDERSCORE {
                     self.bump();
                     if self.token != token::RBRACE {
-                        self.fatal("expected `}`, found `" +
+                        self.fatal(~"expected `}`, found `" +
                                    token_to_str(self.reader, self.token) +
-                                   "`");
+                                   ~"`");
                     }
                     etc = true;
                     break;
@@ -1789,10 +1791,10 @@ class parser {
             }
           }
           tok {
-            if !is_ident(tok) || self.is_keyword("true")
-                || self.is_keyword("false") {
+            if !is_ident(tok) || self.is_keyword(~"true")
+                || self.is_keyword(~"false") {
                 let val = self.parse_expr_res(RESTRICT_NO_BAR_OP);
-                if self.eat_keyword("to") {
+                if self.eat_keyword(~"to") {
                     let end = self.parse_expr_res(RESTRICT_NO_BAR_OP);
                     hi = end.span.hi;
                     pat = pat_range(val, end);
@@ -1866,7 +1868,7 @@ class parser {
     }
 
     fn parse_let() -> @decl {
-        let is_mutbl = self.eat_keyword("mut");
+        let is_mutbl = self.eat_keyword(~"mut");
         let lo = self.span.lo;
         let mut locals = ~[self.parse_local(is_mutbl, true)];
         while self.eat(token::COMMA) {
@@ -1879,11 +1881,11 @@ class parser {
     fn parse_instance_var(pr: visibility) -> @class_member {
         let mut is_mutbl = class_immutable;
         let lo = self.span.lo;
-        if self.eat_keyword("mut") {
+        if self.eat_keyword(~"mut") {
             is_mutbl = class_mutable;
         }
         if !is_plain_ident(self.token) {
-            self.fatal("expected ident");
+            self.fatal(~"expected ident");
         }
         let name = self.parse_ident();
         self.expect(token::COLON);
@@ -1896,14 +1898,14 @@ class parser {
         fn check_expected_item(p: parser, current_attrs: ~[attribute]) {
             // If we have attributes then we should have an item
             if vec::is_not_empty(current_attrs) {
-                p.fatal("expected item");
+                p.fatal(~"expected item");
             }
         }
 
         let lo = self.span.lo;
-        if self.is_keyword("let") {
+        if self.is_keyword(~"let") {
             check_expected_item(self, first_item_attrs);
-            self.expect_keyword("let");
+            self.expect_keyword(~"let");
             let decl = self.parse_let();
             ret @spanned(lo, decl.span.hi, stmt_decl(decl, self.get_id()));
         } else {
@@ -1936,7 +1938,7 @@ class parser {
     }
 
     fn expr_is_complete(e: pexpr) -> bool {
-        log(debug, ("expr_is_complete", self.restriction,
+        log(debug, (~"expr_is_complete", self.restriction,
                     print::pprust::expr_to_str(*e),
                     classify::expr_requires_semi_to_be_stmt(*e)));
         ret self.restriction == RESTRICT_STMT_EXPR &&
@@ -1962,12 +1964,12 @@ class parser {
         }
 
         let lo = self.span.lo;
-        if self.eat_keyword("unchecked") {
+        if self.eat_keyword(~"unchecked") {
             self.expect(token::LBRACE);
             let {inner, next} = maybe_parse_inner_attrs_and_next(self,
                                                                  parse_attrs);
             ret (inner, self.parse_block_tail_(lo, unchecked_blk, next));
-        } else if self.eat_keyword("unsafe") {
+        } else if self.eat_keyword(~"unsafe") {
             self.expect(token::LBRACE);
             let {inner, next} = maybe_parse_inner_attrs_and_next(self,
                                                                  parse_attrs);
@@ -2004,7 +2006,7 @@ class parser {
         let mut initial_attrs = attrs_remaining;
 
         if self.token == token::RBRACE && !vec::is_empty(initial_attrs) {
-            self.fatal("expected item");
+            self.fatal(~"expected item");
         }
 
         while self.token != token::RBRACE {
@@ -2028,9 +2030,9 @@ class parser {
                       }
                       t {
                         if classify::stmt_ends_with_semi(*stmt) {
-                            self.fatal("expected `;` or `}` after expression \
-                                        but found `"
-                                       + token_to_str(self.reader, t) + "`");
+                            self.fatal(~"expected `;` or `}` after \
+                                         expression but found `"
+                                       + token_to_str(self.reader, t) + ~"`");
                         }
                         vec::push(stmts, stmt);
                       }
@@ -2060,9 +2062,9 @@ class parser {
         let ident = self.parse_ident();
         if self.eat(token::COLON) {
             while self.token != token::COMMA && self.token != token::GT {
-                if self.eat_keyword("send") { push(bounds, bound_send); }
-                else if self.eat_keyword("copy") { push(bounds, bound_copy) }
-                else if self.eat_keyword("const") {
+                if self.eat_keyword(~"send") { push(bounds, bound_send); }
+                else if self.eat_keyword(~"copy") { push(bounds, bound_copy) }
+                else if self.eat_keyword(~"const") {
                     push(bounds, bound_const)
                 }
                 else { push(bounds, bound_trait(self.parse_ty(false))); }
@@ -2156,16 +2158,16 @@ class parser {
     fn parse_method_name() -> ident {
         alt copy self.token {
           token::BINOP(op) { self.bump(); @token::binop_to_str(op) }
-          token::NOT { self.bump(); @"!"/~ }
+          token::NOT { self.bump(); @~"!" }
           token::LBRACKET {
             self.bump();
             self.expect(token::RBRACKET);
-            @"[]"/~
+            @~"[]"
           }
           _ {
             let id = self.parse_value_ident();
-            if id == @"unary"/~ && self.eat(token::BINOP(token::MINUS)) {
-                @"unary-"/~
+            if id == @~"unary" && self.eat(token::BINOP(token::MINUS)) {
+                @~"unary-"
             }
             else { id }
           }
@@ -2208,7 +2210,7 @@ class parser {
                 self.parse_region_param();
                 (none, self.parse_ty_params())
             }
-            else if self.is_keyword("of") {
+            else if self.is_keyword(~"of") {
                 (none, ~[])
             } else {
                 let id = self.parse_ident();
@@ -2216,7 +2218,7 @@ class parser {
                 (some(id), self.parse_ty_params())
             }
         };
-        let ifce = if self.eat_keyword("of") {
+        let ifce = if self.eat_keyword(~"of") {
             let path = self.parse_path_with_tps(false);
             if option::is_none(ident) {
                 ident = some(vec::last(path.idents));
@@ -2225,9 +2227,9 @@ class parser {
         } else { none };
         let ident = alt ident {
           some(name) { name }
-          none { self.expect_keyword("of"); fail; }
+          none { self.expect_keyword(~"of"); fail; }
         };
-        self.expect_keyword("for");
+        self.expect_keyword(~"for");
         let ty = self.parse_ty(false);
         let mut meths = ~[];
         self.expect(token::LBRACE);
@@ -2310,14 +2312,14 @@ class parser {
           Is it strange for the parser to check this?
           */
           none {
-            self.fatal("class with no constructor");
+            self.fatal(~"class with no constructor");
           }
         }
     }
 
     fn parse_single_class_item(vis: visibility)
         -> @class_member {
-        if self.eat_keyword("let") {
+        if self.eat_keyword(~"let") {
             let a_var = self.parse_instance_var(vis);
             self.expect(token::SEMI);
             ret a_var;
@@ -2348,15 +2350,15 @@ class parser {
 
     fn parse_class_item(class_name_with_tps: @path)
         -> class_contents {
-        if self.eat_keyword("new") {
+        if self.eat_keyword(~"new") {
             // result type is always the type of the class
             ret self.parse_ctor(ty_path(class_name_with_tps,
                                         self.get_id()));
         }
-        else if self.eat_keyword("drop") {
+        else if self.eat_keyword(~"drop") {
             ret self.parse_dtor();
         }
-        else if self.eat_keyword("priv") {
+        else if self.eat_keyword(~"priv") {
             self.expect(token::LBRACE);
             let mut results = ~[];
             while self.token != token::RBRACE {
@@ -2372,8 +2374,8 @@ class parser {
     }
 
     fn parse_visibility(def: visibility) -> visibility {
-        if self.eat_keyword("pub") { public }
-        else if self.eat_keyword("priv") { private }
+        if self.eat_keyword(~"pub") { public }
+        else if self.eat_keyword(~"priv") { private }
         else { def }
     }
 
@@ -2395,8 +2397,8 @@ class parser {
             alt self.parse_item(attrs, vis) {
               some(i) { vec::push(items, i); }
               _ {
-                self.fatal("expected item but found `" +
-                           token_to_str(self.reader, self.token) + "`");
+                self.fatal(~"expected item but found `" +
+                           token_to_str(self.reader, self.token) + ~"`");
               }
             }
             #debug["parse_mod_items: attrs=%?", attrs];
@@ -2404,7 +2406,7 @@ class parser {
 
         if first && attrs_remaining.len() > 0u {
             // We parsed attributes for the first item but didn't find it
-            self.fatal("expected item");
+            self.fatal(~"expected item");
         }
 
         ret {view_items: view_items, items: items};
@@ -2444,12 +2446,12 @@ class parser {
     }
 
     fn parse_fn_purity() -> purity {
-        if self.eat_keyword("fn") { impure_fn }
-        else if self.eat_keyword("pure") {
-            self.expect_keyword("fn");
+        if self.eat_keyword(~"fn") { impure_fn }
+        else if self.eat_keyword(~"pure") {
+            self.expect_keyword(~"fn");
             pure_fn
-        } else if self.eat_keyword("unsafe") {
-            self.expect_keyword("fn");
+        } else if self.eat_keyword(~"unsafe") {
+            self.expect_keyword(~"fn");
             unsafe_fn
         }
         else { self.unexpected(); }
@@ -2478,7 +2480,7 @@ class parser {
     }
 
     fn parse_item_foreign_mod() -> item_info {
-        self.expect_keyword("mod");
+        self.expect_keyword(~"mod");
         let id = self.parse_ident();
         self.expect(token::LBRACE);
         let more_attrs = self.parse_inner_attrs_and_next();
@@ -2563,7 +2565,7 @@ class parser {
         }
         self.expect(token::RBRACE);
         if (have_disr && !all_nullary) {
-            self.fatal("discriminator values can only be used with a c-like \
+            self.fatal(~"discriminator values can only be used with a c-like \
                         enum");
         }
         (id, item_enum(variants, ty_params), none)
@@ -2603,39 +2605,39 @@ class parser {
     fn parse_item(+attrs: ~[attribute], vis: visibility)
         -> option<@item> {
         let lo = self.span.lo;
-        let (ident, item_, extra_attrs) = if self.eat_keyword("const") {
+        let (ident, item_, extra_attrs) = if self.eat_keyword(~"const") {
             self.parse_item_const()
-        } else if self.is_keyword("fn") &&
+        } else if self.is_keyword(~"fn") &&
             !self.fn_expr_lookahead(self.look_ahead(1u)) {
             self.bump();
             self.parse_item_fn(impure_fn)
-        } else if self.eat_keyword("pure") {
-            self.expect_keyword("fn");
+        } else if self.eat_keyword(~"pure") {
+            self.expect_keyword(~"fn");
             self.parse_item_fn(pure_fn)
-        } else if self.is_keyword("unsafe")
+        } else if self.is_keyword(~"unsafe")
             && self.look_ahead(1u) != token::LBRACE {
             self.bump();
-            self.expect_keyword("fn");
+            self.expect_keyword(~"fn");
             self.parse_item_fn(unsafe_fn)
-        } else if self.eat_keyword("extern") {
-            if self.eat_keyword("fn") {
+        } else if self.eat_keyword(~"extern") {
+            if self.eat_keyword(~"fn") {
                 self.parse_item_fn(extern_fn)
             } else {
                 self.parse_item_foreign_mod()
             }
-        } else if self.eat_keyword("mod") {
+        } else if self.eat_keyword(~"mod") {
             self.parse_item_mod()
-        } else if self.eat_keyword("type") {
+        } else if self.eat_keyword(~"type") {
             self.parse_item_type()
-        } else if self.eat_keyword("enum") {
+        } else if self.eat_keyword(~"enum") {
             self.parse_item_enum(vis)
-        } else if self.eat_keyword("iface") {
+        } else if self.eat_keyword(~"iface") {
             self.parse_item_trait()
-        } else if self.eat_keyword("trait") {
+        } else if self.eat_keyword(~"trait") {
             self.parse_item_trait()
-        } else if self.eat_keyword("impl") {
+        } else if self.eat_keyword(~"impl") {
             self.parse_item_impl()
-        } else if self.eat_keyword("class") {
+        } else if self.eat_keyword(~"class") {
             self.parse_item_class()
         } else if !self.is_any_keyword(copy self.token)
             && self.look_ahead(1) == token::NOT
@@ -2747,21 +2749,21 @@ class parser {
     }
 
     fn is_view_item() -> bool {
-        let tok = if !self.is_keyword("pub") && !self.is_keyword("priv") {
+        let tok = if !self.is_keyword(~"pub") && !self.is_keyword(~"priv") {
             self.token
         } else { self.look_ahead(1u) };
-        self.token_is_keyword("use", tok)
-            || self.token_is_keyword("import", tok)
-            || self.token_is_keyword("export", tok)
+        self.token_is_keyword(~"use", tok)
+            || self.token_is_keyword(~"import", tok)
+            || self.token_is_keyword(~"export", tok)
     }
 
     fn parse_view_item(+attrs: ~[attribute]) -> @view_item {
         let lo = self.span.lo, vis = self.parse_visibility(private);
-        let node = if self.eat_keyword("use") {
+        let node = if self.eat_keyword(~"use") {
             self.parse_use()
-        } else if self.eat_keyword("import") {
+        } else if self.eat_keyword(~"import") {
             view_item_import(self.parse_view_paths())
-        } else if self.eat_keyword("export") {
+        } else if self.eat_keyword(~"export") {
             view_item_export(self.parse_view_paths())
         } else { fail; };
         self.expect(token::SEMI);
@@ -2775,7 +2777,7 @@ class parser {
         let mut attrs = vec::append(first_item_attrs,
                                     self.parse_outer_attributes());
         let mut items = ~[];
-        while if only_imports { self.is_keyword("import") }
+        while if only_imports { self.is_keyword(~"import") }
         else { self.is_view_item() } {
             vec::push(items, self.parse_view_item(attrs));
             attrs = self.parse_outer_attributes();
@@ -2796,11 +2798,11 @@ class parser {
                       config: self.cfg});
     }
 
-    fn parse_str() -> @str/~ {
+    fn parse_str() -> @~str {
         alt copy self.token {
           token::LIT_STR(s) { self.bump(); self.get_str(s) }
           _ {
-            self.fatal("expected string literal")
+            self.fatal(~"expected string literal")
           }
         }
     }
@@ -2821,8 +2823,8 @@ class parser {
         let expect_mod = vec::len(outer_attrs) > 0u;
 
         let lo = self.span.lo;
-        if expect_mod || self.is_keyword("mod") {
-            self.expect_keyword("mod");
+        if expect_mod || self.is_keyword(~"mod") {
+            self.expect_keyword(~"mod");
             let id = self.parse_ident();
             alt self.token {
               // mod x = "foo.rs";
@@ -2849,7 +2851,7 @@ class parser {
         } else if self.is_view_item() {
             let vi = self.parse_view_item(outer_attrs);
             ret spanned(lo, vi.span.hi, cdir_view_item(vi));
-        } else { ret self.fatal("expected crate directive"); }
+        } else { ret self.fatal(~"expected crate directive"); }
     }
 
     fn parse_crate_directives(term: token::token,
@@ -2860,7 +2862,7 @@ class parser {
         // accept seeing the terminator next, so if we do see it then fail the
         // same way parse_crate_directive would
         if vec::len(first_outer_attr) > 0u && self.token == term {
-            self.expect_keyword("mod");
+            self.expect_keyword(~"mod");
         }
 
         let mut cdirs: ~[@crate_directive] = ~[];
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 2c7b14cfe11..7db5af23266 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -100,61 +100,61 @@ enum whole_nt {
     w_mtcs(~[ast::matcher])
 }
 
-fn binop_to_str(o: binop) -> str {
+fn binop_to_str(o: binop) -> ~str {
     alt o {
-      PLUS { "+" }
-      MINUS { "-" }
-      STAR { "*" }
-      SLASH { "/" }
-      PERCENT { "%" }
-      CARET { "^" }
-      AND { "&" }
-      OR { "|" }
-      SHL { "<<" }
-      SHR { ">>" }
+      PLUS { ~"+" }
+      MINUS { ~"-" }
+      STAR { ~"*" }
+      SLASH { ~"/" }
+      PERCENT { ~"%" }
+      CARET { ~"^" }
+      AND { ~"&" }
+      OR { ~"|" }
+      SHL { ~"<<" }
+      SHR { ~">>" }
     }
 }
 
-fn to_str(in: interner<@str/~>, t: token) -> str {
+fn to_str(in: interner<@~str>, t: token) -> ~str {
     alt t {
-      EQ { "=" }
-      LT { "<" }
-      LE { "<=" }
-      EQEQ { "==" }
-      NE { "!=" }
-      GE { ">=" }
-      GT { ">" }
-      NOT { "!" }
-      TILDE { "~" }
-      OROR { "||" }
-      ANDAND { "&&" }
+      EQ { ~"=" }
+      LT { ~"<" }
+      LE { ~"<=" }
+      EQEQ { ~"==" }
+      NE { ~"!=" }
+      GE { ~">=" }
+      GT { ~">" }
+      NOT { ~"!" }
+      TILDE { ~"~" }
+      OROR { ~"||" }
+      ANDAND { ~"&&" }
       BINOP(op) { binop_to_str(op) }
-      BINOPEQ(op) { binop_to_str(op) + "=" }
+      BINOPEQ(op) { binop_to_str(op) + ~"=" }
 
       /* Structural symbols */
-      AT { "@" }
-      DOT { "." }
-      ELLIPSIS { "..." }
-      COMMA { "," }
-      SEMI { "" }
-      COLON { ":" }
-      MOD_SEP { "::" }
-      RARROW { "->" }
-      LARROW { "<-" }
-      DARROW { "<->" }
-      FAT_ARROW { "=>" }
-      LPAREN { "(" }
-      RPAREN { ")" }
-      LBRACKET { "[" }
-      RBRACKET { "]" }
-      LBRACE { "{" }
-      RBRACE { "}" }
-      POUND { "#" }
-      DOLLAR { "$" }
+      AT { ~"@" }
+      DOT { ~"." }
+      ELLIPSIS { ~"..." }
+      COMMA { ~"," }
+      SEMI { ~"" }
+      COLON { ~":" }
+      MOD_SEP { ~"::" }
+      RARROW { ~"->" }
+      LARROW { ~"<-" }
+      DARROW { ~"<->" }
+      FAT_ARROW { ~"=>" }
+      LPAREN { ~"(" }
+      RPAREN { ~")" }
+      LBRACKET { ~"[" }
+      RBRACKET { ~"]" }
+      LBRACE { ~"{" }
+      RBRACE { ~"}" }
+      POUND { ~"#" }
+      DOLLAR { ~"$" }
 
       /* Literals */
       LIT_INT(c, ast::ty_char) {
-        "'" + char::escape_default(c as char) + "'"
+        ~"'" + char::escape_default(c as char) + ~"'"
       }
       LIT_INT(i, t) {
         int::to_str(i as int, 10u) + ast_util::int_ty_to_str(t)
@@ -170,28 +170,28 @@ fn to_str(in: interner<@str/~>, t: token) -> str {
             ast_util::float_ty_to_str(t)
       }
       LIT_STR(s) {
-        "\""
+        ~"\""
             + str::escape_default(*interner::get(in, s))
-            + "\""
+            + ~"\""
       }
 
       /* Name components */
       IDENT(s, _) {
         *interner::get(in, s)
       }
-      UNDERSCORE { "_" }
+      UNDERSCORE { ~"_" }
 
       /* Other */
       DOC_COMMENT(s) { *interner::get(in, s) }
-      EOF { "<eof>" }
+      EOF { ~"<eof>" }
       ACTUALLY(w_nt) {
-        "an interpolated " +
+        ~"an interpolated " +
             alt w_nt {
-              w_item(*) { "item" } w_block(*) { "block" }
-              w_stmt(*) { "statement" } w_pat(*) { "pattern" }
-              w_expr(*) { "expression" } w_ty(*) { "type" }
-              w_ident(*) { "identifier" } w_path(*) { "path" }
-              w_tt(*) { "tt" } w_mtcs(*) { "matcher sequence" }
+              w_item(*) { ~"item" } w_block(*) { ~"block" }
+              w_stmt(*) { ~"statement" } w_pat(*) { ~"pattern" }
+              w_expr(*) { ~"expression" } w_ty(*) { ~"type" }
+              w_ident(*) { ~"identifier" } w_path(*) { ~"path" }
+              w_tt(*) { ~"tt" } w_mtcs(*) { ~"matcher sequence" }
             }
       }
     }
@@ -256,7 +256,7 @@ pure fn is_bar(t: token) -> bool {
  * the grammar is unambiguous. Restricted keywords may not appear
  * in positions that might otherwise contain _value identifiers_.
  */
-fn keyword_table() -> hashmap<str, ()> {
+fn keyword_table() -> hashmap<~str, ()> {
     let keywords = str_hash();
     for contextual_keyword_table().each_key |word| {
         keywords.insert(word, ());
@@ -268,18 +268,18 @@ fn keyword_table() -> hashmap<str, ()> {
 }
 
 /// Keywords that may be used as identifiers
-fn contextual_keyword_table() -> hashmap<str, ()> {
+fn contextual_keyword_table() -> hashmap<~str, ()> {
     let words = str_hash();
     let keys = ~[
-        "as",
-        "else",
-        "move",
-        "of",
-        "priv", "pub",
-        "self", "send", "static",
-        "to",
-        "use",
-        "with"
+        ~"as",
+        ~"else",
+        ~"move",
+        ~"of",
+        ~"priv", ~"pub",
+        ~"self", ~"send", ~"static",
+        ~"to",
+        ~"use",
+        ~"with"
     ];
     for keys.each |word| {
         words.insert(word, ());
@@ -301,23 +301,23 @@ fn contextual_keyword_table() -> hashmap<str, ()> {
  * * `true` or `false` as identifiers would always be shadowed by
  *   the boolean constants
  */
-fn restricted_keyword_table() -> hashmap<str, ()> {
+fn restricted_keyword_table() -> hashmap<~str, ()> {
     let words = str_hash();
     let keys = ~[
-        "alt", "again", "assert",
-        "break",
-        "check", "claim", "class", "const", "copy",
-        "do", "drop",
-        "else", "enum", "export", "extern",
-        "fail", "false", "fn", "for",
-        "if", "iface", "impl", "import",
-        "let", "log", "loop",
-        "mod", "mut",
-        "new",
-        "pure", "ret",
-        "true", "trait", "type",
-        "unchecked", "unsafe",
-        "while"
+        ~"alt", ~"again", ~"assert",
+        ~"break",
+        ~"check", ~"claim", ~"class", ~"const", ~"copy",
+        ~"do", ~"drop",
+        ~"else", ~"enum", ~"export", ~"extern",
+        ~"fail", ~"false", ~"fn", ~"for",
+        ~"if", ~"iface", ~"impl", ~"import",
+        ~"let", ~"log", ~"loop",
+        ~"mod", ~"mut",
+        ~"new",
+        ~"pure", ~"ret",
+        ~"true", ~"trait", ~"type",
+        ~"unchecked", ~"unsafe",
+        ~"while"
     ];
     for keys.each |word| {
         words.insert(word, ());