Skip to content

Commit 682afca

Browse files
committed
auto merge of #6829 : dotdash/rust/allocs, r=sanxiyn
2 parents ca74cbd + 1720d9f commit 682afca

27 files changed

+83
-91
lines changed

src/compiletest/header.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
9999
return false;
100100

101101
fn xfail_target() -> ~str {
102-
~"xfail-" + str::to_owned(os::SYSNAME)
102+
~"xfail-" + os::SYSNAME
103103
}
104104
}
105105
@@ -173,7 +173,7 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
173173

174174
fn parse_name_value_directive(line: &str,
175175
directive: ~str) -> Option<~str> {
176-
let keycolon = directive + ~":";
176+
let keycolon = directive + ":";
177177
match str::find_str(line, keycolon) {
178178
Some(colon) => {
179179
let value = str::slice(line, colon + str::len(keycolon),

src/compiletest/procsrv.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
2424
let mut env = os::env();
2525

2626
// Make sure we include the aux directory in the path
27-
assert!(prog.ends_with(~".exe"));
28-
let aux_path = prog.slice(0u, prog.len() - 4u).to_owned() + ~".libaux";
27+
assert!(prog.ends_with(".exe"));
28+
let aux_path = prog.slice(0u, prog.len() - 4u).to_owned() + ".libaux";
2929

3030
env = do vec::map(env) |pair| {
3131
let (k,v) = *pair;
32-
if k == ~"PATH" { (~"PATH", v + ~";" + lib_path + ~";" + aux_path) }
32+
if k == ~"PATH" { (~"PATH", v + ";" + lib_path + ";" + aux_path) }
3333
else { (k,v) }
3434
};
3535
if str::ends_with(prog, "rustc.exe") {

src/compiletest/runtest.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
378378
was_expected = true;
379379
}
380380

381-
if !was_expected && is_compiler_error_or_warning(str::to_owned(line)) {
381+
if !was_expected && is_compiler_error_or_warning(line) {
382382
fatal_ProcRes(fmt!("unexpected compiler error or warning: '%s'",
383383
line),
384384
ProcRes);
@@ -596,8 +596,7 @@ fn make_lib_name(config: &config, auxfile: &Path, testfile: &Path) -> Path {
596596
}
597597

598598
fn make_exe_name(config: &config, testfile: &Path) -> Path {
599-
Path(output_base_name(config, testfile).to_str() +
600-
str::to_owned(os::EXE_SUFFIX))
599+
Path(output_base_name(config, testfile).to_str() + os::EXE_SUFFIX)
601600
}
602601

603602
fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
@@ -606,7 +605,7 @@ fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
606605
// then split apart its command
607606
let toolargs = split_maybe_args(&config.runtool);
608607

609-
let mut args = toolargs + ~[make_exe_name(config, testfile).to_str()];
608+
let mut args = toolargs + [make_exe_name(config, testfile).to_str()];
610609
let prog = args.shift();
611610
return ProcArgs {prog: prog, args: args};
612611
}
@@ -655,7 +654,7 @@ fn make_cmdline(_libpath: &str, prog: &str, args: &[~str]) -> ~str {
655654
#[cfg(target_os = "win32")]
656655
fn make_cmdline(libpath: &str, prog: &str, args: &[~str]) -> ~str {
657656
fmt!("%s %s %s", lib_path_cmd_prefix(libpath), prog,
658-
str::connect(args, ~" "))
657+
str::connect(args, " "))
659658
}
660659

661660
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
@@ -776,8 +775,8 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
776775
for args.args.each |tv| {
777776
newcmd_out.push_str(" ");
778777
newcmd_err.push_str(" ");
779-
newcmd_out.push_str(tv.to_owned());
780-
newcmd_err.push_str(tv.to_owned());
778+
newcmd_out.push_str(*tv);
779+
newcmd_err.push_str(*tv);
781780
}
782781

783782
newcmd_out.push_str(" 2>/dev/null");

src/libextra/getopts.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ pub struct Opt {
110110
}
111111

112112
fn mkname(nm: &str) -> Name {
113-
let unm = str::to_owned(nm);
114-
return if nm.len() == 1u {
115-
Short(str::char_at(unm, 0u))
116-
} else { Long(unm) };
113+
if nm.len() == 1u {
114+
Short(str::char_at(nm, 0u))
115+
} else {
116+
Long(nm.to_owned())
117+
}
117118
}
118119

119120
/// Create an option that is required and takes an argument
@@ -195,19 +196,19 @@ pub enum Fail_ {
195196
pub fn fail_str(f: Fail_) -> ~str {
196197
return match f {
197198
ArgumentMissing(ref nm) => {
198-
~"Argument to option '" + *nm + "' missing."
199+
fmt!("Argument to option '%s' missing.", *nm)
199200
}
200201
UnrecognizedOption(ref nm) => {
201-
~"Unrecognized option: '" + *nm + "'."
202+
fmt!("Unrecognized option: '%s'.", *nm)
202203
}
203204
OptionMissing(ref nm) => {
204-
~"Required option '" + *nm + "' missing."
205+
fmt!("Required option '%s' missing.", *nm)
205206
}
206207
OptionDuplicated(ref nm) => {
207-
~"Option '" + *nm + "' given more than once."
208+
fmt!("Option '%s' given more than once.", *nm)
208209
}
209210
UnexpectedArgument(ref nm) => {
210-
~"Option " + *nm + " does not take an argument."
211+
fmt!("Option '%s' does not take an argument.", *nm)
211212
}
212213
};
213214
}
@@ -245,11 +246,11 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
245246
let mut names;
246247
let mut i_arg = None;
247248
if cur[1] == '-' as u8 {
248-
let tail = str::slice(cur, 2, curlen).to_owned();
249+
let tail = str::slice(cur, 2, curlen);
249250
let mut tail_eq = ~[];
250251
for str::each_splitn_char(tail, '=', 1) |s| { tail_eq.push(s.to_owned()) }
251252
if tail_eq.len() <= 1 {
252-
names = ~[Long(tail)];
253+
names = ~[Long(tail.to_owned())];
253254
} else {
254255
names =
255256
~[Long(copy tail_eq[0])];

src/libextra/net_ip.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub mod v4 {
230230
let input_is_inaddr_none =
231231
result::get(&ip_rep_result).as_u32() == INADDR_NONE;
232232

233-
let new_addr = uv_ip4_addr(str::to_owned(ip), 22);
233+
let new_addr = uv_ip4_addr(ip, 22);
234234
let reformatted_name = uv_ip4_name(&new_addr);
235235
debug!("try_parse_addr: input ip: %s reparsed ip: %s",
236236
ip, reformatted_name);
@@ -259,7 +259,6 @@ pub mod v6 {
259259
use uv_ip6_name = uv::ll::ip6_name;
260260

261261
use core::result;
262-
use core::str;
263262

264263
/**
265264
* Convert a str to `ip_addr`
@@ -285,7 +284,7 @@ pub mod v6 {
285284
pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
286285
unsafe {
287286
// need to figure out how to establish a parse failure..
288-
let new_addr = uv_ip6_addr(str::to_owned(ip), 22);
287+
let new_addr = uv_ip6_addr(ip, 22);
289288
let reparsed_name = uv_ip6_name(&new_addr);
290289
debug!("v6::try_parse_addr ip: '%s' reparsed '%s'",
291290
ip, reparsed_name);

src/libextra/net_url.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ fn get_path(rawurl: &str, authority: bool) ->
585585
}
586586
}
587587

588-
return Ok((decode_component(str::slice(rawurl, 0, end).to_owned()),
588+
return Ok((decode_component(str::slice(rawurl, 0, end)),
589589
str::slice(rawurl, end, len).to_owned()));
590590
}
591591

@@ -596,14 +596,13 @@ fn get_query_fragment(rawurl: &str) ->
596596
if str::starts_with(rawurl, "#") {
597597
let f = decode_component(str::slice(rawurl,
598598
1,
599-
str::len(rawurl)).to_owned());
599+
str::len(rawurl)));
600600
return Ok((~[], Some(f)));
601601
} else {
602602
return Ok((~[], None));
603603
}
604604
}
605-
let (q, r) = split_char_first(str::slice(rawurl, 1,
606-
str::len(rawurl)).to_owned(), '#');
605+
let (q, r) = split_char_first(str::slice(rawurl, 1, rawurl.len()), '#');
607606
let f = if str::len(r) != 0 {
608607
Some(decode_component(r)) } else { None };
609608
return Ok((query_from_str(q), f));

src/libextra/sha1.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,7 @@ mod tests {
399399
let mut left = len;
400400
while left > 0u {
401401
let take = (left + 1u) / 2u;
402-
sh.input_str(str::slice(t.input, len - left,
403-
take + len - left).to_owned());
402+
sh.input_str(t.input.slice(len - left, take + len - left));
404403
left = left - take;
405404
}
406405
let out = sh.result();

src/libextra/time.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
293293

294294
let mut i = 0u;
295295
while i < digits {
296-
let range = str::char_range_at(str::to_owned(ss), pos);
296+
let range = str::char_range_at(ss, pos);
297297
pos = range.next;
298298

299299
match range.ch {
@@ -632,7 +632,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
632632
}
633633
}
634634

635-
do io::with_str_reader(str::to_owned(format)) |rdr| {
635+
do io::with_str_reader(format) |rdr| {
636636
let mut tm = Tm {
637637
tm_sec: 0_i32,
638638
tm_min: 0_i32,
@@ -844,7 +844,7 @@ priv fn do_strftime(format: &str, tm: &Tm) -> ~str {
844844
845845
let mut buf = ~"";
846846

847-
do io::with_str_reader(str::to_owned(format)) |rdr| {
847+
do io::with_str_reader(format) |rdr| {
848848
while !rdr.eof() {
849849
match rdr.read_char() {
850850
'%' => buf += parse_type(rdr.read_char(), tm),

src/libextra/workcache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ struct Logger {
201201

202202
pub impl Logger {
203203
fn info(&self, i: &str) {
204-
io::println(~"workcache: " + i.to_owned());
204+
io::println(~"workcache: " + i);
205205
}
206206
}
207207

src/librustc/back/link.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -741,16 +741,14 @@ pub fn mangle_internal_name_by_seq(ccx: @CrateContext, flav: &str) -> ~str {
741741

742742

743743
pub fn output_dll_filename(os: session::os, lm: LinkMeta) -> ~str {
744-
let libname = fmt!("%s-%s-%s", lm.name, lm.extras_hash, lm.vers);
745744
let (dll_prefix, dll_suffix) = match os {
746745
session::os_win32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX),
747746
session::os_macos => (macos::DLL_PREFIX, macos::DLL_SUFFIX),
748747
session::os_linux => (linux::DLL_PREFIX, linux::DLL_SUFFIX),
749748
session::os_android => (android::DLL_PREFIX, android::DLL_SUFFIX),
750749
session::os_freebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
751750
};
752-
return str::to_owned(dll_prefix) + libname +
753-
str::to_owned(dll_suffix);
751+
fmt!("%s%s-%s-%s%s", dll_prefix, lm.name, lm.extras_hash, lm.vers, dll_suffix)
754752
}
755753

756754
// If the user wants an exe generated we need to invoke

src/librustc/lib/llvm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,7 @@ pub fn type_to_str_inner(names: @TypeNames, outer0: &[TypeRef], ty: TypeRef)
20142014
let mut first: bool = true;
20152015
for tys.each |t| {
20162016
if first { first = false; } else { s += ", "; }
2017-
s += type_to_str_inner(names, outer, *t).to_owned();
2017+
s += type_to_str_inner(names, outer, *t);
20182018
}
20192019
// [Note at-str] FIXME #2543: Could rewrite this without the copy,
20202020
// but need better @str support.

src/librustc/metadata/loader.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,7 @@ pub fn list_file_metadata(intr: @ident_interner,
268268
match get_metadata_section(os, path) {
269269
option::Some(bytes) => decoder::list_crate_metadata(intr, bytes, out),
270270
option::None => {
271-
out.write_str(~"could not find metadata in "
272-
+ path.to_str() + ".\n");
271+
out.write_str(fmt!("could not find metadata in %s.\n", path.to_str()))
273272
}
274273
}
275274
}

src/librustc/metadata/tyencode.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ pub fn enc_ty(w: @io::Writer, cx: @ctxt, t: ty::t) {
8989
let abbrev_len = 3u + estimate_sz(pos) + estimate_sz(len);
9090
if abbrev_len < len {
9191
// I.e. it's actually an abbreviation.
92-
let s = ~"#" + uint::to_str_radix(pos, 16u) + ":" +
93-
uint::to_str_radix(len, 16u) + "#";
92+
let s = fmt!("#%x:%x#", pos, len);
9493
let a = ty_abbrev { pos: pos, len: len, s: @s };
9594
abbrevs.insert(t, a);
9695
}

src/librustc/middle/trans/asm.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
9898

9999
// Add the clobbers to our constraints list
100100
if clobbers != ~"" && constraints != ~"" {
101-
constraints += ~"," + clobbers;
101+
constraints += ",";
102+
constraints += clobbers;
102103
} else {
103104
constraints += clobbers;
104105
}

src/librustc/middle/trans/base.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2906,8 +2906,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
29062906
let cstore = sess.cstore;
29072907
while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; }
29082908
let mapname = if *sess.building_library {
2909-
mapmeta.name.to_owned() + "_" + mapmeta.vers.to_owned() + "_"
2910-
+ mapmeta.extras_hash.to_owned()
2909+
fmt!("%s_%s_%s", mapmeta.name, mapmeta.vers, mapmeta.extras_hash)
29112910
} else {
29122911
~"toplevel"
29132912
};

src/librustc/middle/trans/cabi.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ pub impl FnType {
6060
fn build_shim_args(&self, bcx: block,
6161
arg_tys: &[TypeRef],
6262
llargbundle: ValueRef) -> ~[ValueRef] {
63-
let mut atys = /*bad*/copy self.arg_tys;
64-
let mut attrs = /*bad*/copy self.attrs;
63+
let mut atys: &[LLVMType] = self.arg_tys;
64+
let mut attrs: &[option::Option<Attribute>] = self.attrs;
6565

6666
let mut llargvals = ~[];
6767
let mut i = 0u;
@@ -71,8 +71,8 @@ pub impl FnType {
7171
let llretptr = GEPi(bcx, llargbundle, [0u, n]);
7272
let llretloc = Load(bcx, llretptr);
7373
llargvals = ~[llretloc];
74-
atys = vec::to_owned(atys.tail());
75-
attrs = vec::to_owned(attrs.tail());
74+
atys = atys.tail();
75+
attrs = attrs.tail();
7676
}
7777

7878
while i < n {
@@ -133,12 +133,12 @@ pub impl FnType {
133133
ret_ty: TypeRef,
134134
llwrapfn: ValueRef,
135135
llargbundle: ValueRef) {
136-
let mut atys = /*bad*/copy self.arg_tys;
137-
let mut attrs = /*bad*/copy self.attrs;
136+
let mut atys: &[LLVMType] = self.arg_tys;
137+
let mut attrs: &[option::Option<Attribute>] = self.attrs;
138138
let mut j = 0u;
139139
let llretptr = if self.sret {
140-
atys = vec::to_owned(atys.tail());
141-
attrs = vec::to_owned(attrs.tail());
140+
atys = atys.tail();
141+
attrs = attrs.tail();
142142
j = 1u;
143143
get_param(llwrapfn, 0u)
144144
} else if self.ret_ty.cast {

src/librustc/middle/typeck/check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3661,8 +3661,8 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
36613661
~"bswap64" => (0, ~[ ty::mk_i64() ], ty::mk_i64()),
36623662
ref other => {
36633663
tcx.sess.span_err(it.span,
3664-
~"unrecognized intrinsic function: `" +
3665-
(*other) + "`");
3664+
fmt!("unrecognized intrinsic function: `%s`",
3665+
*other));
36663666
return;
36673667
}
36683668
};

src/librustc/middle/typeck/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ fn check_main_fn_ty(ccx: @mut CrateCtxt,
323323
}
324324
_ => {
325325
tcx.sess.span_bug(main_span,
326-
~"main has a non-function type: found `" +
327-
ppaux::ty_to_str(tcx, main_t) + "`");
326+
fmt!("main has a non-function type: found `%s`",
327+
ppaux::ty_to_str(tcx, main_t)));
328328
}
329329
}
330330
}
@@ -372,8 +372,8 @@ fn check_start_fn_ty(ccx: @mut CrateCtxt,
372372
}
373373
_ => {
374374
tcx.sess.span_bug(start_span,
375-
~"start has a non-function type: found `" +
376-
ppaux::ty_to_str(tcx, start_t) + "`");
375+
fmt!("start has a non-function type: found `%s`",
376+
ppaux::ty_to_str(tcx, start_t)));
377377
}
378378
}
379379
}

src/librustc/util/ppaux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
416416
ty_rptr(r, ref tm) => {
417417
region_to_str_space(cx, "&", r) + mt_to_str(cx, tm)
418418
}
419-
ty_unboxed_vec(ref tm) => { ~"unboxed_vec<" + mt_to_str(cx, tm) + ">" }
419+
ty_unboxed_vec(ref tm) => { fmt!("unboxed_vec<%s>", mt_to_str(cx, tm)) }
420420
ty_type => ~"type",
421421
ty_tup(ref elems) => {
422422
let strs = elems.map(|elem| ty_to_str(cx, *elem));

0 commit comments

Comments
 (0)