Skip to content

Commit

Permalink
cleanup: replace as[_mut]_slice() calls with deref coercions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Aparicio committed Feb 5, 2015
1 parent 2c05354 commit 17bc7d8
Show file tree
Hide file tree
Showing 289 changed files with 1,372 additions and 1,406 deletions.
20 changes: 10 additions & 10 deletions src/compiletest/compiletest.rs
Expand Up @@ -97,22 +97,22 @@ pub fn parse_config(args: Vec<String> ) -> Config {
assert!(!args.is_empty());
let argv0 = args[0].clone();
let args_ = args.tail();
if args[1].as_slice() == "-h" || args[1].as_slice() == "--help" {
if args[1] == "-h" || args[1] == "--help" {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println!("{}", getopts::usage(message.as_slice(), groups.as_slice()));
println!("{}", getopts::usage(&message, &groups));
println!("");
panic!()
}

let matches =
&match getopts::getopts(args_.as_slice(), groups.as_slice()) {
&match getopts::getopts(args_, &groups) {
Ok(m) => m,
Err(f) => panic!("{:?}", f)
};

if matches.opt_present("h") || matches.opt_present("help") {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println!("{}", getopts::usage(message.as_slice(), groups.as_slice()));
println!("{}", getopts::usage(&message, &groups));
println!("");
panic!()
}
Expand Down Expand Up @@ -156,9 +156,9 @@ pub fn parse_config(args: Vec<String> ) -> Config {
adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")),
adb_device_status:
"arm-linux-androideabi" ==
opt_str2(matches.opt_str("target")).as_slice() &&
opt_str2(matches.opt_str("target")) &&
"(none)" !=
opt_str2(matches.opt_str("adb-test-dir")).as_slice() &&
opt_str2(matches.opt_str("adb-test-dir")) &&
!opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
lldb_python_dir: matches.opt_str("lldb-python-dir"),
verbose: matches.opt_present("verbose"),
Expand Down Expand Up @@ -201,7 +201,7 @@ pub fn log_config(config: &Config) {
pub fn opt_str<'a>(maybestr: &'a Option<String>) -> &'a str {
match *maybestr {
None => "(none)",
Some(ref s) => s.as_slice(),
Some(ref s) => s,
}
}

Expand All @@ -213,7 +213,7 @@ pub fn opt_str2(maybestr: Option<String>) -> String {
}

pub fn run_tests(config: &Config) {
if config.target.as_slice() == "arm-linux-androideabi" {
if config.target == "arm-linux-androideabi" {
match config.mode {
DebugInfoGdb => {
println!("arm-linux-androideabi debug-info \
Expand Down Expand Up @@ -306,13 +306,13 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
let mut valid = false;

for ext in &valid_extensions {
if name.ends_with(ext.as_slice()) {
if name.ends_with(ext) {
valid = true;
}
}

for pre in &invalid_prefixes {
if name.starts_with(pre.as_slice()) {
if name.starts_with(pre) {
valid = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/errors.rs
Expand Up @@ -44,7 +44,7 @@ pub fn load_errors(testfile: &Path) -> Vec<ExpectedError> {
rdr.lines().enumerate().filter_map(|(line_no, ln)| {
parse_expected(last_nonfollow_error,
line_no + 1,
ln.unwrap().as_slice())
&ln.unwrap())
.map(|(which, error)| {
match which {
FollowPrevious(_) => {}
Expand Down
28 changes: 14 additions & 14 deletions src/compiletest/header.rs
Expand Up @@ -145,7 +145,7 @@ pub fn load_props(testfile: &Path) -> TestProps {

pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
fn ignore_target(config: &Config) -> String {
format!("ignore-{}", util::get_os(config.target.as_slice()))
format!("ignore-{}", util::get_os(&config.target))
}
fn ignore_stage(config: &Config) -> String {
format!("ignore-{}",
Expand All @@ -169,8 +169,8 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
.expect("Malformed GDB version directive");
// Ignore if actual version is smaller the minimum required
// version
gdb_version_to_int(actual_version.as_slice()) <
gdb_version_to_int(min_version.as_slice())
gdb_version_to_int(actual_version) <
gdb_version_to_int(min_version)
} else {
false
}
Expand All @@ -197,8 +197,8 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
.expect("Malformed lldb version directive");
// Ignore if actual version is smaller the minimum required
// version
lldb_version_to_int(actual_version.as_slice()) <
lldb_version_to_int(min_version.as_slice())
lldb_version_to_int(actual_version) <
lldb_version_to_int(min_version)
} else {
false
}
Expand All @@ -209,8 +209,8 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {

let val = iter_header(testfile, |ln| {
!parse_name_directive(ln, "ignore-test") &&
!parse_name_directive(ln, ignore_target(config).as_slice()) &&
!parse_name_directive(ln, ignore_stage(config).as_slice()) &&
!parse_name_directive(ln, &ignore_target(config)) &&
!parse_name_directive(ln, &ignore_stage(config)) &&
!(config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) &&
!(config.target != config.host && parse_name_directive(ln, "ignore-cross-compile")) &&
!ignore_gdb(config, ln) &&
Expand Down Expand Up @@ -294,7 +294,7 @@ fn parse_pretty_compare_only(line: &str) -> bool {
fn parse_exec_env(line: &str) -> Option<(String, String)> {
parse_name_value_directive(line, "exec-env").map(|nv| {
// nv is either FOO or FOO=BAR
let mut strs: Vec<String> = nv.as_slice()
let mut strs: Vec<String> = nv
.splitn(1, '=')
.map(|s| s.to_string())
.collect();
Expand Down Expand Up @@ -330,7 +330,7 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
pub fn parse_name_value_directive(line: &str, directive: &str)
-> Option<String> {
let keycolon = format!("{}:", directive);
match line.find_str(keycolon.as_slice()) {
match line.find_str(&keycolon) {
Some(colon) => {
let value = line[(colon + keycolon.len()) .. line.len()].to_string();
debug!("{}: {}", directive, value);
Expand All @@ -344,16 +344,16 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
let error_string = format!(
"Encountered GDB version string with unexpected format: {}",
version_string);
let error_string = error_string.as_slice();
let error_string = error_string;

let components: Vec<&str> = version_string.trim().split('.').collect();

if components.len() != 2 {
panic!("{}", error_string);
}

let major: int = components[0].parse().ok().expect(error_string);
let minor: int = components[1].parse().ok().expect(error_string);
let major: int = components[0].parse().ok().expect(&error_string);
let minor: int = components[1].parse().ok().expect(&error_string);

return major * 1000 + minor;
}
Expand All @@ -362,7 +362,7 @@ pub fn lldb_version_to_int(version_string: &str) -> int {
let error_string = format!(
"Encountered LLDB version string with unexpected format: {}",
version_string);
let error_string = error_string.as_slice();
let major: int = version_string.parse().ok().expect(error_string);
let error_string = error_string;
let major: int = version_string.parse().ok().expect(&error_string);
return major;
}
2 changes: 1 addition & 1 deletion src/compiletest/procsrv.rs
Expand Up @@ -23,7 +23,7 @@ fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {

// Add the new dylib search path var
let var = DynamicLibrary::envvar();
let newpath = DynamicLibrary::create_path(path.as_slice());
let newpath = DynamicLibrary::create_path(&path);
let newpath = String::from_utf8(newpath).unwrap();
cmd.env(var.to_string(), newpath);
}
Expand Down

0 comments on commit 17bc7d8

Please sign in to comment.