Skip to content

Commit 9572518

Browse files
committed
auto merge of #6389 : sonwow/rust/issue-3356, r=bstrie
Fix for #3356
2 parents e478ced + 24ef88c commit 9572518

38 files changed

+105
-105
lines changed

src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn is_test_ignored(config: config, testfile: &Path) -> bool {
9191
return false;
9292

9393
fn xfail_target() -> ~str {
94-
~"xfail-" + str::from_slice(os::SYSNAME)
94+
~"xfail-" + str::to_owned(os::SYSNAME)
9595
}
9696
}
9797

src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
371371
was_expected = true;
372372
}
373373

374-
if !was_expected && is_compiler_error_or_warning(str::from_slice(line)) {
374+
if !was_expected && is_compiler_error_or_warning(str::to_owned(line)) {
375375
fatal_ProcRes(fmt!("unexpected compiler error or warning: '%s'",
376376
line),
377377
ProcRes);
@@ -596,7 +596,7 @@ fn make_lib_name(config: config, auxfile: &Path, testfile: &Path) -> Path {
596596

597597
fn make_exe_name(config: config, testfile: &Path) -> Path {
598598
Path(output_base_name(config, testfile).to_str() +
599-
str::from_slice(os::EXE_SUFFIX))
599+
str::to_owned(os::EXE_SUFFIX))
600600
}
601601

602602
fn make_run_args(config: config, _props: TestProps, testfile: &Path) ->

src/libcore/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ impl<T:Reader> ReaderUtil for T {
758758
fn read_lines(&self) -> ~[~str] {
759759
do vec::build |push| {
760760
for self.each_line |line| {
761-
push(str::from_slice(line));
761+
push(str::to_owned(line));
762762
}
763763
}
764764
}

src/libcore/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ fn dup2(src: c_int, dst: c_int) -> c_int {
396396

397397

398398
pub fn dll_filename(base: &str) -> ~str {
399-
return str::from_slice(DLL_PREFIX) + str::from_slice(base) +
400-
str::from_slice(DLL_SUFFIX)
399+
return str::to_owned(DLL_PREFIX) + str::to_owned(base) +
400+
str::to_owned(DLL_SUFFIX)
401401
}
402402

403403

src/libcore/path.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ impl GenericPath for PosixPath {
506506
fn with_filestem(&self, s: &str) -> PosixPath {
507507
match self.filetype() {
508508
None => self.with_filename(s),
509-
Some(ref t) => self.with_filename(str::from_slice(s) + *t)
509+
Some(ref t) => self.with_filename(str::to_owned(s) + *t)
510510
}
511511
}
512512

@@ -517,7 +517,7 @@ impl GenericPath for PosixPath {
517517
Some(ref s) => self.with_filename(*s)
518518
}
519519
} else {
520-
let t = ~"." + str::from_slice(t);
520+
let t = ~"." + str::to_owned(t);
521521
match self.filestem() {
522522
None => self.with_filename(t),
523523
Some(ref s) => self.with_filename(*s + t)
@@ -650,7 +650,7 @@ impl GenericPath for WindowsPath {
650650
None => {
651651
host = None;
652652
device = None;
653-
rest = str::from_slice(s);
653+
rest = str::to_owned(s);
654654
}
655655
}
656656
}
@@ -723,7 +723,7 @@ impl GenericPath for WindowsPath {
723723
fn with_filestem(&self, s: &str) -> WindowsPath {
724724
match self.filetype() {
725725
None => self.with_filename(s),
726-
Some(ref t) => self.with_filename(str::from_slice(s) + *t)
726+
Some(ref t) => self.with_filename(str::to_owned(s) + *t)
727727
}
728728
}
729729

@@ -734,7 +734,7 @@ impl GenericPath for WindowsPath {
734734
Some(ref s) => self.with_filename(*s)
735735
}
736736
} else {
737-
let t = ~"." + str::from_slice(t);
737+
let t = ~"." + str::to_owned(t);
738738
match self.filestem() {
739739
None => self.with_filename(t),
740740
Some(ref s) =>
@@ -985,7 +985,7 @@ mod tests {
985985
fn test_posix_paths() {
986986
fn t(wp: &PosixPath, s: &str) {
987987
let ss = wp.to_str();
988-
let sss = str::from_slice(s);
988+
let sss = str::to_owned(s);
989989
if (ss != sss) {
990990
debug!("got %s", ss);
991991
debug!("expected %s", sss);
@@ -1043,7 +1043,7 @@ mod tests {
10431043
fn test_normalize() {
10441044
fn t(wp: &PosixPath, s: &str) {
10451045
let ss = wp.to_str();
1046-
let sss = str::from_slice(s);
1046+
let sss = str::to_owned(s);
10471047
if (ss != sss) {
10481048
debug!("got %s", ss);
10491049
debug!("expected %s", sss);
@@ -1106,7 +1106,7 @@ mod tests {
11061106
fn test_windows_paths() {
11071107
fn t(wp: &WindowsPath, s: &str) {
11081108
let ss = wp.to_str();
1109-
let sss = str::from_slice(s);
1109+
let sss = str::to_owned(s);
11101110
if (ss != sss) {
11111111
debug!("got %s", ss);
11121112
debug!("expected %s", sss);

src/libcore/rand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ impl<R: Rng> RngUtil for R {
568568

569569
/// Shuffle a vec
570570
fn shuffle<T:Copy>(&mut self, values: &[T]) -> ~[T] {
571-
let mut m = vec::from_slice(values);
571+
let mut m = vec::to_owned(values);
572572
self.shuffle_mut(m);
573573
m
574574
}

src/libcore/str.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ pub fn from_bytes_slice<'a>(vector: &'a [u8]) -> &'a str {
7878

7979
/// Copy a slice into a new unique str
8080
#[inline(always)]
81-
pub fn from_slice(s: &str) -> ~str {
81+
pub fn to_owned(s: &str) -> ~str {
8282
unsafe { raw::slice_bytes_owned(s, 0, len(s)) }
8383
}
8484

8585
impl ToStr for ~str {
8686
#[inline(always)]
87-
fn to_str(&self) -> ~str { from_slice(*self) }
87+
fn to_str(&self) -> ~str { to_owned(*self) }
8888
}
8989
impl<'self> ToStr for &'self str {
9090
#[inline(always)]
91-
fn to_str(&self) -> ~str { from_slice(*self) }
91+
fn to_str(&self) -> ~str { to_owned(*self) }
9292
}
9393
impl ToStr for @str {
9494
#[inline(always)]
95-
fn to_str(&self) -> ~str { from_slice(*self) }
95+
fn to_str(&self) -> ~str { to_owned(*self) }
9696
}
9797

9898
/**
@@ -511,7 +511,7 @@ Section: Transforming strings
511511
*/
512512
pub fn to_bytes(s: &str) -> ~[u8] {
513513
unsafe {
514-
let mut v: ~[u8] = ::cast::transmute(from_slice(s));
514+
let mut v: ~[u8] = ::cast::transmute(to_owned(s));
515515
vec::raw::set_len(&mut v, len(s));
516516
v
517517
}
@@ -2438,7 +2438,7 @@ pub fn as_c_str<T>(s: &str, f: &fn(*libc::c_char) -> T) -> T {
24382438
// NB: len includes the trailing null.
24392439
assert!(len > 0);
24402440
if unsafe { *(ptr::offset(buf,len-1)) != 0 } {
2441-
as_c_str(from_slice(s), f)
2441+
as_c_str(to_owned(s), f)
24422442
} else {
24432443
f(buf as *libc::c_char)
24442444
}
@@ -3069,7 +3069,7 @@ impl<'self> StrSlice<'self> for &'self str {
30693069
30703070
30713071
#[inline]
3072-
fn to_owned(&self) -> ~str { from_slice(*self) }
3072+
fn to_owned(&self) -> ~str { to_owned(*self) }
30733073
30743074
#[inline]
30753075
fn to_managed(&self) -> @str {
@@ -3109,7 +3109,7 @@ impl OwnedStr for ~str {
31093109
impl Clone for ~str {
31103110
#[inline(always)]
31113111
fn clone(&self) -> ~str {
3112-
from_slice(*self)
3112+
to_owned(*self)
31133113
}
31143114
}
31153115

src/libcore/vec.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> ~[T] {
167167
}
168168

169169
/// Creates a new unique vector with the same contents as the slice
170-
pub fn from_slice<T:Copy>(t: &[T]) -> ~[T] {
170+
pub fn to_owned<T:Copy>(t: &[T]) -> ~[T] {
171171
from_fn(t.len(), |i| t[i])
172172
}
173173

@@ -3645,19 +3645,19 @@ mod tests {
36453645
let mut results: ~[~[int]];
36463646

36473647
results = ~[];
3648-
for each_permutation(~[]) |v| { results.push(from_slice(v)); }
3648+
for each_permutation(~[]) |v| { results.push(to_owned(v)); }
36493649
assert!(results == ~[~[]]);
36503650

36513651
results = ~[];
3652-
for each_permutation(~[7]) |v| { results.push(from_slice(v)); }
3652+
for each_permutation(~[7]) |v| { results.push(to_owned(v)); }
36533653
assert!(results == ~[~[7]]);
36543654

36553655
results = ~[];
3656-
for each_permutation(~[1,1]) |v| { results.push(from_slice(v)); }
3656+
for each_permutation(~[1,1]) |v| { results.push(to_owned(v)); }
36573657
assert!(results == ~[~[1,1],~[1,1]]);
36583658

36593659
results = ~[];
3660-
for each_permutation(~[5,2,0]) |v| { results.push(from_slice(v)); }
3660+
for each_permutation(~[5,2,0]) |v| { results.push(to_owned(v)); }
36613661
assert!(results ==
36623662
~[~[5,2,0],~[5,0,2],~[2,5,0],~[2,0,5],~[0,5,2],~[0,2,5]]);
36633663
}

src/libfuzzer/fuzzer.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ pub fn check_variants_T<T:Copy>(crate: @ast::crate,
316316
if L < 100 {
317317
do under(uint::min(L, 20)) |i| {
318318
error!("Replacing... #%?", uint::to_str(i));
319-
let fname = str::from_slice(filename.to_str());
319+
let fname = str::to_owned(filename.to_str());
320320
do under(uint::min(L, 30)) |j| {
321321
let fname = fname.to_str();
322322
error!("With... %?", stringifier(things[j], intr));

src/librust/rust.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn do_command(command: &Command, args: &[~str]) -> ValidUsage {
192192
let (prog, prog_args) = (words.head(), words.tail());
193193
let exitstatus = run::run_program(
194194
*prog,
195-
vec::append(vec::from_slice(prog_args), args)
195+
vec::append(vec::to_owned(prog_args), args)
196196
);
197197
os::set_exit_status(exitstatus);
198198
Valid

src/librustc/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,8 @@ pub fn output_dll_filename(os: session::os, lm: LinkMeta) -> ~str {
747747
session::os_android => (android::DLL_PREFIX, android::DLL_SUFFIX),
748748
session::os_freebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
749749
};
750-
return str::from_slice(dll_prefix) + libname +
751-
str::from_slice(dll_suffix);
750+
return str::to_owned(dll_prefix) + libname +
751+
str::to_owned(dll_suffix);
752752
}
753753
754754
// If the user wants an exe generated we need to invoke

src/librustc/driver/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ pub fn default_configuration(sess: Session, argv0: @~str, input: &input) ->
9191
};
9292

9393
return ~[ // Target bindings.
94-
attr::mk_word_item(@str::from_slice(os::FAMILY)),
94+
attr::mk_word_item(@str::to_owned(os::FAMILY)),
9595
mk(@~"target_os", @tos),
96-
mk(@~"target_family", @str::from_slice(os::FAMILY)),
96+
mk(@~"target_family", @str::to_owned(os::FAMILY)),
9797
mk(@~"target_arch", @arch),
9898
mk(@~"target_endian", @end),
9999
mk(@~"target_word_size", @wordsz),
@@ -648,7 +648,7 @@ pub fn build_session_options(binary: @~str,
648648
let linker_args = getopts::opt_strs(matches, ~"link-args").flat_map( |a| {
649649
let mut args = ~[];
650650
for str::each_split_char(*a, ' ') |arg| {
651-
args.push(str::from_slice(arg));
651+
args.push(str::to_owned(arg));
652652
}
653653
args
654654
});

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ pub fn maybe_get_item_ast(intr: @ident_interner, cdata: cmd, tcx: ty::ctxt,
619619
let item_doc = lookup_item(id, cdata.data);
620620
let path = {
621621
let item_path = item_path(intr, item_doc);
622-
vec::from_slice(item_path.init())
622+
vec::to_owned(item_path.init())
623623
};
624624
match decode_inlined_item(cdata, tcx, copy path, item_doc) {
625625
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
@@ -1461,7 +1461,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
14611461
//
14621462
// Should be:
14631463
//
1464-
// vec::from_slice(metadata_encoding_version) +
1464+
// vec::to_owned(metadata_encoding_version) +
14651465
14661466
let writer_bytes: &mut ~[u8] = wr.bytes;
14671467

src/librustc/metadata/filesearch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
101101
@FileSearchImpl {
102102
sysroot: sysroot,
103103
addl_lib_search_paths: addl_lib_search_paths,
104-
target_triple: str::from_slice(target_triple)
104+
target_triple: str::to_owned(target_triple)
105105
} as @FileSearch
106106
}
107107

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

128128
pub fn relative_target_lib_path(target_triple: &str) -> Path {
129129
Path(libdir()).push_many([~"rustc",
130-
str::from_slice(target_triple),
130+
str::to_owned(target_triple),
131131
libdir()])
132132
}
133133

src/librustc/metadata/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn libname(cx: &Context) -> (~str, ~str) {
7171
os_freebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
7272
};
7373

74-
(str::from_slice(dll_prefix), str::from_slice(dll_suffix))
74+
(str::to_owned(dll_prefix), str::to_owned(dll_suffix))
7575
}
7676

7777
fn find_library_crate_aux(

0 commit comments

Comments
 (0)