From 03119fe269de56e737562a9ee8d1bc47a9013eb4 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 25 Aug 2011 17:00:12 -0700 Subject: [PATCH] Convert ast::ident to istr. Issue #855 --- src/comp/back/link.rs | 8 +- src/comp/driver/rustc.rs | 22 ++-- src/comp/front/attr.rs | 12 +- src/comp/front/config.rs | 4 +- src/comp/front/test.rs | 28 ++--- src/comp/metadata/creader.rs | 26 +++-- src/comp/metadata/decoder.rs | 8 +- src/comp/metadata/encoder.rs | 70 ++++++------ src/comp/metadata/tydecode.rs | 13 ++- src/comp/metadata/tyencode.rs | 4 +- src/comp/middle/alias.rs | 3 +- src/comp/middle/ast_map.rs | 6 +- src/comp/middle/resolve.rs | 62 ++++++----- src/comp/middle/trans.rs | 30 +++-- src/comp/middle/trans_alt.rs | 6 +- src/comp/middle/trans_objects.rs | 21 ++-- src/comp/middle/tstate/auxiliary.rs | 19 ++-- src/comp/middle/tstate/ck.rs | 17 ++- src/comp/middle/tstate/collect_locals.rs | 12 +- src/comp/middle/tstate/pre_post_conditions.rs | 11 +- src/comp/middle/ty.rs | 25 +++-- src/comp/middle/typeck.rs | 22 ++-- src/comp/syntax/ast.rs | 4 +- src/comp/syntax/ast_util.rs | 8 +- src/comp/syntax/ext/concat_idents.rs | 2 +- src/comp/syntax/ext/expand.rs | 5 +- src/comp/syntax/ext/fmt.rs | 20 ++-- src/comp/syntax/ext/ident_to_str.rs | 5 +- src/comp/syntax/ext/simplext.rs | 39 ++++--- src/comp/syntax/parse/eval.rs | 30 +++-- src/comp/syntax/parse/parser.rs | 49 ++++++--- src/comp/syntax/print/pprust.rs | 104 ++++++++++-------- src/comp/util/common.rs | 8 +- src/comp/util/ppaux.rs | 16 ++- 34 files changed, 403 insertions(+), 316 deletions(-) diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index 2a4da724fba3..3f09374309cb 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -299,12 +299,12 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str, let linkage_metas = attr::find_linkage_metas(c.node.attrs); attr::require_unique_names(sess, linkage_metas); for meta: @ast::meta_item in linkage_metas { - if attr::get_meta_item_name(meta) == "name" { + if attr::get_meta_item_name(meta) == ~"name" { alt attr::get_meta_item_value_str(meta) { some(v) { name = some(v); } none. { cmh_items += [meta]; } } - } else if attr::get_meta_item_name(meta) == "vers" { + } else if attr::get_meta_item_name(meta) == ~"vers" { alt attr::get_meta_item_value_str(meta) { some(v) { vers = some(v); } none. { cmh_items += [meta]; } @@ -334,11 +334,11 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str, let m = m_; alt m.node { ast::meta_name_value(key, value) { - sha.input_str(len_and_str(istr::from_estr(key))); + sha.input_str(len_and_str(key)); sha.input_str(len_and_str_lit(value)); } ast::meta_word(name) { - sha.input_str(len_and_str(istr::from_estr(name))); + sha.input_str(len_and_str(name)); } ast::meta_list(_, _) { // FIXME (#607): Implement this diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 204b6ef0d514..18ff05596240 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -55,11 +55,11 @@ fn default_configuration(sess: session::session, argv0: str, input: str) -> let mk = attr::mk_name_value_item_str; ret [ // Target bindings. - mk("target_os", istr::to_estr(std::os::target_os())), - mk("target_arch", "x86"), - mk("target_libc", libc), + mk(~"target_os", istr::to_estr(std::os::target_os())), + mk(~"target_arch", "x86"), + mk(~"target_libc", libc), // Build bindings. - mk("build_compiler", argv0), mk("build_input", input)]; + mk(~"build_compiler", argv0), mk(~"build_input", input)]; } fn build_configuration(sess: session::session, argv0: str, input: str) -> @@ -71,9 +71,9 @@ fn build_configuration(sess: session::session, argv0: str, input: str) -> // If the user wants a test runner, then add the test cfg let gen_cfg = { - if sess.get_opts().test && !attr::contains_name(user_cfg, "test") - { - [attr::mk_word_item("test")] + if sess.get_opts().test + && !attr::contains_name(user_cfg, ~"test") { + [attr::mk_word_item(~"test")] } else { [] } }; ret user_cfg + gen_cfg + default_cfg; @@ -84,7 +84,9 @@ fn parse_cfgspecs(cfgspecs: &[str]) -> ast::crate_cfg { // FIXME: It would be nice to use the parser to parse all varieties of // meta_item here. At the moment we just support the meta_word variant. let words = []; - for s: str in cfgspecs { words += [attr::mk_word_item(s)]; } + for s: str in cfgspecs { + words += [attr::mk_word_item(istr::from_estr(s))]; + } ret words; } @@ -655,7 +657,7 @@ mod test { let sessopts = build_session_options("whatever", match, "whatever"); let sess = build_session(sessopts); let cfg = build_configuration(sess, "whatever", "whatever"); - assert (attr::contains_name(cfg, "test")); + assert (attr::contains_name(cfg, ~"test")); } // When the user supplies --test and --cfg test, don't implicitly add @@ -669,7 +671,7 @@ mod test { let sessopts = build_session_options("whatever", match, "whatever"); let sess = build_session(sessopts); let cfg = build_configuration(sess, "whatever", "whatever"); - let test_items = attr::find_meta_items_by_name(cfg, "test"); + let test_items = attr::find_meta_items_by_name(cfg, ~"test"); assert (vec::len(test_items) == 1u); } } diff --git a/src/comp/front/attr.rs b/src/comp/front/attr.rs index 5701ff33f975..711f9f670395 100644 --- a/src/comp/front/attr.rs +++ b/src/comp/front/attr.rs @@ -2,6 +2,7 @@ import std::vec; import std::str; +import std::istr; import std::map; import std::option; import syntax::ast; @@ -32,7 +33,7 @@ export mk_attr; // linkage fn find_linkage_metas(attrs: &[ast::attribute]) -> [@ast::meta_item] { let metas: [@ast::meta_item] = []; - for attr: ast::attribute in find_attrs_by_name(attrs, "link") { + for attr: ast::attribute in find_attrs_by_name(attrs, ~"link") { alt attr.node.value.node { ast::meta_list(_, items) { metas += items; } _ { log "ignoring link attribute that has incorrect type"; } @@ -163,11 +164,11 @@ fn sort_meta_items(items: &[@ast::meta_item]) -> [@ast::meta_item] { ret v2; } -fn remove_meta_items_by_name(items: &[@ast::meta_item], name: str) -> +fn remove_meta_items_by_name(items: &[@ast::meta_item], name: &istr) -> [@ast::meta_item] { let filter = - bind fn (item: &@ast::meta_item, name: str) -> + bind fn (item: &@ast::meta_item, name: &istr) -> option::t<@ast::meta_item> { if get_meta_item_name(item) != name { option::some(item) @@ -178,12 +179,13 @@ fn remove_meta_items_by_name(items: &[@ast::meta_item], name: str) -> } fn require_unique_names(sess: &session::session, metas: &[@ast::meta_item]) { - let map = map::mk_hashmap::(str::hash, str::eq); + let map = map::new_str_hash(); for meta: @ast::meta_item in metas { let name = get_meta_item_name(meta); if map.contains_key(name) { sess.span_fatal(meta.span, - #fmt["duplicate meta item `%s`", name]); + #fmt["duplicate meta item `%s`", + istr::to_estr(name)]); } map.insert(name, ()); } diff --git a/src/comp/front/config.rs b/src/comp/front/config.rs index 526bf20ebb76..be02086cc012 100644 --- a/src/comp/front/config.rs +++ b/src/comp/front/config.rs @@ -94,7 +94,7 @@ fn native_item_in_cfg(cfg: &ast::crate_cfg, item: &@ast::native_item) -> fn in_cfg(cfg: &ast::crate_cfg, attrs: &[ast::attribute]) -> bool { // The "cfg" attributes on the item - let item_cfg_attrs = attr::find_attrs_by_name(attrs, "cfg"); + let item_cfg_attrs = attr::find_attrs_by_name(attrs, ~"cfg"); let item_has_cfg_attrs = vec::len(item_cfg_attrs) > 0u; if !item_has_cfg_attrs { ret true; } @@ -108,7 +108,7 @@ fn in_cfg(cfg: &ast::crate_cfg, attrs: &[ast::attribute]) -> bool { [@ast::meta_item] { alt cfg_item.node { ast::meta_list(name, items) { - assert (name == "cfg"); + assert (name == ~"cfg"); inner_items + items } _ { inner_items } diff --git a/src/comp/front/test.rs b/src/comp/front/test.rs index d76e26064a7f..425736c2d5c4 100644 --- a/src/comp/front/test.rs +++ b/src/comp/front/test.rs @@ -64,7 +64,7 @@ fn fold_mod(_cx: &test_ctxt, m: &ast::_mod, fld: fold::ast_fold) -> fn nomain(item: &@ast::item) -> option::t<@ast::item> { alt item.node { ast::item_fn(f, _) { - if item.ident == "main" { + if item.ident == ~"main" { option::none } else { option::some(item) } } @@ -107,7 +107,7 @@ fn fold_item(cx: &test_ctxt, i: &@ast::item, fld: fold::ast_fold) -> fn is_test_fn(i: &@ast::item) -> bool { let has_test_attr = - vec::len(attr::find_attrs_by_name(i.attrs, "test")) > 0u; + vec::len(attr::find_attrs_by_name(i.attrs, ~"test")) > 0u; fn has_test_signature(i: &@ast::item) -> bool { alt i.node { @@ -125,7 +125,7 @@ fn is_test_fn(i: &@ast::item) -> bool { } fn is_ignored(i: &@ast::item) -> bool { - attr::contains_name(attr::attr_metas(i.attrs), "ignore") + attr::contains_name(attr::attr_metas(i.attrs), ~"ignore") } fn add_test_module(cx: &test_ctxt, m: &ast::_mod) -> ast::_mod { @@ -160,7 +160,7 @@ fn mk_test_module(cx: &test_ctxt) -> @ast::item { let testmod: ast::_mod = {view_items: [], items: [mainfn, testsfn]}; let item_ = ast::item_mod(testmod); let item: ast::item = - {ident: "__test", + {ident: ~"__test", attrs: [], id: cx.next_node_id(), node: item_, @@ -198,7 +198,7 @@ fn mk_tests(cx: &test_ctxt) -> @ast::item { let item_ = ast::item_fn(fn_, []); let item: ast::item = - {ident: "tests", + {ident: ~"tests", attrs: [], id: cx.next_node_id(), node: item_, @@ -219,7 +219,7 @@ fn empty_fn_ty() -> ast::ty { fn mk_test_desc_vec_ty(cx: &test_ctxt) -> @ast::ty { let test_desc_ty_path: ast::path = nospan({global: false, - idents: ["std", "test", "test_desc"], + idents: [~"std", ~"test", ~"test_desc"], types: []}); let test_desc_ty: ast::ty = @@ -256,7 +256,7 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr { span: dummy_sp()}; let name_field: ast::field = - nospan({mut: ast::imm, ident: "name", expr: @name_expr}); + nospan({mut: ast::imm, ident: ~"name", expr: @name_expr}); let fn_path: ast::path = nospan({global: false, idents: path, types: []}); @@ -266,7 +266,7 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr { span: dummy_sp()}; let fn_field: ast::field = - nospan({mut: ast::imm, ident: "fn", expr: @fn_expr}); + nospan({mut: ast::imm, ident: ~"fn", expr: @fn_expr}); let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore)); @@ -276,7 +276,7 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr { span: dummy_sp()}; let ignore_field: ast::field = - nospan({mut: ast::imm, ident: "ignore", expr: @ignore_expr}); + nospan({mut: ast::imm, ident: ~"ignore", expr: @ignore_expr}); let desc_rec_: ast::expr_ = ast::expr_rec([name_field, fn_field, ignore_field], option::none); @@ -291,7 +291,7 @@ fn mk_main(cx: &test_ctxt) -> @ast::item { let args_ty: ast::ty = nospan(ast::ty_vec(args_mt)); let args_arg: ast::arg = - {mode: ast::val, ty: @args_ty, ident: "args", id: cx.next_node_id()}; + {mode: ast::val, ty: @args_ty, ident: ~"args", id: cx.next_node_id()}; let ret_ty = nospan(ast::ty_nil); @@ -314,7 +314,7 @@ fn mk_main(cx: &test_ctxt) -> @ast::item { let item_ = ast::item_fn(fn_, []); let item: ast::item = - {ident: "main", + {ident: ~"main", attrs: [], id: cx.next_node_id(), node: item_, @@ -326,7 +326,7 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr { // Get the args passed to main so we can pass the to test_main let args_path: ast::path = - nospan({global: false, idents: ["args"], types: []}); + nospan({global: false, idents: [~"args"], types: []}); let args_path_expr_: ast::expr_ = ast::expr_path(args_path); @@ -335,7 +335,7 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr { // Call __test::test to generate the vector of test_descs let test_path: ast::path = - nospan({global: false, idents: ["tests"], types: []}); + nospan({global: false, idents: [~"tests"], types: []}); let test_path_expr_: ast::expr_ = ast::expr_path(test_path); @@ -350,7 +350,7 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr { // Call std::test::test_main let test_main_path: ast::path = nospan({global: false, - idents: ["std", "test", "test_main"], + idents: [~"std", ~"test", ~"test_main"], types: []}); let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path); diff --git a/src/comp/metadata/creader.rs b/src/comp/metadata/creader.rs index 3f6d63cf5779..1400fe983952 100644 --- a/src/comp/metadata/creader.rs +++ b/src/comp/metadata/creader.rs @@ -70,7 +70,7 @@ fn visit_item(e: env, i: &@ast::item) { let cstore = e.sess.get_cstore(); if !cstore::add_used_library(cstore, m.native_name) { ret; } for a: ast::attribute in - attr::find_attrs_by_name(i.attrs, "link_args") { + attr::find_attrs_by_name(i.attrs, ~"link_args") { alt attr::get_meta_item_value_str(attr::attr_meta(a)) { some(linkarg) { cstore::add_used_link_args(cstore, linkarg); } none. {/* fallthrough */ } @@ -128,15 +128,15 @@ fn find_library_crate(sess: &session::session, ident: &ast::ident, // is using the wrong type of meta item let crate_name = { - let name_items = attr::find_meta_items_by_name(metas, "name"); + let name_items = attr::find_meta_items_by_name(metas, ~"name"); alt vec::last(name_items) { some(i) { alt attr::get_meta_item_value_str(i) { some(n) { n } - _ { ident } + _ { istr::to_estr(ident) } } } - none. { ident } + none. { istr::to_estr(ident) } } }; @@ -219,14 +219,15 @@ fn load_library_crate(sess: &session::session, span: span, ident: &ast::ident, alt find_library_crate(sess, ident, metas, library_search_paths) { some(t) { ret t; } none. { - sess.span_fatal(span, #fmt["can't find crate for '%s'", ident]); + sess.span_fatal(span, #fmt["can't find crate for '%s'", + istr::to_estr(ident)]); } } } -fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item], +fn resolve_crate(e: env, ident: &ast::ident, metas: [@ast::meta_item], span: span) -> ast::crate_num { - if !e.crate_cache.contains_key(istr::from_estr(ident)) { + if !e.crate_cache.contains_key(ident) { let cinfo = load_library_crate(e.sess, span, ident, metas, e.library_search_paths); @@ -236,19 +237,20 @@ fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item], // Claim this crate number and cache it let cnum = e.next_crate_num; - e.crate_cache.insert(istr::from_estr(ident), cnum); + e.crate_cache.insert(ident, cnum); e.next_crate_num += 1; // Now resolve the crates referenced by this crate let cnum_map = resolve_crate_deps(e, cdata); - let cmeta = {name: ident, data: cdata, cnum_map: cnum_map}; + let cmeta = {name: istr::to_estr(ident), + data: cdata, cnum_map: cnum_map}; let cstore = e.sess.get_cstore(); cstore::set_crate_data(cstore, cnum, cmeta); cstore::add_used_crate_file(cstore, cfilename); ret cnum; - } else { ret e.crate_cache.get(istr::from_estr(ident)); } + } else { ret e.crate_cache.get(ident); } } // Go through the crate metadata and load any crates that it references @@ -271,7 +273,9 @@ fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map { // This is a new one so we've got to load it // FIXME: Need better error reporting than just a bogus span let fake_span = ast_util::dummy_sp(); - let local_cnum = resolve_crate(e, cname, [], fake_span); + let local_cnum = resolve_crate(e, + istr::from_estr(cname), + [], fake_span); cnum_map.insert(extrn_cnum, local_cnum); } } diff --git a/src/comp/metadata/decoder.rs b/src/comp/metadata/decoder.rs index 97010e0d521d..b91906063fce 100644 --- a/src/comp/metadata/decoder.rs +++ b/src/comp/metadata/decoder.rs @@ -153,7 +153,7 @@ fn resolve_path(path: &[ast::ident], data: @[u8]) -> [ast::def_id] { fn eq_item(data: &[u8], s: str) -> bool { ret str::eq(str::unsafe_from_bytes(data), s); } - let s = str::connect(path, "::"); + let s = istr::to_estr(istr::connect(path, ~"::")); let md = ebml::new_doc(data); let paths = ebml::get_doc(md, tag_paths); let eqer = bind eq_item(_, s); @@ -302,14 +302,14 @@ fn get_meta_items(md: &ebml::doc) -> [@ast::meta_item] { for each meta_item_doc: ebml::doc in ebml::tagged_docs(md, tag_meta_item_word) { let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); - let n = str::unsafe_from_bytes(ebml::doc_data(nd)); + let n = istr::unsafe_from_bytes(ebml::doc_data(nd)); items += [attr::mk_word_item(n)]; } for each meta_item_doc: ebml::doc in ebml::tagged_docs(md, tag_meta_item_name_value) { let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); let vd = ebml::get_doc(meta_item_doc, tag_meta_item_value); - let n = str::unsafe_from_bytes(ebml::doc_data(nd)); + let n = istr::unsafe_from_bytes(ebml::doc_data(nd)); let v = str::unsafe_from_bytes(ebml::doc_data(vd)); // FIXME (#611): Should be able to decode meta_name_value variants, // but currently they can't be encoded @@ -318,7 +318,7 @@ fn get_meta_items(md: &ebml::doc) -> [@ast::meta_item] { for each meta_item_doc: ebml::doc in ebml::tagged_docs(md, tag_meta_item_list) { let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); - let n = str::unsafe_from_bytes(ebml::doc_data(nd)); + let n = istr::unsafe_from_bytes(ebml::doc_data(nd)); let subitems = get_meta_items(meta_item_doc); items += [attr::mk_list_item(n, subitems)]; } diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs index 1aa89d9a9140..f803292d9ad4 100644 --- a/src/comp/metadata/encoder.rs +++ b/src/comp/metadata/encoder.rs @@ -44,9 +44,9 @@ type entry = {val: T, pos: uint}; fn encode_tag_variant_paths(ebml_w: &ebml::writer, variants: &[variant], path: &[istr], index: &mutable [entry]) { for variant: variant in variants { - add_to_index(ebml_w, path, index, istr::from_estr(variant.node.name)); + add_to_index(ebml_w, path, index, variant.node.name); ebml::start_tag(ebml_w, tag_paths_data_item); - encode_name(ebml_w, istr::from_estr(variant.node.name)); + encode_name(ebml_w, variant.node.name); encode_def_id(ebml_w, local_def(variant.node.id)); ebml::end_tag(ebml_w); } @@ -63,9 +63,9 @@ fn encode_native_module_item_paths(ebml_w: &ebml::writer, nmod: &native_mod, path: &[istr], index: &mutable [entry]) { for nitem: @native_item in nmod.items { - add_to_index(ebml_w, path, index, istr::from_estr(nitem.ident)); + add_to_index(ebml_w, path, index, nitem.ident); ebml::start_tag(ebml_w, tag_paths_data_item); - encode_name(ebml_w, istr::from_estr(nitem.ident)); + encode_name(ebml_w, nitem.ident); encode_def_id(ebml_w, local_def(nitem.id)); ebml::end_tag(ebml_w); } @@ -77,76 +77,76 @@ fn encode_module_item_paths(ebml_w: &ebml::writer, module: &_mod, if !ast_util::is_exported(it.ident, module) { cont; } alt it.node { item_const(_, _) { - add_to_index(ebml_w, path, index, istr::from_estr(it.ident)); + add_to_index(ebml_w, path, index, it.ident); ebml::start_tag(ebml_w, tag_paths_data_item); - encode_name(ebml_w, istr::from_estr(it.ident)); + encode_name(ebml_w, it.ident); encode_def_id(ebml_w, local_def(it.id)); ebml::end_tag(ebml_w); } item_fn(_, tps) { - add_to_index(ebml_w, path, index, istr::from_estr(it.ident)); + add_to_index(ebml_w, path, index, it.ident); ebml::start_tag(ebml_w, tag_paths_data_item); - encode_name(ebml_w, istr::from_estr(it.ident)); + encode_name(ebml_w, it.ident); encode_def_id(ebml_w, local_def(it.id)); ebml::end_tag(ebml_w); } item_mod(_mod) { - add_to_index(ebml_w, path, index, istr::from_estr(it.ident)); + add_to_index(ebml_w, path, index, it.ident); ebml::start_tag(ebml_w, tag_paths_data_mod); - encode_name(ebml_w, istr::from_estr(it.ident)); + encode_name(ebml_w, it.ident); encode_def_id(ebml_w, local_def(it.id)); encode_module_item_paths(ebml_w, _mod, - path + [istr::from_estr(it.ident)], + path + [it.ident], index); ebml::end_tag(ebml_w); } item_native_mod(nmod) { - add_to_index(ebml_w, path, index, istr::from_estr(it.ident)); + add_to_index(ebml_w, path, index, it.ident); ebml::start_tag(ebml_w, tag_paths_data_mod); - encode_name(ebml_w, istr::from_estr(it.ident)); + encode_name(ebml_w, it.ident); encode_def_id(ebml_w, local_def(it.id)); encode_native_module_item_paths( ebml_w, nmod, - path + [istr::from_estr(it.ident)], + path + [it.ident], index); ebml::end_tag(ebml_w); } item_ty(_, tps) { - add_to_index(ebml_w, path, index, istr::from_estr(it.ident)); + add_to_index(ebml_w, path, index, it.ident); ebml::start_tag(ebml_w, tag_paths_data_item); - encode_name(ebml_w, istr::from_estr(it.ident)); + encode_name(ebml_w, it.ident); encode_def_id(ebml_w, local_def(it.id)); ebml::end_tag(ebml_w); } item_res(_, _, tps, ctor_id) { - add_to_index(ebml_w, path, index, istr::from_estr(it.ident)); + add_to_index(ebml_w, path, index, it.ident); ebml::start_tag(ebml_w, tag_paths_data_item); - encode_name(ebml_w, istr::from_estr(it.ident)); + encode_name(ebml_w, it.ident); encode_def_id(ebml_w, local_def(ctor_id)); ebml::end_tag(ebml_w); - add_to_index(ebml_w, path, index, istr::from_estr(it.ident)); + add_to_index(ebml_w, path, index, it.ident); ebml::start_tag(ebml_w, tag_paths_data_item); - encode_name(ebml_w, istr::from_estr(it.ident)); + encode_name(ebml_w, it.ident); encode_def_id(ebml_w, local_def(it.id)); ebml::end_tag(ebml_w); } item_tag(variants, tps) { - add_to_index(ebml_w, path, index, istr::from_estr(it.ident)); + add_to_index(ebml_w, path, index, it.ident); ebml::start_tag(ebml_w, tag_paths_data_item); - encode_name(ebml_w, istr::from_estr(it.ident)); + encode_name(ebml_w, it.ident); encode_def_id(ebml_w, local_def(it.id)); ebml::end_tag(ebml_w); encode_tag_variant_paths(ebml_w, variants, path, index); } item_obj(_, tps, ctor_id) { - add_to_index(ebml_w, path, index, istr::from_estr(it.ident)); + add_to_index(ebml_w, path, index, it.ident); ebml::start_tag(ebml_w, tag_paths_data_item); - encode_name(ebml_w, istr::from_estr(it.ident)); + encode_name(ebml_w, it.ident); encode_def_id(ebml_w, local_def(ctor_id)); ebml::end_tag(ebml_w); - add_to_index(ebml_w, path, index, istr::from_estr(it.ident)); + add_to_index(ebml_w, path, index, it.ident); ebml::start_tag(ebml_w, tag_paths_data_item); - encode_name(ebml_w, istr::from_estr(it.ident)); + encode_name(ebml_w, it.ident); encode_def_id(ebml_w, local_def(it.id)); ebml::end_tag(ebml_w); } @@ -453,7 +453,7 @@ fn encode_meta_item(ebml_w: &ebml::writer, mi: &meta_item) { meta_word(name) { ebml::start_tag(ebml_w, tag_meta_item_word); ebml::start_tag(ebml_w, tag_meta_item_name); - ebml_w.writer.write(str::bytes(name)); + ebml_w.writer.write(istr::bytes(name)); ebml::end_tag(ebml_w); ebml::end_tag(ebml_w); } @@ -462,7 +462,7 @@ fn encode_meta_item(ebml_w: &ebml::writer, mi: &meta_item) { lit_str(value, _) { ebml::start_tag(ebml_w, tag_meta_item_name_value); ebml::start_tag(ebml_w, tag_meta_item_name); - ebml_w.writer.write(str::bytes(name)); + ebml_w.writer.write(istr::bytes(name)); ebml::end_tag(ebml_w); ebml::start_tag(ebml_w, tag_meta_item_value); ebml_w.writer.write(str::bytes(value)); @@ -475,7 +475,7 @@ fn encode_meta_item(ebml_w: &ebml::writer, mi: &meta_item) { meta_list(name, items) { ebml::start_tag(ebml_w, tag_meta_item_list); ebml::start_tag(ebml_w, tag_meta_item_name); - ebml_w.writer.write(str::bytes(name)); + ebml_w.writer.write(istr::bytes(name)); ebml::end_tag(ebml_w); for inner_item: @meta_item in items { encode_meta_item(ebml_w, *inner_item); @@ -508,18 +508,18 @@ fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> [attribute] { assert (ecx.ccx.link_meta.vers != ""); let name_item = - attr::mk_name_value_item_str("name", ecx.ccx.link_meta.name); + attr::mk_name_value_item_str(~"name", ecx.ccx.link_meta.name); let vers_item = - attr::mk_name_value_item_str("vers", ecx.ccx.link_meta.vers); + attr::mk_name_value_item_str(~"vers", ecx.ccx.link_meta.vers); let other_items = { - let tmp = attr::remove_meta_items_by_name(items, "name"); - attr::remove_meta_items_by_name(tmp, "vers") + let tmp = attr::remove_meta_items_by_name(items, ~"name"); + attr::remove_meta_items_by_name(tmp, ~"vers") }; let meta_items = [name_item, vers_item] + other_items; - let link_item = attr::mk_list_item("link", meta_items); + let link_item = attr::mk_list_item(~"link", meta_items); ret attr::mk_attr(link_item); } @@ -528,7 +528,7 @@ fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> [attribute] { let found_link_attr = false; for attr: attribute in crate.node.attrs { attrs += - if attr::get_attr_name(attr) != "link" { + if attr::get_attr_name(attr) != ~"link" { [attr] } else { alt attr.node.value.node { diff --git a/src/comp/metadata/tydecode.rs b/src/comp/metadata/tydecode.rs index f632e5ed28bc..1ab9ed931260 100644 --- a/src/comp/metadata/tydecode.rs +++ b/src/comp/metadata/tydecode.rs @@ -2,6 +2,7 @@ import std::vec; import std::str; +import std::istr; import std::uint; import std::option; import std::option::none; @@ -42,9 +43,9 @@ fn parse_ident(st: @pstate, sd: str_def, last: char) -> ast::ident { fn parse_ident_(st: @pstate, _sd: str_def, is_last: fn(char) -> bool) -> ast::ident { - let rslt = ""; + let rslt = ~""; while !is_last(peek(st) as char) { - rslt += str::unsafe_from_byte(next(st)); + rslt += istr::unsafe_from_byte(next(st)); } ret rslt; } @@ -225,9 +226,9 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t { assert (next(st) as char == '['); let fields: [ty::field] = []; while peek(st) as char != ']' { - let name = ""; + let name = ~""; while peek(st) as char != '=' { - name += str::unsafe_from_byte(next(st)); + name += istr::unsafe_from_byte(next(st)); } st.pos = st.pos + 1u; fields += [{ident: name, mt: parse_mt(st, sd)}]; @@ -278,9 +279,9 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t { 'W' { proto = ast::proto_iter; } 'F' { proto = ast::proto_fn; } } - let name = ""; + let name = ~""; while peek(st) as char != '[' { - name += str::unsafe_from_byte(next(st)); + name += istr::unsafe_from_byte(next(st)); } let func = parse_ty_fn(st, sd); methods += diff --git a/src/comp/metadata/tyencode.rs b/src/comp/metadata/tyencode.rs index bdb5db6758d0..df2c83593d13 100644 --- a/src/comp/metadata/tyencode.rs +++ b/src/comp/metadata/tyencode.rs @@ -134,7 +134,7 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) { ty::ty_rec(fields) { w.write_str(~"R["); for field: ty::field in fields { - w.write_str(istr::from_estr(field.ident)); + w.write_str(field.ident); w.write_char('='); enc_mt(w, cx, field.mt); } @@ -159,7 +159,7 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) { w.write_str(~"O["); for m: ty::method in methods { enc_proto(w, m.proto); - w.write_str(istr::from_estr(m.ident)); + w.write_str(m.ident); enc_ty_fn(w, cx, m.inputs, m.output, m.cf, m.constrs); } w.write_char(']'); diff --git a/src/comp/middle/alias.rs b/src/comp/middle/alias.rs index 03fcb2836218..177f5f752a97 100644 --- a/src/comp/middle/alias.rs +++ b/src/comp/middle/alias.rs @@ -10,6 +10,7 @@ import syntax::visit; import visit::vt; import std::vec; import std::str; +import std::istr; import std::option; import std::option::some; import std::option::none; @@ -593,7 +594,7 @@ fn expr_root(cx: &ctx, ex: @ast::expr, autoderef: bool) -> alt ty::struct(cx.tcx, auto_unbox.t) { ty::ty_rec(fields) { for fld: ty::field in fields { - if str::eq(ident, fld.ident) { + if istr::eq(ident, fld.ident) { mut = fld.mt.mut != ast::imm; break; } diff --git a/src/comp/middle/ast_map.rs b/src/comp/middle/ast_map.rs index 356d2b46b8cf..a0b1a96e3d66 100644 --- a/src/comp/middle/ast_map.rs +++ b/src/comp/middle/ast_map.rs @@ -131,7 +131,7 @@ mod test { fn test_node_span_item() { let expected: codemap::span = ast_util::mk_sp(20u, 30u); let node = - node_item(@{ident: "test", + node_item(@{ident: ~"test", attrs: [], id: 0, node: item_mod({view_items: [], items: []}), @@ -143,7 +143,7 @@ mod test { fn test_node_span_obj_ctor() { let expected: codemap::span = ast_util::mk_sp(20u, 30u); let node = - node_obj_ctor(@{ident: "test", + node_obj_ctor(@{ident: ~"test", attrs: [], id: 0, node: item_mod({view_items: [], items: []}), @@ -155,7 +155,7 @@ mod test { fn test_node_span_native_item() { let expected: codemap::span = ast_util::mk_sp(20u, 30u); let node = - node_native_item(@{ident: "test", + node_native_item(@{ident: ~"test", attrs: [], node: native_item_ty, id: 0, diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 9c0c5281ccca..f65449e7099a 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -432,7 +432,7 @@ fn follow_import(e: &env, sc: &scopes, path: &[ident], sp: &span) -> ast::def_mod(_) | ast::def_native_mod(_) { ret dcur; } _ { e.sess.span_err(sp, - str::connect(path, "::") + + istr::to_estr(istr::connect(path, ~"::")) + " does not name a module."); ret none; } @@ -465,7 +465,7 @@ fn resolve_import(e: &env, defid: ast::def_id, name: &ast::ident, let end_id = ids[n_idents - 1u]; // Ignore the current scope if this import would shadow itself. let sc = - if str::eq(name, ids[0]) { std::list::cdr(sc_in) } else { sc_in }; + if istr::eq(name, ids[0]) { std::list::cdr(sc_in) } else { sc_in }; if n_idents == 1u { register(e, defid, sp, end_id, sc_in, lookup_in_scope(e, sc, sp, end_id, ns_value), @@ -559,9 +559,10 @@ fn unresolved_err(e: &env, sc: &scopes, sp: &span, name: &ident, kind: &str) { } let err_scope = find_fn_or_mod_scope(sc); for rs: {ident: str, sc: scope} in e.reported { - if str::eq(rs.ident, name) && err_scope == rs.sc { ret; } + if str::eq(rs.ident, istr::to_estr(name)) + && err_scope == rs.sc { ret; } } - e.reported += [{ident: name, sc: err_scope}]; + e.reported += [{ident: istr::to_estr(name), sc: err_scope}]; e.sess.span_err(sp, mk_unresolved_msg(name, kind)); } @@ -570,7 +571,7 @@ fn unresolved_fatal(e: &env, sp: &span, id: &ident, kind: &str) -> ! { } fn mk_unresolved_msg(id: &ident, kind: &str) -> str { - ret #fmt["unresolved %s: %s", kind, id]; + ret #fmt["unresolved %s: %s", kind, istr::to_estr(id)]; } // Lookup helpers @@ -734,7 +735,7 @@ fn lookup_in_ty_params(name: &ident, ty_params: &[ast::ty_param]) -> option::t { let i = 0u; for tp: ast::ty_param in ty_params { - if str::eq(tp.ident, name) { ret some(ast::def_ty_arg(i, tp.kind)); } + if istr::eq(tp.ident, name) { ret some(ast::def_ty_arg(i, tp.kind)); } i += 1u; } ret none::; @@ -744,7 +745,7 @@ fn lookup_in_pat(name: &ident, pat: &@ast::pat) -> option::t { let found = none; for each bound in ast_util::pat_bindings(pat) { let p_name = alt bound.node { ast::pat_bind(n) { n } }; - if str::eq(p_name, name) { found = some(local_def(bound.id)); } + if istr::eq(p_name, name) { found = some(local_def(bound.id)); } } ret found; } @@ -755,7 +756,7 @@ fn lookup_in_fn(name: &ident, decl: &ast::fn_decl, alt ns { ns_value. { for a: ast::arg in decl.inputs { - if str::eq(a.ident, name) { + if istr::eq(a.ident, name) { ret some(ast::def_arg(local_def(a.id))); } } @@ -771,7 +772,7 @@ fn lookup_in_obj(name: &ident, ob: &ast::_obj, ty_params: &[ast::ty_param], alt ns { ns_value. { for f: ast::obj_field in ob.fields { - if str::eq(f.ident, name) { + if istr::eq(f.ident, name) { ret some(ast::def_obj_field(local_def(f.id))); } } @@ -810,12 +811,12 @@ fn lookup_in_block(name: &ident, b: &ast::blk_, pos: uint, loc_pos: uint, alt it.node { ast::item_tag(variants, _) { if ns == ns_type { - if str::eq(it.ident, name) { + if istr::eq(it.ident, name) { ret some(ast::def_ty(local_def(it.id))); } } else if ns == ns_value { for v: ast::variant in variants { - if str::eq(v.node.name, name) { + if istr::eq(v.node.name, name) { let i = v.node.id; ret some(ast::def_variant(local_def(it.id), local_def(i))); @@ -824,7 +825,7 @@ fn lookup_in_block(name: &ident, b: &ast::blk_, pos: uint, loc_pos: uint, } } _ { - if str::eq(it.ident, name) { + if istr::eq(it.ident, name) { let found = found_def_item(it, ns); if !is_none(found) { ret found; } } @@ -898,13 +899,15 @@ fn lookup_in_mod(e: &env, m: &def, sp: &span, name: &ident, ns: namespace, if defid.crate != ast::local_crate { // examining a module in an external crate - let cached = e.ext_cache.find({did: defid, ident: name, ns: ns}); + let cached = e.ext_cache.find({did: defid, + ident: istr::to_estr(name), ns: ns}); if !is_none(cached) { ret cached; } let path = [name]; if defid.node != -1 { path = e.ext_map.get(defid) + path; } let fnd = lookup_external(e, defid.crate, path, ns); if !is_none(fnd) { - e.ext_cache.insert({did: defid, ident: name, ns: ns}, + e.ext_cache.insert({did: defid, + ident: istr::to_estr(name), ns: ns}, option::get(fnd)); } ret fnd; @@ -955,7 +958,7 @@ fn lookup_in_local_mod(e: &env, node_id: node_id, sp: &span, id: &ident, ret none::; // name is not visible } - alt info.index.find(istr::from_estr(id)) { + alt info.index.find(id) { none. { } some(lst_) { let lst = lst_; @@ -1000,25 +1003,27 @@ fn lookup_glob_in_mod(e: &env, info: @indexed_mod, sp: &span, id: &ident, } else { for match: glob_imp_def in matches { let sp = match.item.span; - e.sess.span_note(sp, #fmt["'%s' is imported here", id]); + e.sess.span_note(sp, #fmt["'%s' is imported here", + istr::to_estr(id)]); } e.sess.span_fatal(sp, - "'" + id + "' is glob-imported from" + + "'" + istr::to_estr(id) + + "' is glob-imported from" + " multiple different modules."); } } // since we don't know what names we have in advance, // absence takes the place of todo() - if !info.glob_imported_names.contains_key(istr::from_estr(id)) { - info.glob_imported_names.insert(istr::from_estr(id), resolving(sp)); + if !info.glob_imported_names.contains_key(id) { + info.glob_imported_names.insert(id, resolving(sp)); let val = per_ns(e, info, sp, id, ns_value, dr); let typ = per_ns(e, info, sp, id, ns_type, dr); let md = per_ns(e, info, sp, id, ns_module, dr); - info.glob_imported_names.insert(istr::from_estr(id), + info.glob_imported_names.insert(id, resolved(val, typ, md)); } - alt info.glob_imported_names.get(istr::from_estr(id)) { + alt info.glob_imported_names.get(id) { todo(_, _, _, _, _) { e.sess.bug("Shouldn't've put a todo in."); } resolving(sp) { ret none::; //circularity is okay in import globs @@ -1075,7 +1080,6 @@ fn lookup_in_mie(e: &env, mie: &mod_index_entry, ns: namespace) -> // Module indexing fn add_to_index(index: &hashmap>, id: &ident, ent: &mod_index_entry) { - let id = istr::from_estr(id); alt index.find(id) { none. { index.insert(id, cons(ent, @nil::)); } @@ -1193,7 +1197,7 @@ fn check_for_collisions(e: &@env, c: &ast::crate) { for each m: @{key: ast::node_id, val: @indexed_mod} in e.mod_map.items() { for each name: @{key: identistr, val: list} in m.val.index.items() { - check_mod_name(*e, istr::to_estr(name.key), name.val); + check_mod_name(*e, name.key, name.val); } } // Other scopes have to be checked the hard way. @@ -1211,7 +1215,8 @@ fn check_mod_name(e: &env, name: &ident, entries: list) { let saw_type = false; let saw_value = false; fn dup(e: &env, sp: &span, word: &str, name: &ident) { - e.sess.span_fatal(sp, "duplicate definition of " + word + name); + e.sess.span_fatal(sp, "duplicate definition of " + word + + istr::to_estr(name)); } while true { alt entries { @@ -1303,11 +1308,11 @@ fn check_arm(e: &@env, a: &ast::arm, x: &(), v: &vt<()>) { "inconsistent number of bindings"); } else { for name: ident in ch.seen { - if is_none(vec::find(bind str::eq(name, _), seen0)) { + if is_none(vec::find(bind istr::eq(name, _), seen0)) { // Fight the alias checker let name_ = name; e.sess.span_err(a.pats[i].span, - "binding " + name_ + + "binding " + istr::to_estr(name_) + " does not occur in first pattern"); } } @@ -1399,8 +1404,9 @@ fn checker(e: &env, kind: str) -> checker { fn check_name(ch: &checker, sp: &span, name: &ident) { for s: ident in ch.seen { - if str::eq(s, name) { - ch.sess.span_fatal(sp, "duplicate " + ch.kind + " name: " + name); + if istr::eq(s, name) { + ch.sess.span_fatal(sp, "duplicate " + ch.kind + + " name: " + istr::to_estr(name)); } } } diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 0fd6762a4d19..c2391563b787 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -4240,7 +4240,7 @@ fn trans_rec(cx: &@block_ctxt, fields: &[ast::field], bcx = dst_res.bcx; let expr_provided = false; for f: ast::field in fields { - if str::eq(f.node.ident, tf.ident) { + if istr::eq(f.node.ident, tf.ident) { expr_provided = true; let lv = trans_lval(bcx, f.node.expr); bcx = move_val_if_temp(lv.res.bcx, INIT, dst_res.val, @@ -5060,6 +5060,7 @@ fn alloc_local(cx: &@block_ctxt, local: &@ast::local) -> result { alt local.node.pat.node { ast::pat_bind(ident) { if bcx_ccx(cx).sess.get_opts().debuginfo { + let ident = istr::to_estr(ident); llvm::LLVMSetValueName(r.val, str::buf(ident)); } } @@ -5523,7 +5524,7 @@ fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id, fn_args += [{mode: ast::alias(false), ty: varg.ty, - ident: istr::to_estr(~"arg" + uint::to_str(i, 10u)), + ident: ~"arg" + uint::to_str(i, 10u), id: varg.id}]; } assert (cx.ccx.item_ids.contains_key(variant.node.id)); @@ -5625,7 +5626,7 @@ fn trans_const(cx: &@crate_ctxt, e: @ast::expr, id: ast::node_id) { fn trans_item(cx: @local_ctxt, item: &ast::item) { alt item.node { ast::item_fn(f, tps) { - let sub_cx = extend_path(cx, item.ident); + let sub_cx = extend_path(cx, istr::to_estr(item.ident)); alt cx.ccx.item_ids.find(item.id) { some(llfndecl) { trans_fn(sub_cx, item.span, f, llfndecl, none, tps, item.id); @@ -5639,7 +5640,7 @@ fn trans_item(cx: @local_ctxt, item: &ast::item) { ast::item_obj(ob, tps, ctor_id) { let sub_cx = @{obj_typarams: tps, obj_fields: ob.fields - with *extend_path(cx, item.ident)}; + with *extend_path(cx, istr::to_estr(item.ident))}; trans_obj(sub_cx, item.span, ob, ctor_id, tps); } ast::item_res(dtor, dtor_id, tps, ctor_id) { @@ -5657,12 +5658,13 @@ fn trans_item(cx: @local_ctxt, item: &ast::item) { } ast::item_mod(m) { let sub_cx = - @{path: cx.path + [item.ident], - module_path: cx.module_path + [item.ident] with *cx}; + @{path: cx.path + [istr::to_estr(item.ident)], + module_path: cx.module_path + + [istr::to_estr(item.ident)] with *cx}; trans_mod(sub_cx, m); } ast::item_tag(variants, tps) { - let sub_cx = extend_path(cx, item.ident); + let sub_cx = extend_path(cx, istr::to_estr(item.ident)); let degen = std::vec::len(variants) == 1u; let i = 0; for variant: ast::variant in variants { @@ -5717,6 +5719,7 @@ fn decl_fn_and_pair_full(ccx: &@crate_ctxt, sp: &span, path: &[str], let ps: str = mangle_exported_name(ccx, path, node_type); register_fn_pair(ccx, ps, llfty, llfn, node_id); + let path = istr::from_estrs(path); let is_main: bool = is_main_name(path) && !ccx.sess.get_opts().library; if is_main { create_main_wrapper(ccx, sp, llfn, node_type); } } @@ -6029,14 +6032,15 @@ fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &[str], finish_fn(fcx, lltop); } -fn item_path(item: &@ast::item) -> [str] { ret [item.ident]; } +fn item_path(item: &@ast::item) -> [str] { ret [istr::to_estr(item.ident)]; } fn collect_native_item(ccx: @crate_ctxt, i: &@ast::native_item, pt: &[str], _v: &vt<[str]>) { alt i.node { ast::native_item_fn(_, _, _) { if !ccx.obj_methods.contains_key(i.id) { - decl_native_fn_and_pair(ccx, i.span, pt, i.ident, i.id); + decl_native_fn_and_pair(ccx, i.span, pt, + istr::to_estr(i.ident), i.id); } } _ { } @@ -6050,7 +6054,7 @@ fn collect_item_1(ccx: @crate_ctxt, i: &@ast::item, pt: &[str], ast::item_const(_, _) { let typ = node_id_type(ccx, i.id); let s = - mangle_exported_name(ccx, pt + [i.ident], + mangle_exported_name(ccx, pt + [istr::to_estr(i.ident)], node_id_type(ccx, i.id)); let g = llvm::LLVMAddGlobal(ccx.llmod, type_of(ccx, i.span, typ), @@ -6110,7 +6114,8 @@ fn collect_tag_ctor(ccx: @crate_ctxt, i: &@ast::item, pt: &[str], ast::item_tag(variants, tps) { for variant: ast::variant in variants { if std::vec::len(variant.node.args) != 0u { - decl_fn_and_pair(ccx, i.span, new_pt + [variant.node.name], + decl_fn_and_pair(ccx, i.span, + new_pt + [istr::to_estr(variant.node.name)], "tag", tps, variant.node.id); } } @@ -6138,7 +6143,8 @@ fn trans_constant(ccx: @crate_ctxt, it: &@ast::item, pt: &[str], let n_variants = std::vec::len::(variants); while i < n_variants { let variant = variants[i]; - let p = new_pt + [it.ident, variant.node.name, "discrim"]; + let p = new_pt + istr::to_estrs([it.ident, + variant.node.name, ~"discrim"]); let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx)); let discrim_gvar = llvm::LLVMAddGlobal(ccx.llmod, T_int(), str::buf(s)); diff --git a/src/comp/middle/trans_alt.rs b/src/comp/middle/trans_alt.rs index 57539c2a3c59..fdd2446cb1bf 100644 --- a/src/comp/middle/trans_alt.rs +++ b/src/comp/middle/trans_alt.rs @@ -60,7 +60,7 @@ fn variant_opt(ccx: &@crate_ctxt, pat_id: ast::node_id) -> opt { type bind_map = [{ident: ast::ident, val: ValueRef}]; fn assoc(key: str, list: &bind_map) -> option::t { for elt: {ident: ast::ident, val: ValueRef} in list { - if str::eq(elt.ident, key) { ret some(elt.val); } + if istr::eq(elt.ident, istr::from_estr(key)) { ret some(elt.val); } } ret none; } @@ -146,7 +146,7 @@ fn enter_rec(m: &match, col: uint, fields: &[ast::ident], val: ValueRef) -> for fname: ast::ident in fields { let pat = dummy; for fpat: ast::field_pat in fpats { - if str::eq(fpat.ident, fname) { pat = fpat.pat; break; } + if istr::eq(fpat.ident, fname) { pat = fpat.pat; break; } } pats += [pat]; } @@ -234,7 +234,7 @@ fn collect_record_fields(m: &match, col: uint) -> [ast::ident] { alt br.pats[col].node { ast::pat_rec(fs, _) { for f: ast::field_pat in fs { - if !vec::any(bind str::eq(f.ident, _), fields) { + if !vec::any(bind istr::eq(f.ident, _), fields) { fields += [f.ident]; } } diff --git a/src/comp/middle/trans_objects.rs b/src/comp/middle/trans_objects.rs index 17a600e971d9..c55d32593d8d 100644 --- a/src/comp/middle/trans_objects.rs +++ b/src/comp/middle/trans_objects.rs @@ -1,6 +1,7 @@ // Translation of object-related things to LLVM IR. import std::str; +import std::istr; import std::option; import std::vec; import option::none; @@ -396,7 +397,7 @@ tag vtbl_mthd { // Alphabetize ast::methods by ident. A helper for create_vtbl. fn ast_mthd_lteq(a: &@ast::method, b: &@ast::method) -> bool { - ret str::lteq(a.node.ident, b.node.ident); + ret istr::lteq(a.node.ident, b.node.ident); } // Alphabetize vtbl_mthds by ident. A helper for create_vtbl. @@ -404,14 +405,14 @@ fn vtbl_mthd_lteq(a: &vtbl_mthd, b: &vtbl_mthd) -> bool { alt a { normal_mthd(ma) { alt b { - normal_mthd(mb) { ret str::lteq(ma.node.ident, mb.node.ident); } - fwding_mthd(mb) { ret str::lteq(ma.node.ident, mb.ident); } + normal_mthd(mb) { ret istr::lteq(ma.node.ident, mb.node.ident); } + fwding_mthd(mb) { ret istr::lteq(ma.node.ident, mb.ident); } } } fwding_mthd(ma) { alt b { - normal_mthd(mb) { ret str::lteq(ma.ident, mb.node.ident); } - fwding_mthd(mb) { ret str::lteq(ma.ident, mb.ident); } + normal_mthd(mb) { ret istr::lteq(ma.ident, mb.node.ident); } + fwding_mthd(mb) { ret istr::lteq(ma.ident, mb.ident); } } } } @@ -430,7 +431,7 @@ fn filtering_fn(cx: @local_ctxt, m: &vtbl_mthd, addtl_meths: [@ast::method]) alt m { fwding_mthd(fm) { for am: @ast::method in addtl_meths { - if str::eq(am.node.ident, fm.ident) { ret none; } + if istr::eq(am.node.ident, fm.ident) { ret none; } } ret some(fwding_mthd(fm)); } @@ -598,7 +599,8 @@ fn process_bkwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method, // Create a local context that's aware of the name of the method we're // creating. - let mcx: @local_ctxt = @{path: cx.path + ["method", m.ident] with *cx}; + let mcx: @local_ctxt = @{path: cx.path + + ["method", istr::to_estr(m.ident)] with *cx}; // Make up a name for the backwarding function. let fn_name: str = "backwarding_fn"; @@ -726,7 +728,8 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method, // Create a local context that's aware of the name of the method we're // creating. - let mcx: @local_ctxt = @{path: cx.path + ["method", m.ident] with *cx}; + let mcx: @local_ctxt = @{path: cx.path + + ["method", istr::to_estr(m.ident)] with *cx}; // Make up a name for the forwarding function. let fn_name: str = "forwarding_fn"; @@ -917,7 +920,7 @@ fn process_normal_mthd(cx: @local_ctxt, m: @ast::method, self_ty: ty::t, } } let mcx: @local_ctxt = - @{path: cx.path + ["method", m.node.ident] with *cx}; + @{path: cx.path + ["method", istr::to_estr(m.node.ident)] with *cx}; let s: str = mangle_internal_name_by_path(mcx.ccx, mcx.path); let llfn: ValueRef = decl_internal_fastcall_fn(cx.ccx.llmod, s, llfnty); diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs index 49942eaef6bc..640619301c1c 100644 --- a/src/comp/middle/tstate/auxiliary.rs +++ b/src/comp/middle/tstate/auxiliary.rs @@ -67,7 +67,7 @@ fn comma_str(args: &[@constr_arg_use]) -> str { if comma { rslt += ", "; } else { comma = true; } alt a.node { carg_base. { rslt += "*"; } - carg_ident(i) { rslt += i.ident; } + carg_ident(i) { rslt += istr::to_estr(i.ident); } carg_lit(l) { rslt += lit_to_str(l); } } } @@ -77,7 +77,8 @@ fn comma_str(args: &[@constr_arg_use]) -> str { fn constraint_to_str(tcx: &ty::ctxt, c: &sp_constr) -> str { alt c.node { ninit(_, i) { - ret "init(" + i + " [" + tcx.sess.span_str(c.span) + "])"; + ret "init(" + + istr::to_estr(i) + " [" + tcx.sess.span_str(c.span) + "])"; } npred(p, _, args) { ret path_to_str(p) + "(" + comma_str(args) + ")" + "[" + @@ -169,11 +170,11 @@ fn log_states_err(pp: &pre_and_post_state) { log_cond_err(p2); } -fn print_ident(i: &ident) { log " " + i + " "; } +fn print_ident(i: &ident) { log ~" " + i + ~" "; } fn print_idents(idents: &mutable [ident]) { if vec::len::(idents) == 0u { ret; } - log "an ident: " + vec::pop::(idents); + log ~"an ident: " + vec::pop::(idents); print_idents(idents); } @@ -592,7 +593,9 @@ fn constraints(fcx: &fn_ctxt) -> [norm_constraint] { fn match_args(fcx: &fn_ctxt, occs: &@mutable [pred_args], occ: &[@constr_arg_use]) -> uint { log "match_args: looking at " + - constr_args_to_str(fn (i: &inst) -> str { ret i.ident; }, occ); + constr_args_to_str(fn (i: &inst) -> str { + ret istr::to_estr(i.ident); + }, occ); for pd: pred_args in *occs { log "match_args: candidate " + pred_args_to_str(pd); fn eq(p: &inst, q: &inst) -> bool { ret p.node == q.node; } @@ -684,7 +687,9 @@ fn expr_to_constr(tcx: ty::ctxt, e: &@expr) -> sp_constr { fn pred_args_to_str(p: &pred_args) -> str { "<" + istr::to_estr(uint::str(p.node.bit_num)) + ", " + - constr_args_to_str(fn (i: &inst) -> str { ret i.ident; }, p.node.args) + constr_args_to_str(fn (i: &inst) -> str { + ret istr::to_estr(i.ident); + }, p.node.args) + ">" } @@ -790,7 +795,7 @@ fn insts_to_str(stuff: &[constr_arg_general_]) -> str { rslt += " " + alt i { - carg_ident(p) { p.ident } + carg_ident(p) { istr::to_estr(p.ident) } carg_base. { "*" } carg_lit(_) { "[lit]" } } + " "; diff --git a/src/comp/middle/tstate/ck.rs b/src/comp/middle/tstate/ck.rs index 070417e64012..8d42e761571f 100644 --- a/src/comp/middle/tstate/ck.rs +++ b/src/comp/middle/tstate/ck.rs @@ -37,6 +37,7 @@ import std::option; import std::option::t; import std::option::some; import std::option::none; +import std::istr; import aux::*; import syntax::print::pprust::ty_to_str; import util::common::log_stmt_err; @@ -54,7 +55,9 @@ fn check_unused_vars(fcx: &fn_ctxt) { ninit(id, v) { if !vec_contains(fcx.enclosing.used_vars, id) && v[0] != '_' as u8 { - fcx.ccx.tcx.sess.span_warn(c.c.span, "unused variable " + v); + fcx.ccx.tcx.sess.span_warn(c.c.span, + "unused variable " + + istr::to_estr(v)); } } _ {/* ignore pred constraints */ } @@ -147,7 +150,8 @@ fn check_states_against_conditions(fcx: &fn_ctxt, f: &_fn, !type_is_nil(fcx.ccx.tcx, ret_ty_of_fn(fcx.ccx.tcx, id)) && f.decl.cf == return { fcx.ccx.tcx.sess.span_err(f.body.span, - "In function " + fcx.name + + "In function " + + istr::to_estr(fcx.name) + ", not all control paths \ return a value"); fcx.ccx.tcx.sess.span_fatal(f.decl.output.span, @@ -162,7 +166,7 @@ fn check_states_against_conditions(fcx: &fn_ctxt, f: &_fn, if !promises(fcx, post, fcx.enclosing.i_diverge) { fcx.ccx.tcx.sess.span_fatal(f.body.span, "In non-returning function " + - fcx.name + + istr::to_estr(fcx.name) + ", some control paths may \ return to the caller"); } @@ -192,8 +196,11 @@ fn fn_states(f: &_fn, tps: &[ast::ty_param], sp: &span, i: &fn_ident, assert (ccx.fm.contains_key(id)); let f_info = ccx.fm.get(id); - let name = option::from_maybe("anon", i); - let fcx = {enclosing: f_info, id: id, name: name, ccx: ccx}; + let name = option::from_maybe(~"anon", i); + let fcx = {enclosing: f_info, + id: id, + name: name, + ccx: ccx}; check_fn_states(fcx, f, tps, id, sp, i); } diff --git a/src/comp/middle/tstate/collect_locals.rs b/src/comp/middle/tstate/collect_locals.rs index f4729c3182e0..ef7b38d452c9 100644 --- a/src/comp/middle/tstate/collect_locals.rs +++ b/src/comp/middle/tstate/collect_locals.rs @@ -18,7 +18,7 @@ type ctxt = {cs: @mutable [sp_constr], tcx: ty::ctxt}; fn collect_local(loc: &@local, cx: &ctxt, v: &visit::vt) { for each p: @pat in pat_bindings(loc.node.pat) { let ident = alt p.node { pat_bind(id) { id } }; - log "collect_local: pushing " + ident;; + log ~"collect_local: pushing " + ident;; *cx.cs += [respan(loc.span, ninit(p.id, ident))]; } visit::visit_local(loc, cx, v); @@ -94,7 +94,7 @@ fn add_constraint(tcx: &ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) to a bit number in the precondition/postcondition vectors */ fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &[ty_param], f_sp: &span, f_name: &fn_ident, id: node_id) { - let name = fn_ident_to_string(id, f_name); + let name = istr::from_estr(fn_ident_to_string(id, f_name)); let res_map = @new_def_hash::(); let next: uint = 0u; @@ -130,7 +130,7 @@ fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &[ty_param], f_sp: &span, // and the name of the function, with a '!' appended to it, for the // "diverges" constraint let diverges_id = ccx.tcx.sess.next_node_id(); - let diverges_name = name + "!"; + let diverges_name = name + ~"!"; add_constraint(cx.tcx, respan(f_sp, ninit(diverges_id, diverges_name)), next, res_map); @@ -147,9 +147,9 @@ fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &[ty_param], f_sp: &span, i_diverge: ninit(diverges_id, diverges_name), used_vars: v}; ccx.fm.insert(id, rslt); - log name + istr::to_estr(~" has " - + std::uint::str(num_constraints(rslt)) - + ~" constraints"); + log istr::to_estr(name + ~" has " + + std::uint::str(num_constraints(rslt)) + + ~" constraints"); } diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs index c1d81d4d277a..d9d88b04533f 100644 --- a/src/comp/middle/tstate/pre_post_conditions.rs +++ b/src/comp/middle/tstate/pre_post_conditions.rs @@ -1,5 +1,6 @@ import std::vec; +import std::istr; import std::option; import std::option::none; import std::option::some; @@ -68,11 +69,11 @@ fn find_pre_post_item(ccx: &crate_ctxt, i: &item) { {constrs: @new_def_hash::(), num_constraints: 0u, cf: return, - i_return: ninit(0, ""), - i_diverge: ninit(0, ""), + i_return: ninit(0, ~""), + i_diverge: ninit(0, ~""), used_vars: v}, id: 0, - name: "", + name: ~"", ccx: ccx}; find_pre_post_expr(fake_fcx, e); } @@ -369,7 +370,7 @@ fn find_pre_post_expr(fcx: &fn_ctxt, e: @expr) { let rslt = expr_pp(fcx.ccx, e); clear_pp(rslt); let upvars = freevars::get_freevars(fcx.ccx.tcx, e.id); - for id: node_id in *upvars { handle_var(fcx, rslt, id, "upvar"); } + for id: node_id in *upvars { handle_var(fcx, rslt, id, ~"upvar"); } } expr_block(b) { find_pre_post_block(fcx, b); @@ -750,7 +751,7 @@ fn fn_pre_post(f: &_fn, tps: &[ty_param], sp: &span, i: &fn_ident, let fcx = {enclosing: ccx.fm.get(id), id: id, - name: fn_ident_to_string(id, i), + name: istr::from_estr(fn_ident_to_string(id, i)), ccx: ccx}; find_pre_post_fn(fcx, f); } diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index b6ce008b0c71..02ec45739017 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1513,7 +1513,7 @@ fn hash_type_structure(st: &sty) -> uint { ty_native_fn(_, args, rty) { ret hash_fn(28u, args, rty); } ty_obj(methods) { let h = 29u; - for m: method in methods { h += h << 5u + str::hash(m.ident); } + for m: method in methods { h += h << 5u + istr::hash(m.ident); } ret h; } ty_var(v) { ret hash_uint(30u, v as uint); } @@ -1801,20 +1801,21 @@ fn stmt_node_id(s: &@ast::stmt) -> ast::node_id { fn field_idx(sess: &session::session, sp: &span, id: &ast::ident, fields: &[field]) -> uint { let i: uint = 0u; - for f: field in fields { if str::eq(f.ident, id) { ret i; } i += 1u; } - sess.span_fatal(sp, "unknown field '" + id + "' of record"); + for f: field in fields { if istr::eq(f.ident, id) { ret i; } i += 1u; } + sess.span_fatal(sp, "unknown field '" + + istr::to_estr(id) + "' of record"); } fn method_idx(sess: &session::session, sp: &span, id: &ast::ident, meths: &[method]) -> uint { let i: uint = 0u; - for m: method in meths { if str::eq(m.ident, id) { ret i; } i += 1u; } - sess.span_fatal(sp, "unknown method '" + id + "' of obj"); + for m: method in meths { if istr::eq(m.ident, id) { ret i; } i += 1u; } + sess.span_fatal(sp, "unknown method '" + istr::to_estr(id) + "' of obj"); } fn sort_methods(meths: &[method]) -> [method] { fn method_lteq(a: &method, b: &method) -> bool { - ret str::lteq(a.ident, b.ident); + ret istr::lteq(a.ident, b.ident); } ret std::sort::merge_sort::(bind method_lteq(_, _), meths); } @@ -2135,7 +2136,7 @@ mod unify { while i < expected_len { let e_meth = expected_meths[i]; let a_meth = actual_meths[i]; - if !str::eq(e_meth.ident, a_meth.ident) { + if !istr::eq(e_meth.ident, a_meth.ident) { ret ures_err(terr_obj_meths(e_meth.ident, a_meth.ident)); } let r = @@ -2412,7 +2413,7 @@ mod unify { none. { ret ures_err(terr_record_mutability); } some(m) { mut = m; } } - if !str::eq(expected_field.ident, actual_field.ident) { + if !istr::eq(expected_field.ident, actual_field.ident) { let err = terr_record_fields(expected_field.ident, actual_field.ident); @@ -2622,14 +2623,14 @@ fn type_err_to_str(err: &ty::type_err) -> str { } terr_record_mutability. { ret "record elements differ in mutability"; } terr_record_fields(e_fld, a_fld) { - ret "expected a record with field '" + e_fld + - "' but found one with field '" + a_fld + "'"; + ret "expected a record with field '" + istr::to_estr(e_fld) + + "' but found one with field '" + istr::to_estr(a_fld) + "'"; } terr_arg_count. { ret "incorrect number of function parameters"; } terr_meth_count. { ret "incorrect number of object methods"; } terr_obj_meths(e_meth, a_meth) { - ret "expected an obj with method '" + e_meth + - "' but found one with method '" + a_meth + "'"; + ret "expected an obj with method '" + istr::to_estr(e_meth) + + "' but found one with method '" + istr::to_estr(a_meth) + "'"; } terr_mode_mismatch(e_mode, a_mode) { ret "expected argument mode " + mode_str_1(e_mode) + " but found " + diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 5a71c99cec2d..4ae6ecd003ff 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -107,7 +107,7 @@ fn lookup_def(fcx: &@fn_ctxt, sp: &span, id: ast::node_id) -> ast::def { fn ident_for_local(loc: &@ast::local) -> ast::ident { ret alt loc.node.pat.node { ast::pat_bind(name) { name } - _ { "local" } + _ { ~"local" } }; // FIXME DESTR } @@ -626,7 +626,7 @@ mod collect { ty_params: &[ast::ty_param]) -> ty::ty_param_kinds_and_ty { let methods = get_obj_method_types(cx, ob); let t_obj = ty::mk_obj(cx.tcx, ty::sort_methods(methods)); - t_obj = ty::rename(cx.tcx, t_obj, id); + t_obj = ty::rename(cx.tcx, t_obj, istr::to_estr(id)); ret {kinds: ty_param_kinds(ty_params), ty: t_obj}; } fn ty_of_obj_ctor(cx: @ctxt, id: &ast::ident, ob: &ast::_obj, @@ -1322,7 +1322,7 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast_util::pat_id_map, pat: &@ast::pat, let vid = lookup_local(fcx, pat.span, pat.id); let typ = ty::mk_var(fcx.ccx.tcx, vid); typ = demand::simple(fcx, pat.span, expected, typ); - let canon_id = map.get(istr::from_estr(name)); + let canon_id = map.get(name); if canon_id != pat.id { let ct = ty::mk_var(fcx.ccx.tcx, @@ -1429,8 +1429,8 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast_util::pat_id_map, pat: &@ast::pat, fields", ex_f_count, f_count]); } - fn matches(name: &str, f: &ty::field) -> bool { - ret str::eq(name, f.ident); + fn matches(name: &istr, f: &ty::field) -> bool { + ret istr::eq(name, f.ident); } for f: ast::field_pat in fields { alt vec::find(bind matches(f.ident, _), ex_fields) { @@ -1439,7 +1439,7 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast_util::pat_id_map, pat: &@ast::pat, fcx.ccx.tcx.sess.span_fatal(pat.span, #fmt["mismatched types: did not \ expect a record with a field %s", - f.ident]); + istr::to_estr(f.ident)]); } } } @@ -2255,7 +2255,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier, for f: spanned in fields_t { let found = false; for bf: ty::field in base_fields { - if str::eq(f.node.ident, bf.ident) { + if istr::eq(f.node.ident, bf.ident) { demand::simple(fcx, f.span, bf.mt.ty, f.node.mt.ty); found = true; } @@ -2263,7 +2263,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier, if !found { tcx.sess.span_fatal(f.span, "unknown field in record update: " + - f.node.ident); + istr::to_estr(f.node.ident)); } } } @@ -2419,7 +2419,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier, option::t { for om: @ast::method in outer_obj_methods { - if str::eq(om.node.ident, m.ident) { + if istr::eq(om.node.ident, m.ident) { // We'd better be overriding with one of the same // type. Check to make sure. let new_type = ty_of_method(ccx, om); @@ -2427,7 +2427,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier, ccx.tcx.sess.span_fatal( om.span, "Attempted to override method " - + m.ident + + + istr::to_estr(m.ident) + " with one of a different type"); } ret none; @@ -2504,7 +2504,7 @@ fn check_decl_local(fcx: &@fn_ctxt, local: &@ast::local) -> bool { alt fcx.locals.find(local.node.id) { none. { fcx.ccx.tcx.sess.bug("check_decl_local: local id not found " + - ident_for_local(local)); + istr::to_estr(ident_for_local(local))); } some(i) { let t = ty::mk_var(fcx.ccx.tcx, i); diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index d380fbecdb48..4009ff2bd4ed 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -7,7 +7,7 @@ import codemap::filename; type spanned = {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; diff --git a/src/comp/syntax/ast_util.rs b/src/comp/syntax/ast_util.rs index 687070da24fc..72a633da9282 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::(); 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 466f55e60e63..0b88d09ec4d8 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 542b28054029..6a80b0b6cb29 100644 --- a/src/comp/syntax/ext/expand.rs +++ b/src/comp/syntax/ext/expand.rs @@ -24,10 +24,11 @@ fn expand_expr(exts: &hashmap, 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 c70ea3234c48..093799714a79 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 4eb381762fe9..0664987e5309 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 b0d7cd260200..94d814ae9c84 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 = new_str_hash::<()>(); fn mark_ident(i: &ident, _fld: ast_fold, b: &bindings, idents: &hashmap) -> 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 = none; + let macro_name: option::t = 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 18d9a04ebbf8..ccb7f0cfde2f 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 c0beb8a32c3c..85f809ef9653 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 { 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::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 9dcd56407f74..530b16a20377 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::, inputs, output, cf, constrs); + print_ty_fn(s, proto, none::, 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, +fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t, 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 { diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs index f531f4c1e0c4..7afad61064da 100644 --- a/src/comp/util/common.rs +++ b/src/comp/util/common.rs @@ -70,11 +70,11 @@ fn log_block_err(b: &ast::blk) { log_err print::pprust::block_to_str(b); } fn log_item_err(i: &@ast::item) { log_err print::pprust::item_to_str(i); } -fn log_fn(f: &ast::_fn, name: str, params: &[ast::ty_param]) { +fn log_fn(f: &ast::_fn, name: &ast::ident, params: &[ast::ty_param]) { log print::pprust::fun_to_str(f, name, params); } -fn log_fn_err(f: &ast::_fn, name: str, params: &[ast::ty_param]) { +fn log_fn_err(f: &ast::_fn, name: &ast::ident, params: &[ast::ty_param]) { log_err print::pprust::fun_to_str(f, name, params); } @@ -154,8 +154,8 @@ fn call_kind_str(c: call_kind) -> str { } } -fn is_main_name(path: &[str]) -> bool { - str::eq(option::get(std::vec::last(path)), "main") +fn is_main_name(path: &[ast::ident]) -> bool { + istr::eq(option::get(std::vec::last(path)), ~"main") } // FIXME mode this to std::float when editing the stdlib no longer diff --git a/src/comp/util/ppaux.rs b/src/comp/util/ppaux.rs index 259482bc9b3e..88d419ae0cea 100644 --- a/src/comp/util/ppaux.rs +++ b/src/comp/util/ppaux.rs @@ -38,16 +38,16 @@ fn mode_str_1(m: &ty::mode) -> str { fn fn_ident_to_string(id: ast::node_id, i: &ast::fn_ident) -> str { ret alt i { none. { istr::to_estr(~"anon" + int::str(id)) } - some(s) { s } + some(s) { istr::to_estr(s) } }; } fn get_id_ident(cx: &ctxt, id: ast::def_id) -> str { if id.crate != ast::local_crate { - str::connect(cx.ext_map.get(id), "::") + str::connect(istr::to_estrs(cx.ext_map.get(id)), "::") } else { alt cx.items.find(id.node) { - some(ast_map::node_item(it)) { it.ident } + some(ast_map::node_item(it)) { istr::to_estr(it.ident) } _ { fail "get_id_ident: can't find item in ast_map" } } } @@ -63,7 +63,13 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str { inputs: &[arg], output: t, cf: ast::controlflow, constrs: &[@constr]) -> str { let s = proto_to_str(proto); - alt ident { some(i) { s += " "; s += i; } _ { } } + alt ident { + some(i) { + s += " "; + s += istr::to_estr(i); + } + _ { } + } s += "("; let strs = []; for a: arg in inputs { strs += [fn_input_to_str(cx, a)]; } @@ -83,7 +89,7 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str { m.output, m.cf, m.constrs) + ";"; } fn field_to_str(cx: &ctxt, f: &field) -> str { - ret f.ident + ": " + mt_to_str(cx, f.mt); + ret istr::to_estr(f.ident) + ": " + mt_to_str(cx, f.mt); } fn mt_to_str(cx: &ctxt, m: &mt) -> str { let mstr;