rustc: Remove all fixed-length strings from our codebase
This commit is contained in:
parent
b3933b8822
commit
dfe1f6260e
@ -402,7 +402,7 @@ class bitv {
|
||||
*/
|
||||
fn to_str() -> ~str {
|
||||
let mut rs = ~"";
|
||||
for self.each() |i| { if i { rs += "1"; } else { rs += "0"; } };
|
||||
for self.each() |i| { if i { rs += ~"1"; } else { rs += ~"0"; } };
|
||||
rs
|
||||
}
|
||||
|
||||
|
@ -331,22 +331,22 @@ mod chained {
|
||||
impl hashmap<K: copy to_str, V: to_str copy> of to_str for t<K, V> {
|
||||
fn to_writer(wr: io::writer) {
|
||||
if self.count == 0u {
|
||||
wr.write_str("{}");
|
||||
wr.write_str(~"{}");
|
||||
return;
|
||||
}
|
||||
|
||||
wr.write_str("{ ");
|
||||
wr.write_str(~"{ ");
|
||||
let mut first = true;
|
||||
for self.each_entry |entry| {
|
||||
if !first {
|
||||
wr.write_str(", ");
|
||||
wr.write_str(~", ");
|
||||
}
|
||||
first = false;
|
||||
wr.write_str(entry.key.to_str());
|
||||
wr.write_str(": ");
|
||||
wr.write_str(~": ");
|
||||
wr.write_str((copy entry.value).to_str());
|
||||
};
|
||||
wr.write_str(" }");
|
||||
wr.write_str(~" }");
|
||||
}
|
||||
|
||||
fn to_str() -> ~str {
|
||||
|
@ -71,13 +71,13 @@ impl compile of gen_send for message {
|
||||
|
||||
if this.proto.is_bounded() {
|
||||
let (sp, rp) = alt (this.dir, next.dir) {
|
||||
(send, send) { ("c", "s") }
|
||||
(send, recv) { ("s", "c") }
|
||||
(recv, send) { ("s", "c") }
|
||||
(recv, recv) { ("c", "s") }
|
||||
(send, send) { (~"c", ~"s") }
|
||||
(send, recv) { (~"s", ~"c") }
|
||||
(recv, send) { (~"s", ~"c") }
|
||||
(recv, recv) { (~"c", ~"s") }
|
||||
};
|
||||
|
||||
body += "let b = pipe.reuse_buffer();\n";
|
||||
body += ~"let b = pipe.reuse_buffer();\n";
|
||||
body += fmt!{"let %s = pipes::send_packet_buffered(\
|
||||
ptr::addr_of(b.buffer.data.%s));\n",
|
||||
sp, *next.name};
|
||||
|
@ -2164,7 +2164,7 @@ class parser {
|
||||
}
|
||||
_ => {
|
||||
self.fatal(~"expected `,` or `)`, found `" +
|
||||
token_to_str(self.reader, self.token) + "`");
|
||||
token_to_str(self.reader, self.token) + ~"`");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -167,8 +167,8 @@ fn to_str(in: interner<@~str>, t: token) -> ~str {
|
||||
}
|
||||
LIT_FLOAT(s, t) {
|
||||
let mut body = *in.get(s);
|
||||
if body.ends_with(".") {
|
||||
body = body + "0"; // `10.f` is not a float literal
|
||||
if body.ends_with(~".") {
|
||||
body = body + ~"0"; // `10.f` is not a float literal
|
||||
}
|
||||
body + ast_util::float_ty_to_str(t)
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ fn print_item(s: ps, &&item: @ast::item) {
|
||||
bclose(s, item.span);
|
||||
}
|
||||
ast::item_mac({node: ast::mac_invoc_tt(pth, tts), _}) {
|
||||
head(s, path_to_str(pth) + "! " + *item.ident);
|
||||
head(s, path_to_str(pth) + ~"! " + *item.ident);
|
||||
bopen(s);
|
||||
for tts.each |tt| { print_tt(s, tt); }
|
||||
bclose(s, item.span);
|
||||
@ -873,7 +873,7 @@ fn print_mac(s: ps, m: ast::mac) {
|
||||
// FIXME: extension 'body' (#2339)
|
||||
}
|
||||
ast::mac_invoc_tt(pth, tts) {
|
||||
head(s, path_to_str(pth) + "!");
|
||||
head(s, path_to_str(pth) + ~"!");
|
||||
bopen(s);
|
||||
for tts.each() |tt| { print_tt(s, tt); }
|
||||
bclose(s, m.span);
|
||||
|
@ -5292,7 +5292,7 @@ fn gather_external_rtcalls(ccx: @crate_ctxt) {
|
||||
// like gather_local_rtcalls, but we'll need to
|
||||
// export attributes in metadata/encoder before we can do
|
||||
// that.
|
||||
let sentinel = "rt::rt_";
|
||||
let sentinel = ~"rt::rt_";
|
||||
let slen = str::len(sentinel);
|
||||
if str::starts_with(pathname, sentinel) {
|
||||
let name = str::substr(pathname,
|
||||
|
@ -701,7 +701,10 @@ fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
|
||||
alt lit.node {
|
||||
ast::lit_str(s) { ty::mk_estr(tcx, ty::vstore_fixed(s.len())) }
|
||||
ast::lit_str(s) {
|
||||
tcx.sess.span_warn(lit.span, ~"fixed length string");
|
||||
ty::mk_estr(tcx, ty::vstore_fixed(s.len()))
|
||||
}
|
||||
ast::lit_int(_, t) { ty::mk_mach_int(tcx, t) }
|
||||
ast::lit_uint(_, t) { ty::mk_mach_uint(tcx, t) }
|
||||
ast::lit_int_unsuffixed(_) {
|
||||
|
@ -229,7 +229,7 @@ fn header_name(doc: doc::itemtag) -> ~str {
|
||||
if i == 0 {
|
||||
trait_part += ~" of ";
|
||||
} else {
|
||||
trait_part += ", ";
|
||||
trait_part += ~", ";
|
||||
}
|
||||
trait_part += trait_type;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user