about summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-08-25 17:00:12 -0700
committerBrian Anderson <banderson@mozilla.com>2011-08-27 15:54:44 -0700
commit03119fe269de56e737562a9ee8d1bc47a9013eb4 (patch)
tree043711359bd61d152c33a01a720b1982d5ccb69e /src/comp/syntax
parent652332f9d44d0c3eb36c220a88ef37f7f875206f (diff)
downloadrust-03119fe269de56e737562a9ee8d1bc47a9013eb4.tar.gz
rust-03119fe269de56e737562a9ee8d1bc47a9013eb4.zip
Convert ast::ident to istr. Issue #855
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/ast.rs4
-rw-r--r--src/comp/syntax/ast_util.rs8
-rw-r--r--src/comp/syntax/ext/concat_idents.rs2
-rw-r--r--src/comp/syntax/ext/expand.rs5
-rw-r--r--src/comp/syntax/ext/fmt.rs20
-rw-r--r--src/comp/syntax/ext/ident_to_str.rs5
-rw-r--r--src/comp/syntax/ext/simplext.rs39
-rw-r--r--src/comp/syntax/parse/eval.rs30
-rw-r--r--src/comp/syntax/parse/parser.rs49
-rw-r--r--src/comp/syntax/print/pprust.rs104
10 files changed, 154 insertions, 112 deletions
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs
index d380fbecdb4..4009ff2bd4e 100644
--- a/src/comp/syntax/ast.rs
+++ b/src/comp/syntax/ast.rs
@@ -7,7 +7,7 @@ import codemap::filename;
 
 type spanned<T> = {node: T, span: span};
 
-type ident = str;
+type ident = istr;
 type identistr = istr;
 
 // Functions may or may not have names.
@@ -429,7 +429,7 @@ type native_mod =
 
 type variant_arg = {ty: @ty, id: node_id};
 
-type variant_ = {name: str, args: [variant_arg], id: node_id};
+type variant_ = {name: ident, args: [variant_arg], id: node_id};
 
 type variant = spanned<variant_>;
 
diff --git a/src/comp/syntax/ast_util.rs b/src/comp/syntax/ast_util.rs
index 687070da24f..72a633da928 100644
--- a/src/comp/syntax/ast_util.rs
+++ b/src/comp/syntax/ast_util.rs
@@ -16,7 +16,9 @@ fn dummy_sp() -> span { ret mk_sp(0u, 0u); }
 
 fn path_name(p: &path) -> str { path_name_i(p.node.idents) }
 
-fn path_name_i(idents: &[ident]) -> str { str::connect(idents, "::") }
+fn path_name_i(idents: &[ident]) -> str {
+    istr::to_estr(istr::connect(idents, ~"::"))
+}
 
 fn local_def(id: node_id) -> def_id { ret {crate: local_crate, node: id}; }
 
@@ -52,7 +54,7 @@ fn pat_id_map(pat: &@pat) -> pat_id_map {
     let map = std::map::new_str_hash::<node_id>();
     for each bound in pat_bindings(pat) {
         let name = alt bound.node { pat_bind(n) { n } };
-        map.insert(istr::from_estr(name), bound.id);
+        map.insert(name, bound.id);
     }
     ret map;
 }
