]> git.lizzy.rs Git - rust.git/commitdiff
Convert std::int to istrs. Issue #855
authorBrian Anderson <banderson@mozilla.com>
Wed, 24 Aug 2011 04:17:20 +0000 (21:17 -0700)
committerBrian Anderson <banderson@mozilla.com>
Sat, 27 Aug 2011 22:53:08 +0000 (15:53 -0700)
20 files changed:
src/comp/driver/rustc.rs
src/comp/lib/llvm.rs
src/comp/metadata/tyencode.rs
src/comp/middle/freevars.rs
src/comp/middle/trans_common.rs
src/comp/middle/tstate/annotate.rs
src/comp/middle/tstate/auxiliary.rs
src/comp/middle/ty.rs
src/comp/middle/typeck.rs
src/comp/syntax/ext/fmt.rs
src/comp/syntax/parse/token.rs
src/comp/syntax/print/pprust.rs
src/comp/util/ppaux.rs
src/lib/int.rs
src/lib/io.rs
src/test/bench/99bob-iter.rs
src/test/bench/99bob-pattern.rs
src/test/bench/99bob-simple.rs
src/test/bench/99bob-tail.rs
src/test/stdtest/int.rs

index 01f06c49ff08664ae681c4943ee00a30b2b1fbea..918fc05fb251ea72984459eb80b38722a8d9afa3 100644 (file)
@@ -27,6 +27,7 @@
 import std::option::some;
 import std::option::none;
 import std::str;
+import std::istr;
 import std::vec;
 import std::int;
 import std::io;
