Skip to content

Commit 89ab8f1

Browse files
committed
auto merge of #14310 : pcwalton/rust/detildestr-alllibs, r=brson
r? @brson
2 parents a400b31 + 87941e8 commit 89ab8f1

File tree

291 files changed

+3124
-2540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+3124
-2540
lines changed

src/compiletest/compiletest.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn parse_config(args: Vec<StrBuf> ) -> Config {
9696
let args_ = args.tail();
9797
if args.get(1).as_slice() == "-h" || args.get(1).as_slice() == "--help" {
9898
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
99-
println!("{}", getopts::usage(message, groups.as_slice()));
99+
println!("{}", getopts::usage(message.as_slice(), groups.as_slice()));
100100
println!("");
101101
fail!()
102102
}
@@ -109,7 +109,7 @@ pub fn parse_config(args: Vec<StrBuf> ) -> Config {
109109

110110
if matches.opt_present("h") || matches.opt_present("help") {
111111
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
112-
println!("{}", getopts::usage(message, groups.as_slice()));
112+
println!("{}", getopts::usage(message.as_slice(), groups.as_slice()));
113113
println!("");
114114
fail!()
115115
}
@@ -323,11 +323,15 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
323323
let mut valid = false;
324324

325325
for ext in valid_extensions.iter() {
326-
if name.ends_with(*ext) { valid = true; }
326+
if name.ends_with(ext.as_slice()) {
327+
valid = true;
328+
}
327329
}
328330

329331
for pre in invalid_prefixes.iter() {
330-
if name.starts_with(*pre) { valid = false; }
332+
if name.starts_with(pre.as_slice()) {
333+
valid = false;
334+
}
331335
}
332336

333337
return valid;

src/compiletest/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
2424
let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
2525

2626
rdr.lines().enumerate().filter_map(|(line_no, ln)| {
27-
parse_expected(line_no + 1, ln.unwrap(), re)
27+
parse_expected(line_no + 1, ln.unwrap().as_slice(), re)
2828
}).collect()
2929
}
3030

src/compiletest/header.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,14 @@ fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
157157
// module or function. This doesn't seem to be an optimization
158158
// with a warm page cache. Maybe with a cold one.
159159
let ln = ln.unwrap();
160-
if ln.starts_with("fn") || ln.starts_with("mod") {
160+
if ln.as_slice().starts_with("fn") ||
161+
ln.as_slice().starts_with("mod") {
161162
return true;
162-
} else { if !(it(ln.trim())) { return false; } }
163+
} else {
164+
if !(it(ln.as_slice().trim())) {
165+
return false;
166+
}
167+
}
163168
}
164169
return true;
165170
}

src/compiletest/procsrv.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use std::unstable::dynamic_lib::DynamicLibrary;
1515

1616
fn target_env(lib_path: &str, prog: &str) -> Vec<(StrBuf, StrBuf)> {
1717
let prog = if cfg!(windows) {prog.slice_to(prog.len() - 4)} else {prog};
18-
let aux_path = prog + ".libaux";
18+
let mut aux_path = prog.to_strbuf();
19+
aux_path.push_str(".libaux");
1920

2021
// Need to be sure to put both the lib_path and the aux path in the dylib
2122
// search path for the child.

src/compiletest/runtest.rs

+19-9
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
351351
cmds,
352352
"quit".to_strbuf()].connect("\n");
353353
debug!("script_str = {}", script_str);
354-
dump_output_file(config, testfile, script_str, "debugger.script");
354+
dump_output_file(config,
355+
testfile,
356+
script_str.as_slice(),
357+
"debugger.script");
355358

356359

357360
procsrv::run("",
@@ -459,7 +462,10 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
459462
"quit\n".to_strbuf()
460463
].connect("\n");
461464
debug!("script_str = {}", script_str);
462-
dump_output_file(config, testfile, script_str, "debugger.script");
465+
dump_output_file(config,
466+
testfile,
467+
script_str.as_slice(),
468+
"debugger.script");
463469

464470
// run debugger script with gdb
465471
#[cfg(windows)]
@@ -538,7 +544,8 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
538544

