Skip to content

Commit 7755018

Browse files
committed
Revert "std: convert {vec,str}::to_owned to methods."
This fixes the strange random crashes in compile-fail tests. This reverts commit 96cd61a. Conflicts: src/librustc/driver/driver.rs src/libstd/str.rs src/libsyntax/ext/quote.rs
1 parent b417bc8 commit 7755018

30 files changed

+104
-90
lines changed

src/libextra/flatpipes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ pub mod flatteners {
450450
T: Decodable<D>>(
451451
buf: &[u8])
452452
-> T {
453-
let buf = buf.to_owned();
453+
let buf = vec::to_owned(buf);
454454
let buf_reader = @BufReader::new(buf);
455455
let reader = buf_reader as @Reader;
456456
let mut deser: D = FromReader::from_reader(reader);

src/libextra/getopts.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
345345
}
346346
i += 1;
347347
}
348-
return Ok(Matches {opts: opts.to_owned(),
348+
return Ok(Matches {opts: vec::to_owned(opts),
349349
vals: vals,
350350
free: free});
351351
}
@@ -447,7 +447,7 @@ pub fn opt_default(mm: &Matches, nm: &str, def: &str) -> Option<~str> {
447447
let vals = opt_vals(mm, nm);
448448
if vals.is_empty() { return None::<~str>; }
449449
return match vals[0] { Val(ref s) => Some::<~str>(copy *s),
450-
_ => Some::<~str>(def.to_owned()) }
450+
_ => Some::<~str>(str::to_owned(def)) }
451451
}
452452

