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

+1-1
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

+22-22
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

+1-1
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

+1-1
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

+2-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+3-2
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

src/librustc/metadata/loader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn libname(cx: &Context) -> (~str, ~str) {
8080
os_freebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
8181
};
8282

83-
(dll_prefix.to_owned(), dll_suffix.to_owned())
83+
(str::to_owned(dll_prefix), str::to_owned(dll_suffix))
8484
}
8585

8686
fn find_library_crate_aux(

src/librustc/middle/check_match.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
495495
match cx.tcx.def_map.find(&pat_id) {
496496
Some(&def_variant(_, id)) => {
497497
if variant(id) == *ctor_id {
498-
Some(r.tail().to_owned())
498+
Some(vec::to_owned(r.tail()))
499499
} else {
500500
None
501501
}
@@ -533,7 +533,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
533533
_ => fail!("type error")
534534
};
535535
if match_ {
536-
Some(r.tail().to_owned())
536+
Some(vec::to_owned(r.tail()))
537537
} else {
538538
None
539539
}
@@ -580,7 +580,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
580580
_ => fail!("type error")
581581
};
582582
if match_ {
583-
Some(r.tail().to_owned())
583+
Some(vec::to_owned(r.tail()))
584584
} else {
585585
None
586586
}
@@ -590,7 +590,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
590590
Some(args) => args,
591591
None => vec::from_elem(arity, wild())
592592
};
593-
Some(vec::append(args, r.tail().to_owned()))
593+
Some(vec::append(args, vec::to_owned(r.tail())))
594594
}
595595
def_variant(_, _) => None,
596596

@@ -602,7 +602,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
602602
Some(args) => new_args = args,
603603
None => new_args = vec::from_elem(arity, wild())
604604
}
605-
Some(vec::append(new_args, r.tail().to_owned()))
605+
Some(vec::append(new_args, vec::to_owned(r.tail())))
606606
}
607607
_ => None
608608
}
@@ -620,7 +620,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
620620
_ => wild()
621621
}
622622
});
623-
Some(vec::append(args, r.tail().to_owned()))
623+
Some(vec::append(args, vec::to_owned(r.tail())))
624624
} else {
625625
None
626626
}
@@ -651,7 +651,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
651651
_ => wild()
652652
}
653653
});
654-
Some(vec::append(args, r.tail().to_owned()))
654+
Some(vec::append(args, vec::to_owned(r.tail())))
655655
}
656656
}
657657
}
@@ -687,14 +687,14 @@ pub fn specialize(cx: @MatchCheckCtxt,
687687
single => true,
688688
_ => fail!("type error")
689689
};
690-
if match_ { Some(r.tail().to_owned()) } else { None }
690+
if match_ { Some(vec::to_owned(r.tail())) } else { None }
691691
}
692692
pat_range(lo, hi) => {
693693
let (c_lo, c_hi) = match *ctor_id {
694694
val(ref v) => ((/*bad*/copy *v), (/*bad*/copy *v)),
695695
range(ref lo, ref hi) =>
696696
((/*bad*/copy *lo), (/*bad*/copy *hi)),
697-
single => return Some(r.tail().to_owned()),
697+
single => return Some(vec::to_owned(r.tail())),
698698
_ => fail!("type error")
699699
};
700700
let v_lo = eval_const_expr(cx.tcx, lo);
@@ -704,7 +704,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
704704
let m2 = compare_const_vals(&c_hi, &v_hi);
705705
match (m1, m2) {
706706
(Some(val1), Some(val2)) if val1 >= 0 && val2 <= 0 => {
707-
Some(r.tail().to_owned())
707+
Some(vec::to_owned(r.tail()))
708708
},
709709
(Some(_), Some(_)) => None,
710710
_ => {
@@ -745,7 +745,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
745745
}
746746

747747
pub fn default(cx: @MatchCheckCtxt, r: &[@pat]) -> Option<~[@pat]> {
748-
if is_wild(cx, r[0]) { Some(r.tail().to_owned()) }
748+
if is_wild(cx, r[0]) { Some(vec::to_owned(r.tail())) }
749749
else { None }
750750
}
751751

src/librustc/middle/trans/adt.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ use core::iterator::IteratorUtil;
4848
use core::container::Map;
4949
use core::libc::c_ulonglong;
5050
use core::option::{Option, Some, None};
51+
use core::str;
52+
use core::vec;
5153

5254
use lib::llvm::{ValueRef, TypeRef, True, IntEQ, IntNE};
5355
use middle::trans::_match;
@@ -217,7 +219,7 @@ fn mk_struct(cx: @CrateContext, tys: &[ty::t], packed: bool) -> Struct {
217219
size: machine::llsize_of_alloc(cx, llty_rec) /*bad*/as u64,
218220
align: machine::llalign_of_min(cx, llty_rec) /*bad*/as u64,
219221
packed: packed,
220-
fields: tys.to_owned()
222+
fields: vec::to_owned(tys)
221223
}
222224
}
223225

src/librustc/middle/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl get_insn_ctxt for @CrateContext {
113113
fn insn_ctxt(&self, s: &str) -> icx_popper {
114114
debug!("new insn_ctxt: %s", s);
115115
if self.sess.count_llvm_insns() {
116-
self.stats.llvm_insn_ctxt.push(s.to_owned());
116+
self.stats.llvm_insn_ctxt.push(str::to_owned(s));
117117
}
118118
icx_popper(*self)
119119
}

src/librustc/middle/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3898,7 +3898,7 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
38983898
}
38993899

39003900
ast_map::node_variant(ref variant, _, path) => {
3901-
vec::append_one(path.init().to_owned(),
3901+
vec::append_one(vec::to_owned(vec::init(*path)),
39023902
ast_map::path_name((*variant).node.name))
39033903
}
39043904

src/librustdoc/desc_to_brief_pass.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ fn first_sentence_(s: &str) -> ~str {
131131
});
132132
match idx {
133133
Some(idx) if idx > 2u => {
134-
s.slice_to(idx - 1).to_owned()
134+
str::to_owned(s.slice(0, idx - 1))
135135
}
136136
_ => {
137137
if s.ends_with(".") {
138-
s.to_owned()
138+
str::to_owned(s)
139139
} else {
140-
s.to_owned()
140+
str::to_owned(s)
141141
}
142142
}
143143
}

src/libstd/io.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ impl<T:Reader> ReaderUtil for T {
761761
fn read_lines(&self) -> ~[~str] {
762762
do vec::build |push| {
763763
for self.each_line |line| {
764-
push(line.to_owned());
764+
push(str::to_owned(line));
765765
}
766766
}
767767
}

0 commit comments

Comments
 (0)