@@ -189,16 +190,18 @@ fn ann_identified_post(node: &pprust::ann_node) {
         alt node {
           pprust::node_item(s, item) {
             pp::space(s.s);
-            pprust::synth_comment(s, int::to_str(item.id, 10u));
+            pprust::synth_comment(
+                s, istr::to_estr(int::to_str(item.id, 10u)));
           }
           pprust::node_block(s, blk) {
             pp::space(s.s);
-            pprust::synth_comment(s,
-                                  "block " + int::to_str(blk.node.id, 10u));
+            pprust::synth_comment(
+                s, istr::to_estr(~"block " + int::to_str(blk.node.id, 10u)));
           }
           pprust::node_expr(s, expr) {
             pp::space(s.s);
-            pprust::synth_comment(s, int::to_str(expr.id, 10u));
+            pprust::synth_comment(
+                s, istr::to_estr(int::to_str(expr.id, 10u)));
             pprust::pclose(s);
           }
           _ { }
index 9faabc6f3c7b105db51d2386657825cfad6bf6df..591e2270cd24df5c2e3227fac2e34ef8510661e9 100644 (file)
@@ -1,5 +1,6 @@
 import std::vec;
 import std::str;
+import std::istr;
 import std::str::rustrt::sbuf;
 
 import llvm::ModuleRef;
@@ -976,7 +977,8 @@ fn tys_str(names: type_names, outer: &[TypeRef], tys: &[TypeRef]) -> str {
 
 
       7 {
-        ret "i" + std::int::str(llvm::LLVMGetIntTypeWidth(ty) as int);
+        ret "i" + istr::to_estr(std::int::str(
+            llvm::LLVMGetIntTypeWidth(ty) as int));
       }
 
 
@@ -1020,7 +1022,7 @@ fn tys_str(names: type_names, outer: &[TypeRef], tys: &[TypeRef]) -> str {
             i += 1u;
             if tout as int == ty as int {
                 let n: uint = vec::len::<TypeRef>(outer0) - i;
-                ret "*\\" + std::int::str(n as int);
+                ret "*\\" + istr::to_estr(std::int::str(n as int));
             }
         }
         ret "*" +
index 0a15b9e7346f5fd1c6b1d2e62aa6a098a613f21f..34a810adb3b2b209bc5372e62bd11780759440af 100644 (file)
@@ -172,7 +172,10 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
         for t: ty::t in tps { enc_ty(w, cx, t); }
         w.write_char(']');
       }
-      ty::ty_var(id) { w.write_char('X'); w.write_str(int::str(id)); }
+      ty::ty_var(id) {
+        w.write_char('X');
+        w.write_str(istr::to_estr(int::str(id)));
+      }
       ty::ty_native(def) {
         w.write_char('E');
         w.write_str(cx.ds(def));
index e8c146c5a851e165e717924004ba414337f5d3c9..7c68d121602e2c815d0c7d4ab906c2954a7d0c5b 100644 (file)
@@ -5,6 +5,7 @@
 import std::map::*;
 import std::option;
 import std::int;
+import std::istr;
 import std::option::*;
 import syntax::ast;
 import syntax::ast_util;
@@ -146,7 +147,10 @@ fn annotate_freevars(sess: &session::session, def_map: &resolve::def_map,
 
 fn get_freevar_info(tcx: &ty::ctxt, fid: ast::node_id) -> freevar_info {
     alt tcx.freevars.find(fid) {
-      none. { fail "get_freevars: " + int::str(fid) + " has no freevars"; }
+      none. {
+        fail "get_freevars: " + istr::to_estr(int::str(fid))
+            + " has no freevars";
+      }
       some(d) { ret d; }
     }
 }
index 7cc7edd9dcd7978f6a8bc09a9ef39318e365553a..614f371b9bbdf1f9f8e192293e81553920bc283f 100644 (file)
@@ -63,7 +63,9 @@
 import trans::drop_ty;
 
 obj namegen(mutable i: int) {
-    fn next(prefix: str) -> str { i += 1; ret prefix + int::str(i); }
+    fn next(prefix: str) -> str {
+        i += 1; ret prefix + istr::to_estr(int::str(i));
+    }
 }
 
 type derived_tydesc_info = {lltydesc: ValueRef, escapes: bool};
index 946366cd78c46335fc189e11b9c0fca086f4abec..e1c664528e9625084d8488c80a7b27c3568dfce9 100644 (file)
 fn collect_ids_stmt(s: &@stmt, rs: @mutable [node_id]) {
     alt s.node {
       stmt_decl(_, id) {
-        log "node_id " + int::str(id);
+        log ~"node_id " + int::str(id);
         log_stmt(*s);;
         *rs += [id];
       }
       stmt_expr(_, id) {
-        log "node_id " + int::str(id);
+        log ~"node_id " + int::str(id);
         log_stmt(*s);;
         *rs += [id];
       }
@@ -62,7 +62,7 @@ fn node_ids_in_fn(f: &_fn, tps: &[ty_param], sp: &span, i: &fn_ident,
 
 fn init_vecs(ccx: &crate_ctxt, node_ids: &[node_id], len: uint) {
     for i: node_id in node_ids {
-        log int::str(i) + " |-> " + istr::to_estr(uint::str(len));
+        log istr::to_estr(int::str(i) + ~" |-> " + uint::str(len));
         add_node(ccx, i, empty_ann(len));
     }
 }
index b8d125e59a9d8b39febfec9a6dcfcabe26267d25..49942eaef6bcf72c090d28973b04f132bfa7bf28 100644 (file)
@@ -57,7 +57,7 @@
 
 /* logging funs */
 fn def_id_to_str(d: def_id) -> str {
-    ret int::str(d.crate) + "," + int::str(d.node);
+    ret istr::to_estr(int::str(d.crate) + ~"," + int::str(d.node));
 }
 
 fn comma_str(args: &[@constr_arg_use]) -> str {
@@ -329,7 +329,8 @@ fn get_ts_ann(ccx: &crate_ctxt, i: node_id) -> option::t<ts_ann> {
 fn node_id_to_ts_ann(ccx: &crate_ctxt, id: node_id) -> ts_ann {
     alt get_ts_ann(ccx, id) {
       none. {
-        log_err "node_id_to_ts_ann: no ts_ann for node_id " + int::str(id);
+        log_err "node_id_to_ts_ann: no ts_ann for node_id "
+            + istr::to_estr(int::str(id));
         fail;
       }
       some(t) { ret t; }
@@ -531,7 +532,8 @@ fn constraints_expr(cx: &ty::ctxt, e: @expr) -> [@ty::constr] {
 fn node_id_to_def_upvar_strict(cx: &fn_ctxt, id: node_id) -> def {
     alt freevars::def_lookup(cx.ccx.tcx, cx.id, id) {
       none. {
-        log_err "node_id_to_def: node_id " + int::str(id) + " has no def";
+        log_err "node_id_to_def: node_id "
+            + istr::to_estr(int::str(id)) + " has no def";
         fail;
       }
       some(d) { ret d; }
@@ -540,7 +542,8 @@ fn node_id_to_def_upvar_strict(cx: &fn_ctxt, id: node_id) -> def {
 fn node_id_to_def_strict(cx: &ty::ctxt, id: node_id) -> def {
     alt cx.def_map.find(id) {
       none. {
-        log_err "node_id_to_def: node_id " + int::str(id) + " has no def";
+        log_err "node_id_to_def: node_id "
+            + istr::to_estr(int::str(id)) + " has no def";
         fail;
       }
       some(d) { ret d; }
@@ -601,7 +604,8 @@ fn match_args(fcx: &fn_ctxt, occs: &@mutable [pred_args],
 fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id {
     alt tcx.def_map.find(t) {
       none. {
-        tcx.sess.bug("node_id_for_constr: bad node_id " + int::str(t));
+        tcx.sess.bug("node_id_for_constr: bad node_id "
+                     + istr::to_estr(int::str(t)));
       }
       some(def_fn(i, _)) { ret i; }
       _ { tcx.sess.bug("node_id_for_constr: pred is not a function"); }
index 3a446c4dc6a346464f2899919d44c269013c0c2f..1617dea99c08b86a0acbcdbc069bd6ae751d1458 100644 (file)
@@ -1629,8 +1629,9 @@ fn node_id_to_ty_param_substs_opt_and_ty(cx: &ctxt, id: &ast::node_id) ->
     alt smallintmap::find(*cx.node_types, id as uint) {
       none. {
         cx.sess.bug("node_id_to_ty_param_substs_opt_and_ty() called on " +
-                        "an untyped node (" + std::int::to_str(id, 10u) +
-                        ")");
+                    "an untyped node (" +
+                    istr::to_estr(std::int::to_str(id, 10u)) +
+                    ")");
       }
       some(tpot) { ret tpot; }
     }
index 7519e2541f584011fc3002773b0c8237f46840d5..1985928442bf114e52235bad17c4bf3bbaaab7bd 100644 (file)
@@ -37,6 +37,7 @@
 import std::int;
 import std::vec;
 import std::str;
+import std::istr;
 import std::uint;
 import std::map;
 import std::map::hashmap;
@@ -586,7 +587,10 @@ fn getter(cx: @ctxt, id: &ast::def_id) -> ty::ty_param_kinds_and_ty {
           some(ast_map::node_native_item(native_item)) {
             tpt = ty_of_native_item(cx, native_item, ast::native_abi_cdecl);
           }
-          _ { cx.tcx.sess.fatal("internal error " + std::int::str(id.node)); }
+          _ {
+            cx.tcx.sess.fatal(
+                "internal error " + istr::to_estr(std::int::str(id.node)));
+          }
         }
         ret tpt;
     }
@@ -2152,8 +2156,9 @@ fn check_binop_type_compat(fcx: &@fn_ctxt, span: span, ty: ty::t,
                     this_obj_sty = some(structure_of(fcx, expr.span, tpt.ty));
                   }
                   none. {
-                    tcx.sess.bug("didn't find " + int::str(did.node) +
-                                     " in type cache");
+                    tcx.sess.bug("didn't find " +
+                                 istr::to_estr(int::str(did.node)) +
+                                 " in type cache");
                   }
                 }
               }
index 9b8a1b616847f87289136a7b40d20cc84287cbec..c70ea3234c480211b2152eecb0c08f226052d69c 100644 (file)
@@ -7,6 +7,7 @@
  */
 import std::vec;
 import std::str;
+import std::istr;
 import std::option;
 import std::option::none;
 import std::option::some;
@@ -258,7 +259,10 @@ fn is_signed_type(cnv: conv) -> bool {
     }
     fn log_conv(c: conv) {
         alt c.param {
-          some(p) { log "param: " + std::int::to_str(p, 10u); }
+          some(p) {
+            log "param: "
+                + istr::to_estr(std::int::to_str(p, 10u));
+          }
           _ { log "param: none"; }
         }
         for f: flag in c.flags {
@@ -271,17 +275,21 @@ fn log_conv(c: conv) {
             }
         }
         alt c.width {
-          count_is(i) { log "width: count is " + std::int::to_str(i, 10u); }
+          count_is(i) { log "width: count is "
+              + istr::to_estr(std::int::to_str(i, 10u)); }
           count_is_param(i) {
-            log "width: count is param " + std::int::to_str(i, 10u);
+            log "width: count is param "
+                + istr::to_estr(std::int::to_str(i, 10u));
           }
           count_is_next_param. { log "width: count is next param"; }
           count_implied. { log "width: count is implied"; }
         }
         alt c.precision {
-          count_is(i) { log "prec: count is " + std::int::to_str(i, 10u); }
+          count_is(i) { log "prec: count is "
+              + istr::to_estr(std::int::to_str(i, 10u)); }
           count_is_param(i) {
-            log "prec: count is param " + std::int::to_str(i, 10u);
+            log "prec: count is param "
+                + istr::to_estr(std::int::to_str(i, 10u));
           }
           count_is_next_param. { log "prec: count is next param"; }
           count_implied. { log "prec: count is implied"; }
index 994c4e03b3424f7eafa392d10933404e232f9491..4fd5aa4453d12a005bb220557afeab88058d1b75 100644 (file)
@@ -145,11 +145,11 @@ fn to_str(r: lexer::reader, t: token) -> str {
 
       /* Literals */
       LIT_INT(i) {
-        ret int::to_str(i, 10u);
+        ret istr::to_estr(int::to_str(i, 10u));
       }
       LIT_UINT(u) { ret istr::to_estr(uint::to_str(u, 10u)); }
       LIT_MACH_INT(tm, i) {
-        ret int::to_str(i, 10u) + "_" + ty_mach_to_str(tm);
+        ret istr::to_estr(int::to_str(i, 10u)) + "_" + ty_mach_to_str(tm);
       }
       LIT_MACH_FLOAT(tm, s) {
         ret interner::get::<str>(*r.get_interner(), s) + "_" +
@@ -173,7 +173,7 @@ fn to_str(r: lexer::reader, t: token) -> str {
       IDENT(s, _) {
         ret interner::get::<str>(*r.get_interner(), s);
       }
-      IDX(i) { ret "_" + int::to_str(i, 10u); }
+      IDX(i) { ret istr::to_estr(~"_" + int::to_str(i, 10u)); }
       UNDERSCORE. { ret "_"; }
       BRACEQUOTE(_) { ret "<bracequote>"; }
       EOF. { ret "<eof>"; }
index 81220647288059a5588b1b6167c58677085b83f9..bf3942f1eab223e9fa5c6cad8589aba09f5f22b1 100644 (file)
@@ -1498,11 +1498,11 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
              "'" + escape_str(str::unsafe_from_bytes([ch as u8]), '\'') +
                  "'");
       }
-      ast::lit_int(val) { word(s.s, int::str(val)); }
+      ast::lit_int(val) { word(s.s, istr::to_estr(int::str(val))); }
       ast::lit_uint(val) { word(s.s, istr::to_estr(uint::str(val)) + "u"); }
       ast::lit_float(fstr) { word(s.s, fstr); }
       ast::lit_mach_int(mach, val) {
-        word(s.s, int::str(val as int));
+        word(s.s, istr::to_estr(int::str(val as int)));
         word(s.s, ast_util::ty_mach_to_str(mach));
       }
       ast::lit_mach_float(mach, val) {
index d5ad05fa6b01bb93fe966d89c35b997fada8ef4f..610b1a54b62cc67c409df17ae8427697bc769476 100644 (file)
@@ -1,5 +1,6 @@
 import std::vec;
 import std::str;
+import std::istr;
 import std::int;
 import std::option;
 import std::option::none;
@@ -35,7 +36,10 @@ 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. { "anon" + int::str(id) } some(s) { s } };
+    ret alt i {
+      none. { istr::to_estr(~"anon" + int::str(id)) }
+      some(s) { s }
+    };
 }
 
 fn get_id_ident(cx: &ctxt, id: ast::def_id) -> str {
@@ -139,7 +143,7 @@ fn mt_to_str(cx: &ctxt, m: &mt) -> str {
             "obj {\n\t" + str::connect(strs, "\n\t") + "\n}"
           }
           ty_res(id, _, _) { get_id_ident(cx, id) }
-          ty_var(v) { "<T" + int::str(v) + ">" }
+          ty_var(v) { istr::to_estr(~"<T" + int::str(v) + ~">") }
           ty_param(id, _) {
             "'" + str::unsafe_from_bytes([('a' as u8) + (id as u8)])
           }
index 937c60265854f2426a9a4185f3e5a4f9de36e223..902d5295dc19feaa43bce1c03de3d731afda1540 100644 (file)
     while lo_ < hi { put lo_; lo_ += 1; }
 }
 
-fn to_str(n: int, radix: uint) -> str {
+fn to_str(n: int, radix: uint) -> istr {
     assert (0u < radix && radix <= 16u);
     ret if n < 0 {
-            "-" + istr::to_estr(uint::to_str(-n as uint, radix))
-        } else { istr::to_estr(uint::to_str(n as uint, radix)) };
+            ~"-" + uint::to_str(-n as uint, radix)
+        } else { uint::to_str(n as uint, radix) };
 }
-fn str(i: int) -> str { ret to_str(i, 10u); }
+fn str(i: int) -> istr { ret to_str(i, 10u); }
 
 fn pow(base: int, exponent: uint) -> int {
     ret if exponent == 0u {
index b627342d0271aeb5efabc271e7bd95a3a395dd95..95945425a1d2143661b032273bdc54f742075b23 100644 (file)
@@ -337,7 +337,8 @@ fn write_char(ch: char) {
 
         out.write(str::bytes(str::from_char(ch)));
     }
-    fn write_int(n: int) { out.write(str::bytes(int::to_str(n, 10u))); }
+    fn write_int(n: int) { out.write(str::bytes(
+        istr::to_estr(int::to_str(n, 10u)))); }
     fn write_uint(n: uint) { out.write(str::bytes(
         istr::to_estr(uint::to_str(n, 10u)))); }
     fn write_bytes(bytes: &[u8]) { out.write(bytes); }
index aa79590a24687aeeca9f91397180b9eb59ee827b..47263b6cf27b311fcb1d059fdf28a7d5ac659a00 100644 (file)
@@ -7,6 +7,7 @@
 use std;
 import std::int;
 import std::str;
+import std::istr;
 
 fn b1() -> str { ret "# of beer on the wall, # of beer."; }
 
@@ -29,7 +30,7 @@ fn sub(t: str, n: int) -> str {
     alt n {
       0 { ns = "no more bottles"; }
       1 { ns = "1 bottle"; }
-      _ { ns = int::to_str(n, 10u) + " bottles"; }
+      _ { ns = istr::to_estr(int::to_str(n, 10u) + ~" bottles"); }
     }
     while i < str::byte_len(t) {
         if t[i] == '#' as u8 { b += ns; } else { str::push_byte(b, t[i]); }
index fdfce9dfae520711c735147491022ad44ef8ace6..c221ae2d8460b4537571910b995674615fe0907b 100644 (file)
@@ -7,6 +7,7 @@
 use std;
 import std::int;
 import std::str;
+import std::istr;
 
 tag bottle { none; dual; single; multiple(int); }
 
@@ -29,8 +30,8 @@ fn show(b: bottle) {
                 "1 bottle of beer on the wall.";
       }
       multiple(n) {
-        let nb: str = int::to_str(n, 10u);
-        let mb: str = int::to_str(n - 1, 10u);
+        let nb: str = istr::to_estr(int::to_str(n, 10u));
+        let mb: str = istr::to_estr(int::to_str(n - 1, 10u));
         log nb + " bottles of beer on the wall, " + nb + " bottles of beer,";
         log "Take one down and pass it around, " + mb +
                 " bottles of beer on the wall.";
index 2db6321d257a928b0e4e8f5615b036068697f0fc..af6f50a2901b58069de819bbe22cccfe8963e8eb 100644 (file)
@@ -7,6 +7,7 @@
 use std;
 import std::int;
 import std::str;
+import std::istr;
 
 fn b1() -> str { ret "# of beer on the wall, # of beer."; }
 
@@ -29,7 +30,7 @@ fn sub(t: str, n: int) -> str {
     alt n {
       0 { ns = "no more bottles"; }
       1 { ns = "1 bottle"; }
-      _ { ns = int::to_str(n, 10u) + " bottles"; }
+      _ { ns = istr::to_estr(int::to_str(n, 10u) + ~" bottles"); }
     }
     while i < str::byte_len(t) {
         if t[i] == '#' as u8 { b += ns; } else { str::push_byte(b, t[i]); }
index af5e22f48ea81443a531cc0214f4d0787fc9b97d..a3dd8628d9400f14d287b8ad30b96294b73332ab 100644 (file)
@@ -5,11 +5,12 @@
 use std;
 import std::int;
 import std::str;
+import std::istr;
 
 fn main() {
     fn multiple(n: int) {
-        let nb: str = int::to_str(n, 10u);
-        let mb: str = int::to_str(n - 1, 10u);
+        let nb: str = istr::to_estr(int::to_str(n, 10u));
+        let mb: str = istr::to_estr(int::to_str(n - 1, 10u));
         log nb + " bottles of beer on the wall, " + nb + " bottles of beer,";
         log "Take one down and pass it around, " + mb +
                 " bottles of beer on the wall.";
index 61d3448a175e9827806f920c4117c61bc7d47a7a..185c9db4a2e53531bab42d82c7d8a22903893521 100644 (file)
@@ -1,15 +1,15 @@
 
 use std;
 import std::int;
-import std::str::eq;
+import std::istr::eq;
 
 #[test]
 fn test_to_str() {
-    assert (eq(int::to_str(0, 10u), "0"));
-    assert (eq(int::to_str(1, 10u), "1"));
-    assert (eq(int::to_str(-1, 10u), "-1"));
-    assert (eq(int::to_str(255, 16u), "ff"));
-    assert (eq(int::to_str(100, 10u), "100"));
+    assert (eq(int::to_str(0, 10u), ~"0"));
+    assert (eq(int::to_str(1, 10u), ~"1"));
+    assert (eq(int::to_str(-1, 10u), ~"-1"));
+    assert (eq(int::to_str(255, 16u), ~"ff"));
+    assert (eq(int::to_str(100, 10u), ~"100"));
 }
 
 #[test]