Skip to content

Commit 682afca

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

File tree

27 files changed

+83
-91
lines changed

27 files changed

+83
-91
lines changed

src/compiletest/header.rs

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 6 additions & 7 deletions
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

Lines changed: 12 additions & 11 deletions
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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 3 deletions
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

0 commit comments

Comments
 (0)