From 7661c08496b0dc9ce55657246f8e5e42051c812e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 6 Jul 2011 16:46:17 +0200 Subject: [PATCH] Remove temporary stdlib placeholders, use actual stdlib functions (Possible now that a snapshot took place.) --- src/comp/back/x86.rs | 1 - src/comp/driver/rustc.rs | 2 +- src/comp/lib/llvm.rs | 7 ++--- src/comp/metadata/creader.rs | 2 +- src/comp/metadata/tyencode.rs | 5 ++-- src/comp/middle/alias.rs | 2 +- src/comp/middle/resolve.rs | 4 +-- src/comp/middle/trans.rs | 10 +++---- src/comp/middle/tstate/annotate.rs | 12 ++++---- src/comp/middle/tstate/auxiliary.rs | 21 ++++++++------ src/comp/middle/tstate/collect_locals.rs | 8 ++--- src/comp/middle/tstate/pre_post_conditions.rs | 4 +-- src/comp/middle/tstate/states.rs | 1 - src/comp/middle/typeck.rs | 4 +-- src/comp/rustc.rc | 1 - src/comp/syntax/_std.rs | 29 ------------------- src/comp/syntax/ext/base.rs | 2 +- src/comp/syntax/parse/parser.rs | 2 +- src/comp/syntax/parse/token.rs | 2 +- src/comp/syntax/print/pprust.rs | 10 +++---- src/comp/util/ppaux.rs | 11 ++++--- 21 files changed, 53 insertions(+), 87 deletions(-) delete mode 100644 src/comp/syntax/_std.rs diff --git a/src/comp/back/x86.rs b/src/comp/back/x86.rs index 018c99e153a..018ae876ea6 100644 --- a/src/comp/back/x86.rs +++ b/src/comp/back/x86.rs @@ -4,7 +4,6 @@ import lib::llvm::llvm::ModuleRef; import std::str; import std::vec; import std::os::target_os; -import syntax::_std::istr; fn get_module_asm() -> str { ret ""; } diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 5f410678fdf..80b94be4c53 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -343,7 +343,7 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) -> fn build_session(@session::options sopts) -> session::session { auto target_cfg = build_target_config(); - auto crate_cache = syntax::_std::new_int_hash[session::crate_metadata](); + auto crate_cache = std::map::new_int_hash[session::crate_metadata](); ret session::session(target_cfg, sopts, crate_cache, [], [], [], codemap::new_codemap(), 0u); } diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs index 8a9c5aa5857..0674d3a2463 100644 --- a/src/comp/lib/llvm.rs +++ b/src/comp/lib/llvm.rs @@ -1457,7 +1457,7 @@ state obj type_names(std::map::hashmap[TypeRef, str] type_names, } fn mk_type_names() -> type_names { - auto nt = syntax::_std::new_str_hash[TypeRef](); + auto nt = std::map::new_str_hash[TypeRef](); fn hash(&TypeRef t) -> uint { ret t as uint; @@ -1519,8 +1519,7 @@ fn type_to_str_inner(type_names names, case (6) { ret "Label"; } case (7) { - ret "i" + syntax::_std::istr(llvm::LLVMGetIntTypeWidth(ty) - as int); + ret "i" + std::int::str(llvm::LLVMGetIntTypeWidth(ty) as int); } case (8) { @@ -1558,7 +1557,7 @@ fn type_to_str_inner(type_names names, i += 1u; if (tout as int == ty as int) { let uint n = vec::len[TypeRef](outer0) - i; - ret "*\\" + syntax::_std::istr(n as int); + ret "*\\" + std::int::str(n as int); } } ret "*" + type_to_str_inner(names, outer, diff --git a/src/comp/metadata/creader.rs b/src/comp/metadata/creader.rs index f2f9a358713..7ef50e2b418 100644 --- a/src/comp/metadata/creader.rs +++ b/src/comp/metadata/creader.rs @@ -201,7 +201,7 @@ fn read_crates(session::session sess, resolve::crate_map crate_map, auto e = @rec(sess=sess, crate_map=crate_map, - crate_cache=@syntax::_std::new_str_hash[int](), + crate_cache=@std::map::new_str_hash[int](), library_search_paths=sess.get_opts().library_search_paths, mutable next_crate_num=1); auto v = diff --git a/src/comp/metadata/tyencode.rs b/src/comp/metadata/tyencode.rs index af7f3f67118..f6ea1a89719 100644 --- a/src/comp/metadata/tyencode.rs +++ b/src/comp/metadata/tyencode.rs @@ -4,6 +4,7 @@ import std::io; import std::map::hashmap; import std::option::some; import std::option::none; +import std::int; import std::uint; import syntax::ast::*; import middle::ty; @@ -182,7 +183,7 @@ fn enc_sty(&io::writer w, &@ctxt cx, &ty::sty st) { } case (ty::ty_var(?id)) { w.write_char('X'); - w.write_str(syntax::_std::istr(id)); + w.write_str(int::str(id)); } case (ty::ty_native(?def)) { w.write_char('E'); @@ -191,7 +192,7 @@ fn enc_sty(&io::writer w, &@ctxt cx, &ty::sty st) { } case (ty::ty_param(?id)) { w.write_char('p'); - w.write_str(syntax::_std::uistr(id)); + w.write_str(uint::str(id)); } case (ty::ty_type) { w.write_char('Y'); } case (ty::ty_task) { w.write_char('a'); } diff --git a/src/comp/middle/alias.rs b/src/comp/middle/alias.rs index e419426c969..0c2200d9771 100644 --- a/src/comp/middle/alias.rs +++ b/src/comp/middle/alias.rs @@ -45,7 +45,7 @@ fn check_crate(@ty::ctxt tcx, &@ast::crate crate) { // Stores information about object fields and function // arguments that's otherwise not easily available. - local_map=syntax::_std::new_int_hash()); + local_map=std::map::new_int_hash()); auto v = @rec(visit_fn=bind visit_fn(cx, _, _, _, _, _, _, _), visit_item=bind visit_item(cx, _, _, _), diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 2e3ed812900..9bab6e6e067 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -11,8 +11,8 @@ import metadata::creader; import metadata::decoder; import driver::session::session; import util::common::new_def_hash; -import syntax::_std::new_int_hash; -import syntax::_std::new_str_hash; +import std::map::new_int_hash; +import std::map::new_str_hash; import syntax::codemap::span; import syntax::ast::respan; import middle::ty::constr_table; diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 7e3d1aa9d76..7647ccd23fe 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -36,10 +36,9 @@ import middle::ty::pat_ty; import syntax::visit; import visit::vt; import util::common; -import syntax::_std::istr; import util::common::new_def_hash; -import syntax::_std::new_int_hash; -import syntax::_std::new_str_hash; +import std::map::new_int_hash; +import std::map::new_str_hash; import util::common::local_rhs_span; import syntax::codemap::span; import lib::llvm::llvm; @@ -73,7 +72,7 @@ import syntax::print::pprust::expr_to_str; import syntax::print::pprust::path_to_str; obj namegen(mutable int i) { - fn next(str prefix) -> str { i += 1; ret prefix + istr(i); } + fn next(str prefix) -> str { i += 1; ret prefix + int::str(i); } } type derived_tydesc_info = rec(ValueRef lltydesc, bool escapes); @@ -4432,7 +4431,8 @@ fn build_environment(&@block_ctxt cx, &vec[ast::node_id] upvars) -> case (some(?x)) { llbinding = x; } case (_) { cx.fcx.lcx.ccx.sess.bug("unbound var \ - in build_environment " + istr(nid)); } + in build_environment " + int::str(nid)); + } } } case (some(?llval)) { llbinding = llval; } diff --git a/src/comp/middle/tstate/annotate.rs b/src/comp/middle/tstate/annotate.rs index abffc3a97e3..6f3b29716ec 100644 --- a/src/comp/middle/tstate/annotate.rs +++ b/src/comp/middle/tstate/annotate.rs @@ -3,12 +3,12 @@ import std::vec; import std::option; import std::option::some; import std::option::none; +import std::int; +import std::uint; import syntax::ast::*; import syntax::walk; import syntax::codemap::span; -import syntax::_std::istr; -import syntax::_std::uistr; -import syntax::_std::new_str_hash; +import std::map::new_str_hash; import util::common::log_expr_err; import util::common::log_block_err; import util::common::log_item_err; @@ -35,12 +35,12 @@ fn collect_ids_block(&block b, @mutable vec[node_id] rs) { fn collect_ids_stmt(&@stmt s, @mutable vec[node_id] rs) { alt (s.node) { case (stmt_decl(_, ?id)) { - log "node_id " + istr(id); + log "node_id " + int::str(id); log_stmt(*s); vec::push(*rs, id); } case (stmt_expr(_, ?id)) { - log "node_id " + istr(id); + log "node_id " + int::str(id); log_stmt(*s); vec::push(*rs, id); } @@ -65,7 +65,7 @@ fn node_ids_in_fn(&_fn f, &vec[ty_param] tps, &span sp, &fn_ident i, fn init_vecs(&crate_ctxt ccx, &vec[node_id] node_ids, uint len) { for (node_id i in node_ids) { - log istr(i) + " |-> " + uistr(len); + log int::str(i) + " |-> " + uint::str(len); add_node(ccx, i, empty_ann(len)); } } diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs index 123f51e7a70..0bc1ceb3951 100644 --- a/src/comp/middle/tstate/auxiliary.rs +++ b/src/comp/middle/tstate/auxiliary.rs @@ -7,15 +7,15 @@ import std::option; import std::option::none; import std::option::some; import std::option::maybe; +import std::int; +import std::uint; import syntax::ast::*; import syntax::codemap::span; import util::common; import util::common::log_block; -import syntax::_std::new_int_hash; -import syntax::_std::new_uint_hash; +import std::map::new_int_hash; +import std::map::new_uint_hash; import util::common::log_expr_err; -import syntax::_std::istr; -import syntax::_std::uistr; import util::common::lit_eq; import syntax::print::pprust::path_to_str; import tstate::ann::pre_and_post; @@ -44,7 +44,9 @@ import syntax::print::pprust::lit_to_str; /* logging funs */ -fn def_id_to_str(def_id d) -> str { ret istr(d._0) + "," + istr(d._1); } +fn def_id_to_str(def_id d) -> str { + ret int::str(d._0) + "," + int::str(d._1); +} fn comma_str(vec[@constr_arg_use] args) -> str { auto rslt = ""; @@ -259,7 +261,8 @@ fn get_ts_ann(&crate_ctxt ccx, node_id i) -> option::t[ts_ann] { fn node_id_to_ts_ann(&crate_ctxt ccx, node_id id) -> ts_ann { alt (get_ts_ann(ccx, id)) { case (none) { - log_err "node_id_to_ts_ann: no ts_ann for node_id " + istr(id); + log_err "node_id_to_ts_ann: no ts_ann for node_id " + + int::str(id); fail; } case (some(?t)) { ret t; } @@ -460,7 +463,7 @@ fn constraints_expr(&ty::ctxt cx, @expr e) -> vec[@ty::constr_def] { fn node_id_to_def_strict(&ty::ctxt cx, node_id id) -> def { alt (cx.def_map.find(id)) { case (none) { - log_err "node_id_to_def: node_id " + istr(id) + " has no def"; + log_err "node_id_to_def: node_id " + int::str(id) + " has no def"; fail; } case (some(?d)) { ret d; } @@ -518,7 +521,7 @@ fn match_args(&fn_ctxt fcx, vec[pred_desc] occs, vec[@constr_arg_use] occ) -> fn node_id_for_constr(ty::ctxt tcx, node_id t) -> node_id { alt (tcx.def_map.find(t)) { case (none) { - tcx.sess.bug("node_id_for_constr: bad node_id " + istr(t)); + tcx.sess.bug("node_id_for_constr: bad node_id " + int::str(t)); } case (some(def_fn(?i,_))) { ret i._1; } case (_) { @@ -590,7 +593,7 @@ fn expr_to_constr(ty::ctxt tcx, &@expr e) -> constr { } fn pred_desc_to_str(&pred_desc p) -> str { - ret "<" + uistr(p.node.bit_num) + ", " + + ret "<" + uint::str(p.node.bit_num) + ", " + constr_args_to_str(std::util::fst[ident, def_id], p.node.args) + ">"; } diff --git a/src/comp/middle/tstate/collect_locals.rs b/src/comp/middle/tstate/collect_locals.rs index e3b4f0421d4..764c66e52a0 100644 --- a/src/comp/middle/tstate/collect_locals.rs +++ b/src/comp/middle/tstate/collect_locals.rs @@ -21,9 +21,8 @@ import aux::constr_map; import aux::expr_to_constr; import aux::constraints_expr; import aux::node_id_to_def_strict; -import syntax::_std::new_int_hash; +import std::map::new_int_hash; import util::common::new_def_hash; -import syntax::_std::uistr; import syntax::codemap::span; import syntax::ast::respan; @@ -82,7 +81,7 @@ fn find_locals(&ty::ctxt tcx, &_fn f, &vec[ty_param] tps, fn add_constraint(&ty::ctxt tcx, aux::constr c, uint next, constr_map tbl) -> uint { - log aux::constraint_to_str(tcx, c) + " |-> " + uistr(next); + log aux::constraint_to_str(tcx, c) + " |-> " + std::uint::str(next); alt (c.node.c) { case (ninit(?i)) { tbl.insert(c.node.id, cinit(next, c.span, i)); } case (npred(?p, ?args)) { @@ -142,7 +141,8 @@ fn mk_fn_info(&crate_ctxt ccx, &_fn f, &vec[ty_param] tp, cf=f.decl.cf, used_vars=v); ccx.fm.insert(id, rslt); - log name + " has " + uistr(num_constraints(rslt)) + " constraints"; + log 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 9ce0d7ce5eb..d183ef28a73 100644 --- a/src/comp/middle/tstate/pre_post_conditions.rs +++ b/src/comp/middle/tstate/pre_post_conditions.rs @@ -66,10 +66,8 @@ import bitvectors::gen_poststate; import bitvectors::relax_precond_block; import bitvectors::gen; import syntax::ast::*; -import syntax::_std::new_int_hash; +import std::map::new_int_hash; import util::common::new_def_hash; -import syntax::_std::istr; -import syntax::_std::uistr; import util::common::log_expr; import util::common::log_fn; import util::common::elt_exprs; diff --git a/src/comp/middle/tstate/states.rs b/src/comp/middle/tstate/states.rs index ff999c1aa1c..d75c5a43f2e 100644 --- a/src/comp/middle/tstate/states.rs +++ b/src/comp/middle/tstate/states.rs @@ -80,7 +80,6 @@ import middle::ty::expr_ty; import middle::ty::type_is_nil; import middle::ty::type_is_bot; import util::common::new_def_hash; -import syntax::_std::uistr; import util::common::log_expr; import util::common::log_block; import util::common::log_block_err; diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 54ce0ffffc9..aa950769863 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -9,7 +9,7 @@ import metadata::decoder; import driver::session; import util::common; import syntax::codemap::span; -import syntax::_std::new_int_hash; +import std::map::new_int_hash; import util::common::new_def_hash; import util::common::log_expr_err; import middle::ty; @@ -537,7 +537,7 @@ mod collect { } case (_) { cx.tcx.sess.fatal("internal error " + - syntax::_std::istr(id._1)); + std::int::str(id._1)); } } ret tpt; diff --git a/src/comp/rustc.rc b/src/comp/rustc.rc index d79c221013a..fe97761cf8c 100644 --- a/src/comp/rustc.rc +++ b/src/comp/rustc.rc @@ -37,7 +37,6 @@ mod middle { mod syntax { - mod _std; // FIXME remove mod ast; mod fold; mod walk; diff --git a/src/comp/syntax/_std.rs b/src/comp/syntax/_std.rs deleted file mode 100644 index fb4d1449a99..00000000000 --- a/src/comp/syntax/_std.rs +++ /dev/null @@ -1,29 +0,0 @@ -// FIXME all this stuff should be in the standard lib, and in fact is, -// but due to the way our snapshots currently work, rustc can't use it -// until after the next snapshot. - -fn new_str_hash[V]() -> std::map::hashmap[str, V] { - let std::map::hashfn[str] hasher = std::str::hash; - let std::map::eqfn[str] eqer = std::str::eq; - ret std::map::mk_hashmap[str, V](hasher, eqer); -} - -fn new_int_hash[V]() -> std::map::hashmap[int, V] { - fn hash_int(&int x) -> uint { ret x as uint; } - fn eq_int(&int a, &int b) -> bool { ret a == b; } - auto hasher = hash_int; - auto eqer = eq_int; - ret std::map::mk_hashmap[int, V](hasher, eqer); -} - -fn new_uint_hash[V]() -> std::map::hashmap[uint, V] { - fn hash_uint(&uint x) -> uint { ret x; } - fn eq_uint(&uint a, &uint b) -> bool { ret a == b; } - auto hasher = hash_uint; - auto eqer = eq_uint; - ret std::map::mk_hashmap[uint, V](hasher, eqer); -} - -fn istr(int i) -> str { ret std::int::to_str(i, 10u); } - -fn uistr(uint i) -> str { ret std::uint::to_str(i, 10u); } diff --git a/src/comp/syntax/ext/base.rs b/src/comp/syntax/ext/base.rs index 719e96f5fe6..a0ba306edfa 100644 --- a/src/comp/syntax/ext/base.rs +++ b/src/comp/syntax/ext/base.rs @@ -3,7 +3,7 @@ import std::option; import std::map::hashmap; import parse::parser::parse_sess; import codemap::span; -import syntax::_std::new_str_hash; +import std::map::new_str_hash; import codemap; type syntax_expander = diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index b671e9eaa69..dc19a507db5 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -12,7 +12,7 @@ import std::map::hashmap; import token::can_begin_expr; import ex=ext::base; import codemap::span; -import _std::new_str_hash; +import std::map::new_str_hash; import util::interner; tag restriction { UNRESTRICTED; RESTRICT_NO_CALL_EXPRS; } diff --git a/src/comp/syntax/parse/token.rs b/src/comp/syntax/parse/token.rs index b8ea07d50db..2ce5d9e6cb4 100644 --- a/src/comp/syntax/parse/token.rs +++ b/src/comp/syntax/parse/token.rs @@ -1,7 +1,7 @@ import ast::ty_mach; import ast::ty_mach_to_str; -import _std::new_str_hash; +import std::map::new_str_hash; import util::interner; import std::int; import std::uint; diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index b5f83c2009c..86ae4cbd295 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -8,8 +8,6 @@ import std::option; import parse::lexer; import syntax::codemap::codemap; import ast; -import _std::istr; -import _std::uistr; import option::some; import option::none; import pp::printer; @@ -1294,11 +1292,11 @@ fn print_literal(&ps s, &@ast::lit lit) { word(s.s, "'" + escape_str(str::from_bytes([ch as u8]), '\'') + "'"); } - case (ast::lit_int(?val)) { word(s.s, istr(val)); } - case (ast::lit_uint(?val)) { word(s.s, uistr(val) + "u"); } + case (ast::lit_int(?val)) { word(s.s, int::str(val)); } + case (ast::lit_uint(?val)) { word(s.s, uint::str(val) + "u"); } case (ast::lit_float(?fstr)) { word(s.s, fstr); } case (ast::lit_mach_int(?mach, ?val)) { - word(s.s, istr(val as int)); + word(s.s, int::str(val as int)); word(s.s, ast::ty_mach_to_str(mach)); } case (ast::lit_mach_float(?mach, ?val)) { @@ -1446,7 +1444,7 @@ fn constr_arg_to_str[T](fn(&T) -> str f, &ast::constr_arg_general_[T] c) -> // needed b/c constr_args_to_str needs // something that takes an alias // (argh) -fn uint_to_str(&uint i) -> str { ret uistr(i); } +fn uint_to_str(&uint i) -> str { ret uint::str(i); } fn ast_constr_to_str(&@ast::constr c) -> str { ret ast::path_to_str(c.node.path) + diff --git a/src/comp/util/ppaux.rs b/src/comp/util/ppaux.rs index 4adc6c437db..e3eb707dbf5 100644 --- a/src/comp/util/ppaux.rs +++ b/src/comp/util/ppaux.rs @@ -1,6 +1,7 @@ import std::io; import std::vec; import std::str; +import std::int; import std::option; import std::option::none; import std::option::some; @@ -12,8 +13,6 @@ import pp::word; import pp::eof; import pp::zerobreak; import pp::hardbreak; -import syntax::_std::istr; -import syntax::_std::uistr; import ast::ty_mach_to_str; import syntax::ast; @@ -34,7 +33,7 @@ fn mode_str_1(&ty::mode m) -> str { fn fn_ident_to_string(ast::node_id id, &ast::fn_ident i) -> str { ret alt (i) { - case (none) { "anon" + istr(id) } + case (none) { "anon" + int::str(id) } case (some(?s)) { s } }; } @@ -118,7 +117,7 @@ fn ty_to_str(&ctxt cx, &t typ) -> str { case (ty_tag(?id, ?tps)) { // The user should never see this if the cname is set properly! - s += ""; + s += ""; if (vec::len[t](tps) > 0u) { auto f = bind ty_to_str(cx, _); auto strs = vec::map[t, str](f, tps); @@ -138,9 +137,9 @@ fn ty_to_str(&ctxt cx, &t typ) -> str { s += "obj {\n\t" + str::connect(m, "\n\t") + "\n}"; } case (ty_res(?id, _, _)) { - s += ""; + s += ""; } - case (ty_var(?v)) { s += ""; } + case (ty_var(?v)) { s += ""; } case (ty_param(?id)) { s += "'" + str::unsafe_from_bytes([('a' as u8) + (id as u8)]); }