539545
// Set breakpoints on every line that contains the string "#break"
540546
for line in breakpoint_lines.iter() {
541-
script_str.push_str(format!("breakpoint set --line {}\n", line));
547+
script_str.push_str(format!("breakpoint set --line {}\n",
548+
line).as_slice());
542549
}
543550

544551
// Append the other commands
@@ -552,7 +559,10 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
552559

553560
// Write the script into a file
554561
debug!("script_str = {}", script_str);
555-
dump_output_file(config, testfile, script_str.into_owned(), "debugger.script");
562+
dump_output_file(config,
563+
testfile,
564+
script_str.as_slice(),
565+
"debugger.script");
556566
let debugger_script = make_out_name(config, testfile, "debugger.script");
557567

558568
// Let LLDB execute the script via lldb_batchmode.py
@@ -609,8 +619,8 @@ fn parse_debugger_commands(file_path: &Path, debugger_prefix: &str)
609619
-> DebuggerCommands {
610620
use std::io::{BufferedReader, File};
611621

612-
let command_directive = debugger_prefix + "-command";
613-
let check_directive = debugger_prefix + "-check";
622+
let command_directive = format!("{}-command", debugger_prefix);
623+
let check_directive = format!("{}-check", debugger_prefix);
614624

615625
let mut breakpoint_lines = vec!();
616626
let mut commands = vec!();
@@ -620,18 +630,18 @@ fn parse_debugger_commands(file_path: &Path, debugger_prefix: &str)
620630
for line in reader.lines() {
621631
match line {
622632
Ok(line) => {
623-
if line.contains("#break") {
633+
if line.as_slice().contains("#break") {
624634
breakpoint_lines.push(counter);
625635
}
626636

627637
header::parse_name_value_directive(
628-
line,
638+
line.as_slice(),
629639
command_directive.to_strbuf()).map(|cmd| {
630640
commands.push(cmd)
631641
});
632642

633643
header::parse_name_value_directive(
634-
line,
644+
line.as_slice(),
635645
check_directive.to_strbuf()).map(|cmd| {
636646
check_lines.push(cmd)
637647
});

src/doc/complement-cheatsheet.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ To return an Owned String (StrBuf) use the str helper function [`from_utf8_owned
6060
~~~
6161
use std::str;
6262
63-
let x: Result<StrBuf,~[u8]> =
64-
str::from_utf8_owned(~[104u8,105u8]).map(|x| x.to_strbuf());
63+
let x: Option<StrBuf> =
64+
str::from_utf8([ 104u8, 105u8 ]).map(|x| x.to_strbuf());
6565
let y: StrBuf = x.unwrap();
6666
~~~
6767

src/libcollections/bitv.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ impl Bitv {
538538
* The resulting string has the same length as `self`, and each
539539
* character is either '0' or '1'.
540540
*/
541-
pub fn to_str(&self) -> ~str {
541+
pub fn to_str(&self) -> StrBuf {
542542
let mut rs = StrBuf::new();
543543
for i in self.iter() {
544544
if i {
@@ -547,7 +547,7 @@ impl Bitv {
547547
rs.push_char('0');
548548
}
549549
};
550-
rs.into_owned()
550+
rs
551551
}
552552

553553

@@ -1330,7 +1330,7 @@ mod tests {
13301330
#[test]
13311331
fn test_from_bytes() {
13321332
let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]);
1333-
let str = "10110110".to_owned() + "00000000" + "11111111";
1333+
let str = format!("{}{}{}", "10110110", "00000000", "11111111");
13341334
assert_eq!(bitv.to_str(), str);
13351335
}
13361336

src/libcore/any.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ mod tests {
119119
use prelude::*;
120120
use super::*;
121121
use realstd::owned::{Box, AnyOwnExt};
122-
use realstd::str::StrAllocating;
122+
use realstd::str::{Str, StrAllocating};
123123

124124
#[deriving(Eq, Show)]
125125
struct Test;
@@ -249,13 +249,17 @@ mod tests {
249249
use realstd::to_str::ToStr;
250250
let a = box 8u as Box<::realstd::any::Any>;
251251
let b = box Test as Box<::realstd::any::Any>;
252-
assert_eq!(a.to_str(), "Box<Any>".to_owned());
253-
assert_eq!(b.to_str(), "Box<Any>".to_owned());
252+
let a_str = a.to_str();
253+
let b_str = b.to_str();
254+
assert_eq!(a_str.as_slice(), "Box<Any>");
255+
assert_eq!(b_str.as_slice(), "Box<Any>");
254256

255257
let a = &8u as &Any;
256258
let b = &Test as &Any;
257-
assert_eq!(format!("{}", a), "&Any".to_owned());
258-
assert_eq!(format!("{}", b), "&Any".to_owned());
259+
let s = format!("{}", a);
260+
assert_eq!(s.as_slice(), "&Any");
261+
let s = format!("{}", b);
262+
assert_eq!(s.as_slice(), "&Any");
259263
}
260264
}
261265

src/libcore/bool.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,10 @@ mod tests {
242242

243243
#[test]
244244
fn test_to_str() {
245-
assert_eq!(false.to_str(), "false".to_owned());
246-
assert_eq!(true.to_str(), "true".to_owned());
245+
let s = false.to_str();
246+
assert_eq!(s.as_slice(), "false");
247+
let s = true.to_str();
248+
assert_eq!(s.as_slice(), "true");
247249
}
248250

249251
#[test]

src/libcore/cell.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,13 @@ mod test {
404404
#[test]
405405
fn cell_has_sensible_show() {
406406
use str::StrSlice;
407+
use realstd::str::Str;
407408

408409
let x = Cell::new("foo bar");
409-
assert!(format!("{}", x).contains(x.get()));
410+
assert!(format!("{}", x).as_slice().contains(x.get()));
410411

411412
x.set("baz qux");
412-
assert!(format!("{}", x).contains(x.get()));
413+
assert!(format!("{}", x).as_slice().contains(x.get()));
413414
}
414415

415416
#[test]

src/libcore/char.rs

+44-25
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ mod test {
637637
use slice::ImmutableVector;
638638
use option::{Some, None};
639639
use realstd::strbuf::StrBuf;
640-
use realstd::str::StrAllocating;
640+
use realstd::str::{Str, StrAllocating};
641641

642642
#[test]
643643
fn test_is_lowercase() {
@@ -742,46 +742,65 @@ mod test {
742742

743743
#[test]
744744
fn test_escape_default() {
745-
fn string(c: char) -> ~str {
745+
fn string(c: char) -> StrBuf {
746746
let mut result = StrBuf::new();
747747
escape_default(c, |c| { result.push_char(c); });
748-
return result.into_owned();
748+
return result;
749749
}
750-
assert_eq!(string('\n'), "\\n".to_owned());
751-
assert_eq!(string('\r'), "\\r".to_owned());
752-
assert_eq!(string('\''), "\\'".to_owned());
753-
assert_eq!(string('"'), "\\\"".to_owned());
754-
assert_eq!(string(' '), " ".to_owned());
755-
assert_eq!(string('a'), "a".to_owned());
756-
assert_eq!(string('~'), "~".to_owned());
757-
assert_eq!(string('\x00'), "\\x00".to_owned());
758-
assert_eq!(string('\x1f'), "\\x1f".to_owned());
759-
assert_eq!(string('\x7f'), "\\x7f".to_owned());
760-
assert_eq!(string('\xff'), "\\xff".to_owned());
761-
assert_eq!(string('\u011b'), "\\u011b".to_owned());
762-
assert_eq!(string('\U0001d4b6'), "\\U0001d4b6".to_owned());
750+
let s = string('\n');
751+
assert_eq!(s.as_slice(), "\\n");
752+
let s = string('\r');
753+
assert_eq!(s.as_slice(), "\\r");
754+
let s = string('\'');
755+
assert_eq!(s.as_slice(), "\\'");
756+
let s = string('"');
757+
assert_eq!(s.as_slice(), "\\\"");
758+
let s = string(' ');
759+
assert_eq!(s.as_slice(), " ");
760+
let s = string('a');
761+
assert_eq!(s.as_slice(), "a");
762+
let s = string('~');
763+
assert_eq!(s.as_slice(), "~");
764+
let s = string('\x00');
765+
assert_eq!(s.as_slice(), "\\x00");
766+
let s = string('\x1f');
767+
assert_eq!(s.as_slice(), "\\x1f");
768+
let s = string('\x7f');
769+
assert_eq!(s.as_slice(), "\\x7f");
770+
let s = string('\xff');
771+
assert_eq!(s.as_slice(), "\\xff");
772+
let s = string('\u011b');
773+
assert_eq!(s.as_slice(), "\\u011b");
774+
let s = string('\U0001d4b6');
775+
assert_eq!(s.as_slice(), "\\U0001d4b6");
763776
}
764777

765778
#[test]
766779
fn test_escape_unicode() {
767-
fn string(c: char) -> ~str {
780+
fn string(c: char) -> StrBuf {
768781
let mut result = StrBuf::new();
769782
escape_unicode(c, |c| { result.push_char(c); });
770-
return result.into_owned();
783+
return result;
771784
}
772-
assert_eq!(string('\x00'), "\\x00".to_owned());
773-
assert_eq!(string('\n'), "\\x0a".to_owned());
774-
assert_eq!(string(' '), "\\x20".to_owned());
775-
assert_eq!(string('a'), "\\x61".to_owned());
776-
assert_eq!(string('\u011b'), "\\u011b".to_owned());
777-
assert_eq!(string('\U0001d4b6'), "\\U0001d4b6".to_owned());
785+
let s = string('\x00');
786+
assert_eq!(s.as_slice(), "\\x00");
787+
let s = string('\n');
788+
assert_eq!(s.as_slice(), "\\x0a");
789+
let s = string(' ');
790+
assert_eq!(s.as_slice(), "\\x20");
791+
let s = string('a');
792+
assert_eq!(s.as_slice(), "\\x61");
793+
let s = string('\u011b');
794+
assert_eq!(s.as_slice(), "\\u011b");
795+
let s = string('\U0001d4b6');
796+
assert_eq!(s.as_slice(), "\\U0001d4b6");
778797
}
779798

780799
#[test]
781800
fn test_to_str() {
782801
use realstd::to_str::ToStr;
783802
let s = 't'.to_str();
784-
assert_eq!(s, "t".to_owned());
803+
assert_eq!(s.as_slice(), "t");
785804
}
786805

787806
#[test]

src/libcore/cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub trait Ord: Eq {
171171
/// The equivalence relation. Two values may be equivalent even if they are
172172
/// of different types. The most common use case for this relation is
173173
/// container types; e.g. it is often desirable to be able to use `&str`
174-
/// values to look up entries in a container with `~str` keys.
174+
/// values to look up entries in a container with `StrBuf` keys.
175175
pub trait Equiv<T> {
176176
/// Implement this function to decide equivalent values.
177177
fn equiv(&self, other: &T) -> bool;

src/libcore/fmt/mod.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter) -> Result,
594594
}
595595

596596
#[cfg(test)]
597-
pub fn format(args: &Arguments) -> ~str {
597+
pub fn format(args: &Arguments) -> ::realstd::strbuf::StrBuf {
598598
use str;
599599
use realstd::str::StrAllocating;
600600
use realstd::io::MemWriter;
@@ -613,7 +613,10 @@ pub fn format(args: &Arguments) -> ~str {
613613

614614
let mut i = MemWriter::new();
615615
let _ = write(&mut i, args);
616-
str::from_utf8(i.get_ref()).unwrap().to_owned()
616+
617+
let mut result = ::realstd::strbuf::StrBuf::new();
618+
result.push_str(str::from_utf8(i.get_ref()).unwrap());
619+
result
617620
}
618621

619622
/// When the compiler determines that the type of an argument *must* be a string
@@ -761,7 +764,6 @@ macro_rules! delegate(($ty:ty to $other:ident) => {
761764
}
762765
}
763766
})
764-
delegate!(~str to string)
765767
delegate!(&'a str to string)
766768
delegate!(bool to bool)
767769
delegate!(char to char)

0 commit comments

Comments
 (0)