453453
#[deriving(Eq)]
@@ -487,10 +487,10 @@ pub mod groups {
487487
desc: &str, hint: &str) -> OptGroup {
488488
let len = short_name.len();
489489
assert!(len == 1 || len == 0);
490-
return OptGroup { short_name: short_name.to_owned(),
491-
long_name: long_name.to_owned(),
492-
hint: hint.to_owned(),
493-
desc: desc.to_owned(),
490+
return OptGroup { short_name: str::to_owned(short_name),
491+
long_name: str::to_owned(long_name),
492+
hint: str::to_owned(hint),
493+
desc: str::to_owned(desc),
494494
hasarg: Yes,
495495
occur: Req};
496496
}
@@ -500,10 +500,10 @@ pub mod groups {
500500
desc: &str, hint: &str) -> OptGroup {
501501
let len = short_name.len();
502502
assert!(len == 1 || len == 0);
503-
return OptGroup {short_name: short_name.to_owned(),
504-
long_name: long_name.to_owned(),
505-
hint: hint.to_owned(),
506-
desc: desc.to_owned(),
503+
return OptGroup {short_name: str::to_owned(short_name),
504+
long_name: str::to_owned(long_name),
505+
hint: str::to_owned(hint),
506+
desc: str::to_owned(desc),
507507
hasarg: Yes,
508508
occur: Optional};
509509
}
@@ -513,10 +513,10 @@ pub mod groups {
513513
desc: &str) -> OptGroup {
514514
let len = short_name.len();
515515
assert!(len == 1 || len == 0);
516-
return OptGroup {short_name: short_name.to_owned(),
517-
long_name: long_name.to_owned(),
516+
return OptGroup {short_name: str::to_owned(short_name),
517+
long_name: str::to_owned(long_name),
518518
hint: ~"",
519-
desc: desc.to_owned(),
519+
desc: str::to_owned(desc),
520520
hasarg: No,
521521
occur: Optional};
522522
}
@@ -526,10 +526,10 @@ pub mod groups {
526526
desc: &str, hint: &str) -> OptGroup {
527527
let len = short_name.len();
528528
assert!(len == 1 || len == 0);
529-
return OptGroup {short_name: short_name.to_owned(),
530-
long_name: long_name.to_owned(),
531-
hint: hint.to_owned(),
532-
desc: desc.to_owned(),
529+
return OptGroup {short_name: str::to_owned(short_name),
530+
long_name: str::to_owned(long_name),
531+
hint: str::to_owned(hint),
532+
desc: str::to_owned(desc),
533533
hasarg: Maybe,
534534
occur: Optional};
535535
}
@@ -542,10 +542,10 @@ pub mod groups {
542542
desc: &str, hint: &str) -> OptGroup {
543543
let len = short_name.len();
544544
assert!(len == 1 || len == 0);
545-
return OptGroup {short_name: short_name.to_owned(),
546-
long_name: long_name.to_owned(),
547-
hint: hint.to_owned(),
548-
desc: desc.to_owned(),
545+
return OptGroup {short_name: str::to_owned(short_name),
546+
long_name: str::to_owned(long_name),
547+
hint: str::to_owned(hint),
548+
desc: str::to_owned(desc),
549549
hasarg: Yes,
550550
occur: Multi};
551551
}
@@ -654,7 +654,7 @@ pub mod groups {
654654
row
655655
});
656656

657-
return brief.to_owned() +
657+
return str::to_owned(brief) +
658658
"\n\nOptions:\n" +
659659
rows.connect("\n") +
660660
"\n\n";

src/libextra/md4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn md4(msg: &[u8]) -> Quad {
2929
let orig_len: u64 = (msg.len() * 8u) as u64;
3030

3131
// pad message
32-
let mut msg = vec::append(msg.to_owned(), [0x80u8]);
32+
let mut msg = vec::append(vec::to_owned(msg), [0x80u8]);
3333
let mut bitlen = orig_len + 8u64;
3434
while (bitlen + 64u64) % 512u64 > 0u64 {
3535
msg.push(0u8);

src/libextra/num/bigint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ impl BigUint {
564564
/// Creates and initializes an BigUint.
565565
566566
pub fn from_slice(slice: &[BigDigit]) -> BigUint {
567-
return BigUint::new(slice.to_owned());
567+
return BigUint::new(vec::to_owned(slice));
568568
}
569569

570570
/// Creates and initializes an BigUint.

src/libextra/stats.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use core::iterator::*;
1616
use core::f64;
1717
use core::cmp;
1818
use core::num;
19+
use core::vec;
1920
use sort;
2021

2122
// NB: this can probably be rewritten in terms of num::Num
@@ -56,7 +57,7 @@ impl<'self> Stats for &'self [f64] {
5657

5758
fn median(self) -> f64 {
5859
assert!(self.len() != 0);
59-
let mut tmp = self.to_owned();
60+
let mut tmp = vec::to_owned(self);
6061
sort::tim_sort(tmp);
6162
if tmp.len() & 1 == 0 {
6263
let m = tmp.len() / 2;

src/libextra/time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ mod tests {
10291029
10301030
fn test(s: &str, format: &str) -> bool {
10311031
match strptime(s, format) {
1032-
Ok(ref tm) => tm.strftime(format) == s.to_owned(),
1032+
Ok(ref tm) => tm.strftime(format) == str::to_owned(s),
10331033
Err(e) => fail!(e)
10341034
}
10351035
}

src/libfuzzer/fuzzer.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ pub fn check_variants_T<T:Copy>(crate: @ast::crate,
328328
if L < 100 {
329329
do under(uint::min(L, 20)) |i| {
330330
error!("Replacing... #%?", uint::to_str(i));
331-
let fname = filename.to_str();
331+
let fname = str::to_owned(filename.to_str());
332332
do under(uint::min(L, 30)) |j| {
333333
let fname = fname.to_str();
334334
error!("With... %?", stringifier(things[j], intr));

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ pub fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt,
570570
let item_doc = lookup_item(id, cdata.data);
571571
let path = {
572572
let item_path = item_path(item_doc);
573-
item_path.init().to_owned()
573+
vec::to_owned(item_path.init())
574574
};
575575
match decode_inlined_item(cdata, tcx, copy path, item_doc) {
576576
Some(ref ii) => csearch::found((/*bad*/copy *ii)),

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
15211521

15221522
let writer_bytes: &mut ~[u8] = wr.bytes;
15231523

1524-
metadata_encoding_version.to_owned() +
1524+
vec::to_owned(metadata_encoding_version) +
15251525
flate::deflate_bytes(*writer_bytes)
15261526
}
15271527

src/librustc/metadata/filesearch.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use core::prelude::*;
1313
use core::option;
1414
use core::os;
1515
use core::result;
16+
use core::str;
1617

1718
// A module for searching for libraries
1819
// FIXME (#2658): I'm not happy how this module turned out. Should
@@ -80,7 +81,7 @@ pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
8081
@FileSearchImpl {
8182
sysroot: sysroot,
8283
addl_lib_search_paths: addl_lib_search_paths,
83-
target_triple: target_triple.to_owned()
84+
target_triple: str::to_owned(target_triple)
8485
} as @FileSearch
8586
}
8687

@@ -106,7 +107,7 @@ pub fn search<T:Copy>(filesearch: @FileSearch, pick: pick<T>) -> Option<T> {
106107

107108
pub fn relative_target_lib_path(target_triple: &str) -> Path {
108109
Path(libdir()).push_many([~"rustc",
109-
target_triple.to_owned(),
110+
str::to_owned(target_triple),
110111
libdir()])
111112
}
112113

0 commit comments

Comments
 (0)