@@ -156,7 +158,7 @@ fn is_exported(i: ident, m: _mod) -> bool {
     for vi: @ast::view_item in m.view_items {
         alt vi.node {
           ast::view_item_export(ids, _) {
-            for id in ids { if str::eq(i, id) { ret true; } }
+            for id in ids { if istr::eq(i, id) { ret true; } }
             count += 1u;
           }
           _ {/* fall through */ }
diff --git a/src/comp/syntax/ext/concat_idents.rs b/src/comp/syntax/ext/concat_idents.rs
index 466f55e60e6..0b88d09ec4d 100644
--- a/src/comp/syntax/ext/concat_idents.rs
+++ b/src/comp/syntax/ext/concat_idents.rs
@@ -11,7 +11,7 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
             cx.span_fatal(sp, "#concat_idents requires a vector argument .")
           }
         };
-    let res: ast::ident = "";
+    let res: ast::ident = ~"";
     for e: @ast::expr in args {
         res += expr_to_ident(cx, e, "expected an ident");
     }
diff --git a/src/comp/syntax/ext/expand.rs b/src/comp/syntax/ext/expand.rs
index 542b2805402..6a80b0b6cb2 100644
--- a/src/comp/syntax/ext/expand.rs
+++ b/src/comp/syntax/ext/expand.rs
@@ -24,10 +24,11 @@ fn expand_expr(exts: &hashmap<istr, syntax_extension>, cx: &ext_ctxt,
               mac_invoc(pth, args, body) {
                 assert (vec::len(pth.node.idents) > 0u);
                 let extname = pth.node.idents[0];
-                alt exts.find(istr::from_estr(extname)) {
+                alt exts.find(extname) {
                   none. {
                     cx.span_fatal(pth.span,
-                                  #fmt["macro undefined: '%s'", extname])
+                                  #fmt["macro undefined: '%s'",
+                                       istr::to_estr(extname)])
                   }
                   some(normal(ext)) {
                     let expanded = ext(cx, pth.span, args, body);
diff --git a/src/comp/syntax/ext/fmt.rs b/src/comp/syntax/ext/fmt.rs
index c70ea3234c4..093799714a7 100644
--- a/src/comp/syntax/ext/fmt.rs
+++ b/src/comp/syntax/ext/fmt.rs
@@ -100,16 +100,16 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
         let recexpr = ast::expr_rec(astfields, option::none::<@ast::expr>);
         ret @{id: cx.next_id(), node: recexpr, span: sp};
     }
-    fn make_path_vec(cx: &ext_ctxt, ident: str) -> [str] {
+    fn make_path_vec(cx: &ext_ctxt, ident: &ast::ident) -> [ast::ident] {
         fn compiling_std(cx: &ext_ctxt) -> bool {
             ret str::find(cx.crate_file_name(), "std.rc") >= 0;
         }
         if compiling_std(cx) {
-            ret ["extfmt", "rt", ident];
-        } else { ret ["std", "extfmt", "rt", ident]; }
+            ret [~"extfmt", ~"rt", ident];
+        } else { ret [~"std", ~"extfmt", ~"rt", ident]; }
     }
     fn make_rt_path_expr(cx: &ext_ctxt, sp: span, ident: str) -> @ast::expr {
-        let path = make_path_vec(cx, ident);
+        let path = make_path_vec(cx, istr::from_estr(ident));
         ret make_path_expr(cx, sp, path);
     }
     // Produces an AST expression that represents a RT::conv record,
@@ -145,7 +145,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
               }
               count_is(c) {
                 let count_lit = make_new_int(cx, sp, c);
-                let count_is_path = make_path_vec(cx, "count_is");
+                let count_is_path = make_path_vec(cx, ~"count_is");
                 let count_is_args = [count_lit];
                 ret make_call(cx, sp, count_is_path, count_is_args);
               }
@@ -171,10 +171,10 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
                          width_expr: @ast::expr, precision_expr: @ast::expr,
                          ty_expr: @ast::expr) -> @ast::expr {
             ret make_rec_expr(cx, sp,
-                              [{ident: "flags", ex: flags_expr},
-                               {ident: "width", ex: width_expr},
-                               {ident: "precision", ex: precision_expr},
-                               {ident: "ty", ex: ty_expr}]);
+                              [{ident: ~"flags", ex: flags_expr},
+                               {ident: ~"width", ex: width_expr},
+                               {ident: ~"precision", ex: precision_expr},
+                               {ident: ~"ty", ex: ty_expr}]);
         }
         let rt_conv_flags = make_flags(cx, sp, cnv.flags);
         let rt_conv_width = make_count(cx, sp, cnv.width);
@@ -185,7 +185,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
     }
     fn make_conv_call(cx: &ext_ctxt, sp: span, conv_type: str, cnv: &conv,
                       arg: @ast::expr) -> @ast::expr {
-        let fname = "conv_" + conv_type;
+        let fname = ~"conv_" + istr::from_estr(conv_type);
         let path = make_path_vec(cx, fname);
         let cnv_expr = make_rt_conv_expr(cx, sp, cnv);
         let args = [cnv_expr, arg];
diff --git a/src/comp/syntax/ext/ident_to_str.rs b/src/comp/syntax/ext/ident_to_str.rs
index 4eb381762fe..0664987e530 100644
--- a/src/comp/syntax/ext/ident_to_str.rs
+++ b/src/comp/syntax/ext/ident_to_str.rs
@@ -1,4 +1,5 @@
 import std::vec;
+import std::istr;
 import std::option;
 import base::*;
 import syntax::ast;
@@ -17,8 +18,8 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
     }
 
     ret make_new_lit(cx, sp,
-                     ast::lit_str(expr_to_ident(cx, args[0u],
-                                                "expected an ident"),
+                     ast::lit_str(istr::to_estr(expr_to_ident(cx, args[0u],
+                                                "expected an ident")),
                                   ast::sk_rc));
 
 }
diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs
index b0d7cd26020..94d814ae9c8 100644
--- a/src/comp/syntax/ext/simplext.rs
+++ b/src/comp/syntax/ext/simplext.rs
@@ -268,8 +268,8 @@ iter free_vars(b: &bindings, e: @expr) -> ident {
     let idents: hashmap<identistr, ()> = new_str_hash::<()>();
     fn mark_ident(i: &ident, _fld: ast_fold, b: &bindings,
                   idents: &hashmap<identistr, ()>) -> ident {
-        if b.contains_key(istr::from_estr(i)) {
-            idents.insert(istr::from_estr(i), ());
+        if b.contains_key(i) {
+            idents.insert(i, ());
         }
         ret i;
     }
@@ -281,7 +281,7 @@ iter free_vars(b: &bindings, e: @expr) -> ident {
     let f = make_fold(f_pre);
     f.fold_expr(e); // ignore result
     dummy_out(f);
-    for each id: identistr in idents.keys() { put istr::to_estr(id); }
+    for each id: identistr in idents.keys() { put id; }
 }
 
 
@@ -298,7 +298,7 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
             /* we need to walk over all the free vars in lockstep, except for
             the leaves, which are just duplicated */
             for each fv: ident in free_vars(b, repeat_me) {
-                let cur_pos = follow(b.get(istr::from_estr(fv)), idx_path);
+                let cur_pos = follow(b.get(fv), idx_path);
                 alt cur_pos {
                   leaf(_) { }
                   seq(ms, _) {
@@ -310,8 +310,10 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
                         let len = vec::len(*ms);
                         if old_len != len {
                             let msg =
-                                #fmt["'%s' occurs %u times, but ", fv, len] +
-                                    #fmt["'%s' occurs %u times", old_name,
+                                #fmt["'%s' occurs %u times, but ",
+                                     istr::to_estr(fv), len] +
+                                    #fmt["'%s' occurs %u times",
+                                         istr::to_estr(old_name),
                                          old_len];
                             cx.span_fatal(repeat_me.span, msg);
                         }
@@ -350,7 +352,7 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
 // substitute, in a position that's required to be an ident
 fn transcribe_ident(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
                     i: &ident, _fld: ast_fold) -> ident {
-    ret alt follow_for_trans(cx, b.find(istr::from_estr(i)), idx_path) {
+    ret alt follow_for_trans(cx, b.find(i), idx_path) {
           some(match_ident(a_id)) { a_id.node }
           some(m) { match_error(cx, m, "an identifier") }
           none. { i }
@@ -362,8 +364,7 @@ fn transcribe_path(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
                    p: &path_, _fld: ast_fold) -> path_ {
     // Don't substitute into qualified names.
     if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { ret p; }
-    ret alt follow_for_trans(cx, b.find(
-        istr::from_estr(p.idents[0])), idx_path) {
+    ret alt follow_for_trans(cx, b.find(p.idents[0]), idx_path) {
           some(match_ident(id)) {
             {global: false, idents: [id.node], types: []}
           }
@@ -384,8 +385,7 @@ fn transcribe_expr(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
             if vec::len(p.node.types) > 0u || vec::len(p.node.idents) != 1u {
                 e
             }
-            alt follow_for_trans(cx, b.find(
-                istr::from_estr(p.node.idents[0])), idx_path) {
+            alt follow_for_trans(cx, b.find(p.node.idents[0]), idx_path) {
               some(match_ident(id)) {
                 expr_path(respan(id.span,
                                  {global: false,
@@ -409,8 +409,7 @@ fn transcribe_type(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
           ast::ty_path(pth, _) {
             alt path_to_ident(pth) {
               some(id) {
-                alt follow_for_trans(cx, b.find(
-                    istr::from_estr(id)), idx_path) {
+                alt follow_for_trans(cx, b.find(id), idx_path) {
                   some(match_ty(ty)) { ty.node }
                   some(m) { match_error(cx, m, "a type") }
                   none. { orig(t, fld) }
@@ -433,7 +432,7 @@ fn transcribe_block(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
     ret alt block_to_ident(blk) {
           some(id) {
             alt follow_for_trans(cx, b.find(
-                istr::from_estr(id)), idx_path) {
+                id), idx_path) {
               some(match_block(new_blk)) { new_blk.node }
 
 
@@ -534,10 +533,10 @@ fn p_t_s_r_path(cx: &ext_ctxt, p: &path, s: &selector, b: &binders) {
                   _ { cx.bug("broken traversal in p_t_s_r") }
                 }
         }
-        if b.real_binders.contains_key(istr::from_estr(p_id)) {
+        if b.real_binders.contains_key(p_id) {
             cx.span_fatal(p.span, "duplicate binding identifier");
         }
-        b.real_binders.insert(istr::from_estr(p_id),
+        b.real_binders.insert(p_id,
                               compose_sels(s, bind select(cx, _)));
       }
       none. { }
@@ -584,7 +583,7 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) {
                 }
                 let final_step = bind select_pt_1(cx, _, select_pt_2);
                 b.real_binders.insert(
-                    istr::from_estr(id), compose_sels(s, final_step));
+                    id, compose_sels(s, final_step));
               }
               none. { no_des(cx, pth.span, "under `#<>`"); }
             }
@@ -604,7 +603,7 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) {
                     }
             }
             let final_step = bind select_pt_1(cx, _, select_pt_2);
-            b.real_binders.insert(istr::from_estr(id),
+            b.real_binders.insert(id,
                                   compose_sels(s, final_step));
           }
           none. { no_des(cx, blk.span, "under `#{}`"); }
@@ -700,7 +699,7 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
           }
         };
 
-    let macro_name: option::t<str> = none;
+    let macro_name: option::t<istr> = none;
     let clauses: [@clause] = [];
     for arg: @expr in args {
         alt arg.node {
@@ -760,7 +759,7 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
 
     ret {ident:
              alt macro_name {
-               some(id) { id }
+               some(id) { istr::to_estr(id) }
                none. {
                  cx.span_fatal(sp,
                                "macro definition must have " +
diff --git a/src/comp/syntax/parse/eval.rs b/src/comp/syntax/parse/eval.rs
index 18d9a04ebbf..ccb7f0cfde2 100644
--- a/src/comp/syntax/parse/eval.rs
+++ b/src/comp/syntax/parse/eval.rs
@@ -47,13 +47,18 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
                         items: &mutable [@ast::item]) {
     alt cdir.node {
       ast::cdir_src_mod(id, file_opt, attrs) {
-        let file_path = id + ".rs";
-        alt file_opt { some(f) { file_path = f; } none. { } }
+        let file_path = id + ~".rs";
+        alt file_opt {
+          some(f) {
+            file_path = istr::from_estr(f);
+          }
+          none. { }
+        }
         let full_path = if std::fs::path_is_absolute(
-            istr::from_estr(file_path)) {
-            file_path
+            file_path) {
+            istr::to_estr(file_path)
         } else {
-            prefix + istr::to_estr(std::fs::path_sep()) + file_path
+            prefix + istr::to_estr(std::fs::path_sep() + file_path)
         };
         if cx.mode == mode_depend { cx.deps += [full_path]; ret; }
         let p0 =
@@ -74,11 +79,18 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
       }
       ast::cdir_dir_mod(id, dir_opt, cdirs, attrs) {
         let path = id;
-        alt dir_opt { some(d) { path = d; } none. { } }
+        alt dir_opt {
+          some(d) {
+            path = istr::from_estr(d);
+          }
+          none. { }
+        }
         let full_path =
-            if std::fs::path_is_absolute(istr::from_estr(path)) {
-                path
-            } else { prefix + istr::to_estr(std::fs::path_sep()) + path };
+            if std::fs::path_is_absolute(path) {
+                istr::to_estr(path)
+            } else {
+            prefix + istr::to_estr(std::fs::path_sep() + path)
+        };
         let m0 = eval_crate_directives_to_mod(cx, cdirs, full_path);
         let i =
             @{ident: id,
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index c0beb8a32c3..85f809ef965 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -229,7 +229,10 @@ fn spanned<@T>(lo: uint, hi: uint, node: &T) -> spanned<T> {
 
 fn parse_ident(p: &parser) -> ast::ident {
     alt p.peek() {
-      token::IDENT(i, _) { p.bump(); ret p.get_str(i); }
+      token::IDENT(i, _) {
+        p.bump();
+        ret istr::from_estr(p.get_str(i));
+      }
       _ { p.fatal("expecting ident"); }
     }
 }
@@ -375,7 +378,8 @@ fn parse_ty_field(p: &parser) -> ast::ty_field {
 fn ident_index(p: &parser, args: &[ast::arg], i: &ast::ident) -> uint {
     let j = 0u;
     for a: ast::arg in args { if a.ident == i { ret j; } j += 1u; }
-    p.fatal("Unbound variable " + i + " in constraint arg");
+    p.fatal("Unbound variable " +
+            istr::to_estr(i) + " in constraint arg");
 }
 
 fn parse_type_constr_arg(p: &parser) -> @ast::ty_constr_arg {
@@ -742,7 +746,7 @@ fn parse_path(p: &parser) -> ast::path {
         alt p.peek() {
           token::IDENT(i, _) {
             hi = p.get_hi_pos();
-            ids += [p.get_str(i)];
+            ids += [istr::from_estr(p.get_str(i))];
             hi = p.get_hi_pos();
             p.bump();
             if p.peek() == token::MOD_SEP && p.look_ahead(1u) != token::LT {
@@ -1102,7 +1106,9 @@ fn parse_dot_or_call_expr_with(p: &parser, e: @ast::expr) -> @ast::expr {
               token::IDENT(i, _) {
                 hi = p.get_hi_pos();
                 p.bump();
-                e = mk_expr(p, lo, hi, ast::expr_field(e, p.get_str(i)));
+                e = mk_expr(p, lo, hi,
+                            ast::expr_field(
+                                e, istr::from_estr(p.get_str(i))));
               }
               t { unexpected(p, t); }
             }
@@ -1455,9 +1461,9 @@ fn parse_pat(p: &parser) -> @ast::pat {
                 p.bump();
                 subpat = parse_pat(p);
             } else {
-                if p.get_bad_expr_words()
-                    .contains_key(istr::from_estr(fieldname)) {
-                    p.fatal("found " + fieldname + " in binding position");
+                if p.get_bad_expr_words().contains_key(fieldname) {
+                    p.fatal("found " + istr::to_estr(fieldname)
+                            + " in binding position");
                 }
                 subpat =
                     @{id: p.get_id(),
@@ -1984,7 +1990,8 @@ fn parse_native_item(p: &parser, attrs: &[ast::attribute]) ->
     } else { unexpected(p, p.peek()); }
 }
 
-fn parse_native_mod_items(p: &parser, native_name: &str, abi: ast::native_abi,
+fn parse_native_mod_items(p: &parser, native_name: &str,
+                          abi: ast::native_abi,
                           first_item_attrs: &[ast::attribute]) ->
    ast::native_mod {
     // Shouldn't be any view items since we've already parsed an item attr
@@ -2027,7 +2034,7 @@ fn parse_item_native_mod(p: &parser, attrs: &[ast::attribute]) -> @ast::item {
     if p.peek() == token::EQ {
         expect(p, token::EQ);
         native_name = parse_str(p);
-    } else { native_name = id; }
+    } else { native_name = istr::to_estr(id); }
     expect(p, token::LBRACE);
     let more_attrs = parse_inner_attrs_and_next(p);
     let inner_attrs = more_attrs.inner;
@@ -2062,8 +2069,9 @@ fn parse_item_tag(p: &parser, attrs: &[ast::attribute]) -> @ast::item {
     let variants: [ast::variant] = [];
     // Newtype syntax
     if p.peek() == token::EQ {
-        if p.get_bad_expr_words().contains_key(istr::from_estr(id)) {
-            p.fatal("found " + id + " in tag constructor position");
+        if p.get_bad_expr_words().contains_key(id) {
+            p.fatal("found " + istr::to_estr(id)
+                    + " in tag constructor position");
         }
         p.bump();
         let ty = parse_ty(p, false);
@@ -2100,7 +2108,8 @@ fn parse_item_tag(p: &parser, attrs: &[ast::attribute]) -> @ast::item {
             }
             expect(p, token::SEMI);
             p.get_id();
-            let vr = {name: p.get_str(name), args: args, id: p.get_id()};
+            let vr = {name: istr::from_estr(p.get_str(name)),
+                      args: args, id: p.get_id()};
             variants += [spanned(vlo, vhi, vr)];
           }
           token::RBRACE. {/* empty */ }
@@ -2261,7 +2270,7 @@ fn parse_use(p: &parser) -> ast::view_item_ {
     ret ast::view_item_use(ident, metadata, p.get_id());
 }
 
-fn parse_rest_import_name(p: &parser, first: ast::ident,
+fn parse_rest_import_name(p: &parser, first: &ast::ident,
                           def_ident: option::t<ast::ident>) ->
    ast::view_item_ {
     let identifiers: [ast::ident] = [first];
@@ -2336,12 +2345,13 @@ fn parse_rest_import_name(p: &parser, first: ast::ident,
     }
 }
 
-fn parse_full_import_name(p: &parser, def_ident: ast::ident) ->
+fn parse_full_import_name(p: &parser, def_ident: &ast::ident) ->
    ast::view_item_ {
     alt p.peek() {
       token::IDENT(i, _) {
         p.bump();
-        ret parse_rest_import_name(p, p.get_str(i), some(def_ident));
+        ret parse_rest_import_name(
+            p, istr::from_estr(p.get_str(i)), some(def_ident));
       }
       _ { p.fatal("expecting an identifier"); }
     }
@@ -2354,9 +2364,12 @@ fn parse_import(p: &parser) -> ast::view_item_ {
         alt p.peek() {
           token::EQ. {
             p.bump();
-            ret parse_full_import_name(p, p.get_str(i));
+            ret parse_full_import_name(p, istr::from_estr(p.get_str(i)));
+          }
+          _ {
+            ret parse_rest_import_name(
+                p, istr::from_estr(p.get_str(i)), none);
           }
-          _ { ret parse_rest_import_name(p, p.get_str(i), none); }
         }
       }
       _ { p.fatal("expecting an identifier"); }
@@ -2436,7 +2449,7 @@ fn parse_crate_mod(p: &parser, _cfg: &ast::crate_cfg) -> @ast::crate {
                   config: p.get_cfg()});
 }
 
-fn parse_str(p: &parser) -> ast::ident {
+fn parse_str(p: &parser) -> str {
     alt p.peek() {
       token::LIT_STR(s) { p.bump(); ret p.get_str(s); }
       _ { fail; }
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index 9dcd56407f7..530b16a2037 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -107,7 +107,8 @@ fn path_to_str(p: &ast::path) -> str {
     be to_str(p, bind print_path(_, _, false));
 }
 
-fn fun_to_str(f: &ast::_fn, name: str, params: &[ast::ty_param]) -> str {
+fn fun_to_str(f: &ast::_fn, name: &ast::ident,
+              params: &[ast::ty_param]) -> str {
     let writer = io::string_writer();
     let s = rust_printer(writer.get_writer());
     print_fn(s, f.decl, f.proto, name, params, f.decl.constraints);
@@ -305,7 +306,7 @@ fn print_type(s: &ps, ty: &@ast::ty) {
         fn print_field(s: &ps, f: &ast::ty_field) {
             cbox(s, indent_unit);
             print_mutability(s, f.node.mt.mut);
-            word(s.s, f.node.ident);
+            word(s.s, istr::to_estr(f.node.ident));
             word_space(s, ":");
             print_type(s, f.node.mt.ty);
             end(s);
@@ -320,7 +321,7 @@ fn print_type(s: &ps, ty: &@ast::ty) {
         pclose(s);
       }
       ast::ty_fn(proto, inputs, output, cf, constrs) {
-        print_ty_fn(s, proto, none::<str>, inputs, output, cf, constrs);
+        print_ty_fn(s, proto, none::<istr>, inputs, output, cf, constrs);
       }
       ast::ty_obj(methods) {
         head(s, "obj");
@@ -356,7 +357,7 @@ fn print_native_item(s: &ps, item: &@ast::native_item) {
         ibox(s, indent_unit);
         ibox(s, 0u);
         word_nbsp(s, "type");
-        word(s.s, item.ident);
+        word(s.s, istr::to_estr(item.ident));
         end(s); // end the inner ibox
         word(s.s, ";");
         end(s); // end the outer ibox
@@ -388,7 +389,7 @@ fn print_item(s: &ps, item: &@ast::item) {
     alt item.node {
       ast::item_const(ty, expr) {
         head(s, "const");
-        word_space(s, item.ident + ":");
+        word_space(s, istr::to_estr(item.ident) + ":");
         print_type(s, ty);
         space(s.s);
         end(s); // end the head-ibox
@@ -407,7 +408,7 @@ fn print_item(s: &ps, item: &@ast::item) {
       }
       ast::item_mod(_mod) {
         head(s, "mod");
-        word_nbsp(s, item.ident);
+        word_nbsp(s, istr::to_estr(item.ident));
         bopen(s);
         print_mod(s, _mod, item.attrs);
         bclose(s, item.span);
@@ -424,8 +425,8 @@ fn print_item(s: &ps, item: &@ast::item) {
           ast::native_abi_x86stdcall. { word_nbsp(s, "\"x86stdcall\""); }
         }
         word_nbsp(s, "mod");
-        word_nbsp(s, item.ident);
-        if !str::eq(nmod.native_name, item.ident) {
+        word_nbsp(s, istr::to_estr(item.ident));
+        if !str::eq(nmod.native_name, istr::to_estr(item.ident)) {
             word_space(s, "=");
             print_string(s, nmod.native_name);
             nbsp(s);
@@ -438,7 +439,7 @@ fn print_item(s: &ps, item: &@ast::item) {
         ibox(s, indent_unit);
         ibox(s, 0u);
         word_nbsp(s, "type");
-        word(s.s, item.ident);
+        word(s.s, istr::to_estr(item.ident));
         print_type_params(s, params);
         end(s); // end the inner ibox
 
@@ -451,13 +452,13 @@ fn print_item(s: &ps, item: &@ast::item) {
       ast::item_tag(variants, params) {
         let newtype =
             vec::len(variants) == 1u &&
-                str::eq(item.ident, variants[0].node.name) &&
+                istr::eq(item.ident, variants[0].node.name) &&
                 vec::len(variants[0].node.args) == 1u;
         if newtype {
             ibox(s, indent_unit);
             word_space(s, "tag");
         } else { head(s, "tag"); }
-        word(s.s, item.ident);
+        word(s.s, istr::to_estr(item.ident));
         print_type_params(s, params);
         space(s.s);
         if newtype {
@@ -470,7 +471,7 @@ fn print_item(s: &ps, item: &@ast::item) {
             for v: ast::variant in variants {
                 space_if_not_bol(s);
                 maybe_print_comment(s, v.span.lo);
-                word(s.s, v.node.name);
+                word(s.s, istr::to_estr(v.node.name));
                 if vec::len(v.node.args) > 0u {
                     popen(s);
                     fn print_variant_arg(s: &ps, arg: &ast::variant_arg) {
@@ -487,13 +488,13 @@ fn print_item(s: &ps, item: &@ast::item) {
       }
       ast::item_obj(_obj, params, _) {
         head(s, "obj");
-        word(s.s, item.ident);
+        word(s.s, istr::to_estr(item.ident));
         print_type_params(s, params);
         popen(s);
         fn print_field(s: &ps, field: &ast::obj_field) {
             ibox(s, indent_unit);
             print_mutability(s, field.mut);
-            word_space(s, field.ident + ":");
+            word_space(s, istr::to_estr(field.ident) + ":");
             print_type(s, field.ty);
             end(s);
         }
@@ -515,10 +516,10 @@ fn print_item(s: &ps, item: &@ast::item) {
       }
       ast::item_res(dt, dt_id, tps, ct_id) {
         head(s, "resource");
-        word(s.s, item.ident);
+        word(s.s, istr::to_estr(item.ident));
         print_type_params(s, tps);
         popen(s);
-        word_space(s, dt.decl.inputs[0].ident + ":");
+        word_space(s, istr::to_estr(dt.decl.inputs[0].ident) + ":");
         print_type(s, dt.decl.inputs[0].ty);
         pclose(s);
         space(s.s);
@@ -786,7 +787,7 @@ fn print_expr(s: &ps, expr: &@ast::expr) {
         fn print_field(s: &ps, field: &ast::field) {
             ibox(s, indent_unit);
             if field.node.mut == ast::mut { word_nbsp(s, "mutable"); }
-            word(s.s, field.node.ident);
+            word(s.s, istr::to_estr(field.node.ident));
             word_space(s, ":");
             print_expr(s, field.node.expr);
             end(s);
@@ -981,7 +982,7 @@ fn print_expr(s: &ps, expr: &@ast::expr) {
       ast::expr_field(expr, id) {
         print_expr_parens_if_unary(s, expr);
         word(s.s, ".");
-        word(s.s, id);
+        word(s.s, istr::to_estr(id));
       }
       ast::expr_index(expr, index) {
         print_expr_parens_if_unary(s, expr);
@@ -1042,7 +1043,7 @@ fn print_expr(s: &ps, expr: &@ast::expr) {
         fn print_field(s: &ps, field: &ast::anon_obj_field) {
             ibox(s, indent_unit);
             print_mutability(s, field.mut);
-            word_space(s, field.ident + ":");
+            word_space(s, istr::to_estr(field.ident) + ":");
             print_type(s, field.ty);
             space(s.s);
             word_space(s, "=");
@@ -1131,7 +1132,9 @@ fn print_decl(s: &ps, decl: &@ast::decl) {
     }
 }
 
-fn print_ident(s: &ps, ident: &ast::ident) { word(s.s, ident); }
+fn print_ident(s: &ps, ident: &ast::ident) {
+    word(s.s, istr::to_estr(ident));
+}
 
 fn print_for_decl(s: &ps, loc: &@ast::local, coll: &@ast::expr) {
     print_local_decl(s, loc);
@@ -1144,9 +1147,9 @@ fn print_path(s: &ps, path: &ast::path, colons_before_params: bool) {
     maybe_print_comment(s, path.span.lo);
     if path.node.global { word(s.s, "::"); }
     let first = true;
-    for id: str in path.node.idents {
+    for id: ast::ident in path.node.idents {
         if first { first = false; } else { word(s.s, "::"); }
-        word(s.s, id);
+        word(s.s, istr::to_estr(id));
     }
     if vec::len(path.node.types) > 0u {
         if colons_before_params { word(s.s, "::"); }
@@ -1162,7 +1165,7 @@ fn print_pat(s: &ps, pat: &@ast::pat) {
     s.ann.pre(ann_node);
     alt pat.node {
       ast::pat_wild. { word(s.s, "_"); }
-      ast::pat_bind(id) { word(s.s, id); }
+      ast::pat_bind(id) { word(s.s, istr::to_estr(id)); }
       ast::pat_lit(lit) { print_literal(s, lit); }
       ast::pat_tag(path, args) {
         print_path(s, path, true);
@@ -1176,7 +1179,7 @@ fn print_pat(s: &ps, pat: &@ast::pat) {
         word(s.s, "{");
         fn print_field(s: &ps, f: &ast::field_pat) {
             cbox(s, indent_unit);
-            word(s.s, f.ident);
+            word(s.s, istr::to_estr(f.ident));
             word_space(s, ":");
             print_pat(s, f.pat);
             end(s);
@@ -1199,13 +1202,13 @@ fn print_pat(s: &ps, pat: &@ast::pat) {
     s.ann.post(ann_node);
 }
 
-fn print_fn(s: &ps, decl: ast::fn_decl, proto: ast::proto, name: str,
+fn print_fn(s: &ps, decl: ast::fn_decl, proto: ast::proto, name: &ast::ident,
             typarams: &[ast::ty_param], constrs: [@ast::constr]) {
     alt decl.purity {
       ast::impure_fn. { head(s, proto_to_str(proto)); }
       _ { head(s, "pure fn"); }
     }
-    word(s.s, name);
+    word(s.s, istr::to_estr(name));
     print_type_params(s, typarams);
     print_fn_args_and_ret(s, decl, constrs);
 }
@@ -1215,7 +1218,7 @@ fn print_fn_args_and_ret(s: &ps, decl: &ast::fn_decl,
     popen(s);
     fn print_arg(s: &ps, x: &ast::arg) {
         ibox(s, indent_unit);
-        word_space(s, x.ident + ":");
+        word_space(s, istr::to_estr(x.ident) + ":");
         print_alias(s, x.mode);
         print_type(s, x.ty);
         end(s);
@@ -1236,7 +1239,7 @@ fn print_fn_block_args(s: &ps, decl: &ast::fn_decl) {
     fn print_arg(s: &ps, x: &ast::arg) {
         ibox(s, indent_unit);
         print_alias(s, x.mode);
-        word(s.s, x.ident);
+        word(s.s, istr::to_estr(x.ident));
         end(s);
     }
     commasep(s, inconsistent, decl.inputs, print_arg);
@@ -1266,7 +1269,7 @@ fn print_type_params(s: &ps, params: &[ast::ty_param]) {
         word(s.s, "<");
         fn printParam(s: &ps, param: &ast::ty_param) {
             print_kind(s, param.kind);
-            word(s.s, param.ident);
+            word(s.s, istr::to_estr(param.ident));
         }
         commasep(s, inconsistent, params, printParam);
         word(s.s, ">");
@@ -1276,14 +1279,14 @@ fn print_type_params(s: &ps, params: &[ast::ty_param]) {
 fn print_meta_item(s: &ps, item: &@ast::meta_item) {
     ibox(s, indent_unit);
     alt item.node {
-      ast::meta_word(name) { word(s.s, name); }
+      ast::meta_word(name) { word(s.s, istr::to_estr(name)); }
       ast::meta_name_value(name, value) {
-        word_space(s, name);
+        word_space(s, istr::to_estr(name));
         word_space(s, "=");
         print_literal(s, @value);
       }
       ast::meta_list(name, items) {
-        word(s.s, name);
+        word(s.s, istr::to_estr(name));
         popen(s);
         commasep(s, consistent, items, print_meta_item);
         pclose(s);
@@ -1298,7 +1301,7 @@ fn print_view_item(s: &ps, item: &@ast::view_item) {
     alt item.node {
       ast::view_item_use(id, mta, _) {
         head(s, "use");
-        word(s.s, id);
+        word(s.s, istr::to_estr(id));
         if vec::len(mta) > 0u {
             popen(s);
             commasep(s, consistent, mta, print_meta_item);
@@ -1307,38 +1310,43 @@ fn print_view_item(s: &ps, item: &@ast::view_item) {
       }
       ast::view_item_import(id, ids, _) {
         head(s, "import");
-        if !str::eq(id, ids[vec::len(ids) - 1u]) {
-            word_space(s, id);
+        if !istr::eq(id, ids[vec::len(ids) - 1u]) {
+            word_space(s, istr::to_estr(id));
             word_space(s, "=");
         }
         let first = true;
-        for elt: str in ids {
+        for elt: ast::ident in ids {
             if first { first = false; } else { word(s.s, "::"); }
-            word(s.s, elt);
+            word(s.s, istr::to_estr(elt));
         }
       }
       ast::view_item_import_from(mod_path, idents, _) {
         head(s, "import");
-        for elt: str in mod_path { word(s.s, elt); word(s.s, "::"); }
+        for elt: ast::ident in mod_path {
+            word(s.s, istr::to_estr(elt)); word(s.s, "::");
+        }
         word(s.s, "{");
         commasep(s, inconsistent, idents,
                  fn (s: &ps, w: &ast::import_ident) {
-                     word(s.s, w.node.name)
+                     word(s.s, istr::to_estr(w.node.name))
                  });
         word(s.s, "}");
       }
       ast::view_item_import_glob(ids, _) {
         head(s, "import");
         let first = true;
-        for elt: str in ids {
+        for elt: ast::ident in ids {
             if first { first = false; } else { word(s.s, "::"); }
-            word(s.s, elt);
+            word(s.s, istr::to_estr(elt));
         }
         word(s.s, "::*");
       }
       ast::view_item_export(ids, _) {
         head(s, "export");
-        commasep(s, inconsistent, ids, fn (s: &ps, w: &str) { word(s.s, w) });
+        commasep(s, inconsistent, ids,
+                 fn (s: &ps, w: &ast::ident) {
+                     word(s.s, istr::to_estr(w))
+                 });
       }
     }
     word(s.s, ";");
@@ -1402,12 +1410,18 @@ fn print_mt(s: &ps, mt: &ast::mt) {
     print_type(s, mt.ty);
 }
 
-fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t<str>,
+fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t<ast::ident>,
                inputs: &[ast::ty_arg], output: &@ast::ty,
                cf: &ast::controlflow, constrs: &[@ast::constr]) {
     ibox(s, indent_unit);
     word(s.s, proto_to_str(proto));
-    alt id { some(id) { word(s.s, " "); word(s.s, id); } _ { } }
+    alt id {
+      some(id) {
+        word(s.s, " ");
+        word(s.s, istr::to_estr(id));
+      }
+      _ { }
+    }
     zerobreak(s.s);
     popen(s);
     fn print_arg(s: &ps, input: &ast::ty_arg) {
@@ -1680,7 +1694,7 @@ fn ast_ty_fn_constrs_str(constrs: &[@ast::constr]) -> str {
 }
 
 fn fn_arg_idx_to_str(decl: &ast::fn_decl, idx: &uint) -> str {
-    decl.inputs[idx].ident
+    istr::to_estr(decl.inputs[idx].ident)
 }
 
 fn ast_fn_constr_to_str(decl: &ast::fn_decl, c: &@ast::constr) -> str {