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

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(

src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl get_insn_ctxt for @CrateContext {
104104
fn insn_ctxt(&self, s: &str) -> icx_popper {
105105
debug!("new insn_ctxt: %s", s);
106106
if self.sess.count_llvm_insns() {
107-
self.stats.llvm_insn_ctxt.push(str::from_slice(s));
107+
self.stats.llvm_insn_ctxt.push(str::to_owned(s));
108108
}
109109
icx_popper(*self)
110110
}

src/librustdoc/desc_to_brief_pass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ fn first_sentence_(s: &str) -> ~str {
129129
};
130130
match idx {
131131
Some(idx) if idx > 2u => {
132-
str::from_slice(str::slice(s, 0, idx - 1))
132+
str::to_owned(str::slice(s, 0, idx - 1))
133133
}
134134
_ => {
135135
if str::ends_with(s, ~".") {
136-
str::from_slice(s)
136+
str::to_owned(s)
137137
} else {
138-
str::from_slice(s)
138+
str::to_owned(s)
139139
}
140140
}
141141
}

src/libstd/getopts.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub struct Opt {
106106
}
107107

108108
fn mkname(nm: &str) -> Name {
109-
let unm = str::from_slice(nm);
109+
let unm = str::to_owned(nm);
110110
return if nm.len() == 1u {
111111
Short(str::char_at(unm, 0u))
112112
} else { Long(unm) };
@@ -441,7 +441,7 @@ pub fn opt_default(mm: &Matches, nm: &str, def: &str) -> Option<~str> {
441441
let vals = opt_vals(mm, nm);
442442
if vec::len::<Optval>(vals) == 0u { return None::<~str>; }
443443
return match vals[0] { Val(copy s) => Some::<~str>(s),
444-
_ => Some::<~str>(str::from_slice(def)) }
444+
_ => Some::<~str>(str::to_owned(def)) }
445445
}
446446

447447
#[deriving(Eq)]
@@ -481,10 +481,10 @@ pub mod groups {
481481
desc: &str, hint: &str) -> OptGroup {
482482
let len = short_name.len();
483483
assert!(len == 1 || len == 0);
484-
return OptGroup { short_name: str::from_slice(short_name),
485-
long_name: str::from_slice(long_name),
486-
hint: str::from_slice(hint),
487-
desc: str::from_slice(desc),
484+
return OptGroup { short_name: str::to_owned(short_name),
485+
long_name: str::to_owned(long_name),
486+
hint: str::to_owned(hint),
487+
desc: str::to_owned(desc),
488488
hasarg: Yes,
489489
occur: Req};
490490
}
@@ -494,10 +494,10 @@ pub mod groups {
494494
desc: &str, hint: &str) -> OptGroup {
495495
let len = short_name.len();
496496
assert!(len == 1 || len == 0);
497-
return OptGroup {short_name: str::from_slice(short_name),
498-
long_name: str::from_slice(long_name),
499-
hint: str::from_slice(hint),
500-
desc: str::from_slice(desc),
497+
return OptGroup {short_name: str::to_owned(short_name),
498+
long_name: str::to_owned(long_name),
499+
hint: str::to_owned(hint),
500+
desc: str::to_owned(desc),
501501
hasarg: Yes,
502502
occur: Optional};
503503
}
@@ -507,10 +507,10 @@ pub mod groups {
507507
desc: &str) -> OptGroup {
508508
let len = short_name.len();
509509
assert!(len == 1 || len == 0);
510-
return OptGroup {short_name: str::from_slice(short_name),
511-
long_name: str::from_slice(long_name),
510+
return OptGroup {short_name: str::to_owned(short_name),
511+
long_name: str::to_owned(long_name),
512512
hint: ~"",
513-
desc: str::from_slice(desc),
513+
desc: str::to_owned(desc),
514514
hasarg: No,
515515
occur: Optional};
516516
}
@@ -520,10 +520,10 @@ pub mod groups {
520520
desc: &str, hint: &str) -> OptGroup {
521521
let len = short_name.len();
522522
assert!(len == 1 || len == 0);
523-
return OptGroup {short_name: str::from_slice(short_name),
524-
long_name: str::from_slice(long_name),
525-
hint: str::from_slice(hint),
526-
desc: str::from_slice(desc),
523+
return OptGroup {short_name: str::to_owned(short_name),
524+
long_name: str::to_owned(long_name),
525+
hint: str::to_owned(hint),
526+
desc: str::to_owned(desc),
527527
hasarg: Maybe,
528528
occur: Optional};
529529
}
@@ -536,10 +536,10 @@ pub mod groups {
536536
desc: &str, hint: &str) -> OptGroup {
537537
let len = short_name.len();
538538
assert!(len == 1 || len == 0);
539-
return OptGroup {short_name: str::from_slice(short_name),
540-
long_name: str::from_slice(long_name),
541-
hint: str::from_slice(hint),
542-
desc: str::from_slice(desc),
539+
return OptGroup {short_name: str::to_owned(short_name),
540+
long_name: str::to_owned(long_name),
541+
hint: str::to_owned(hint),
542+
desc: str::to_owned(desc),
543543
hasarg: Yes,
544544
occur: Multi};
545545
}
@@ -648,7 +648,7 @@ pub mod groups {
648648
row
649649
});
650650
651-
return str::from_slice(brief) +
651+
return str::to_owned(brief) +
652652
~"\n\nOptions:\n" +
653653
str::connect(rows, ~"\n") +
654654
~"\n\n";

src/libstd/net_ip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub mod v4 {
225225
let input_is_inaddr_none =
226226
result::get(&ip_rep_result).as_u32() == INADDR_NONE;
227227
228-
let new_addr = uv_ip4_addr(str::from_slice(ip), 22);
228+
let new_addr = uv_ip4_addr(str::to_owned(ip), 22);
229229
let reformatted_name = uv_ip4_name(&new_addr);
230230
debug!("try_parse_addr: input ip: %s reparsed ip: %s",
231231
ip, reformatted_name);
@@ -278,7 +278,7 @@ pub mod v6 {
278278
pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
279279
unsafe {
280280
// need to figure out how to establish a parse failure..
281-
let new_addr = uv_ip6_addr(str::from_slice(ip), 22);
281+
let new_addr = uv_ip6_addr(str::to_owned(ip), 22);
282282
let reparsed_name = uv_ip6_name(&new_addr);
283283
debug!("v6::try_parse_addr ip: '%s' reparsed '%s'",
284284
ip, reparsed_name);

0 commit comments

Comments
 (0)