Skip to content

Commit 24ef88c

Browse files
committed
renamed str::from_slice to str::to_owned
1 parent b7da975 commit 24ef88c

File tree

19 files changed

+66
-66
lines changed

19 files changed

+66
-66
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
@@ -711,7 +711,7 @@ impl<T:Reader> ReaderUtil for T {
711711
fn read_lines(&self) -> ~[~str] {
712712
do vec::build |push| {
713713
for self.each_line |line| {
714-
push(str::from_slice(line));
714+
push(str::to_owned(line));
715715
}
716716
}
717717
}

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
@@ -477,7 +477,7 @@ impl GenericPath for PosixPath {
477477
fn with_filestem(&self, s: &str) -> PosixPath {
478478
match self.filetype() {
479479
None => self.with_filename(s),
480-
Some(ref t) => self.with_filename(str::from_slice(s) + *t)
480+
Some(ref t) => self.with_filename(str::to_owned(s) + *t)
481481
}
482482
}
483483

@@ -488,7 +488,7 @@ impl GenericPath for PosixPath {
488488
Some(ref s) => self.with_filename(*s)
489489
}
490490
} else {
491-
let t = ~"." + str::from_slice(t);
491+
let t = ~"." + str::to_owned(t);
492492
match self.filestem() {
493493
None => self.with_filename(t),
494494
Some(ref s) => self.with_filename(*s + t)
@@ -621,7 +621,7 @@ impl GenericPath for WindowsPath {
621621
None => {
622622
host = None;
623623
device = None;
624-
rest = str::from_slice(s);
624+
rest = str::to_owned(s);
625625
}
626626
}
627627
}
@@ -694,7 +694,7 @@ impl GenericPath for WindowsPath {
694694
fn with_filestem(&self, s: &str) -> WindowsPath {
695695
match self.filetype() {
696696
None => self.with_filename(s),
697-
Some(ref t) => self.with_filename(str::from_slice(s) + *t)
697+
Some(ref t) => self.with_filename(str::to_owned(s) + *t)
698698
}
699699
}
700700

@@ -705,7 +705,7 @@ impl GenericPath for WindowsPath {
705705
Some(ref s) => self.with_filename(*s)
706706
}
707707
} else {
708-
let t = ~"." + str::from_slice(t);
708+
let t = ~"." + str::to_owned(t);
709709
match self.filestem() {
710710
None => self.with_filename(t),
711711
Some(ref s) =>
@@ -956,7 +956,7 @@ mod tests {
956956
fn test_posix_paths() {
957957
fn t(wp: &PosixPath, s: &str) {
958958
let ss = wp.to_str();
959-
let sss = str::from_slice(s);
959+
let sss = str::to_owned(s);
960960
if (ss != sss) {
961961
debug!("got %s", ss);
962962
debug!("expected %s", sss);
@@ -1014,7 +1014,7 @@ mod tests {
10141014
fn test_normalize() {
10151015
fn t(wp: &PosixPath, s: &str) {
10161016
let ss = wp.to_str();
1017-
let sss = str::from_slice(s);
1017+
let sss = str::to_owned(s);
10181018
if (ss != sss) {
10191019
debug!("got %s", ss);
10201020
debug!("expected %s", sss);
@@ -1077,7 +1077,7 @@ mod tests {
10771077
fn test_windows_paths() {
10781078
fn t(wp: &WindowsPath, s: &str) {
10791079
let ss = wp.to_str();
1080-
let sss = str::from_slice(s);
1080+
let sss = str::to_owned(s);
10811081
if (ss != sss) {
10821082
debug!("got %s", ss);
10831083
debug!("expected %s", sss);

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
}
@@ -2141,7 +2141,7 @@ pub fn as_c_str<T>(s: &str, f: &fn(*libc::c_char) -> T) -> T {
21412141
// NB: len includes the trailing null.
21422142
assert!(len > 0);
21432143
if unsafe { *(ptr::offset(buf,len-1)) != 0 } {
2144-
as_c_str(from_slice(s), f)
2144+
as_c_str(to_owned(s), f)
21452145
} else {
21462146
f(buf as *libc::c_char)
21472147
}
@@ -2682,7 +2682,7 @@ impl<'self> StrSlice<'self> for &'self str {
26822682
26832683
26842684
#[inline]
2685-
fn to_owned(&self) -> ~str { from_slice(*self) }
2685+
fn to_owned(&self) -> ~str { to_owned(*self) }
26862686
26872687
#[inline]
26882688
fn to_managed(&self) -> @str {
@@ -2722,7 +2722,7 @@ impl OwnedStr for ~str {
27222722
impl Clone for ~str {
27232723
#[inline(always)]
27242724
fn clone(&self) -> ~str {
2725-
from_slice(*self)
2725+
to_owned(*self)
27262726
}
27272727
}
27282728

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/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/filesearch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
7373
@FileSearchImpl {
7474
sysroot: sysroot,
7575
addl_lib_search_paths: addl_lib_search_paths,
76-
target_triple: str::from_slice(target_triple)
76+
target_triple: str::to_owned(target_triple)
7777
} as @FileSearch
7878
}
7979

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

100100
pub fn relative_target_lib_path(target_triple: &str) -> Path {
101101
Path(libdir()).push_many([~"rustc",
102-
str::from_slice(target_triple),
102+
str::to_owned(target_triple),
103103
libdir()])
104104
}
105105

0 commit comments

Comments
 (0)