cleanup: replace as[_mut]_slice()
calls with deref coercions
This commit is contained in:
parent
2c05354211
commit
17bc7d8d5b
@ -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!()
|
||||
}
|
||||
@ -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"),
|
||||
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 \
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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(_) => {}
|
||||
|
@ -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-{}",
|
||||
@ -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
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
@ -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) &&
|
||||
@ -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();
|
||||
@ -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);
|
||||
@ -344,7 +344,7 @@ 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();
|
||||
|
||||
@ -352,8 +352,8 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
|
||||
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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ use std::time::Duration;
|
||||
use test::MetricMap;
|
||||
|
||||
pub fn run(config: Config, testfile: String) {
|
||||
match config.target.as_slice() {
|
||||
match &*config.target {
|
||||
|
||||
"arm-linux-androideabi" => {
|
||||
if !config.adb_device_status {
|
||||
@ -106,10 +106,10 @@ fn run_cfail_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
}
|
||||
check_expected_errors(expected_errors, testfile, &proc_res);
|
||||
} else {
|
||||
check_error_patterns(props, testfile, output_to_check.as_slice(), &proc_res);
|
||||
check_error_patterns(props, testfile, &output_to_check, &proc_res);
|
||||
}
|
||||
check_no_compiler_crash(&proc_res);
|
||||
check_forbid_output(props, output_to_check.as_slice(), &proc_res);
|
||||
check_forbid_output(props, &output_to_check, &proc_res);
|
||||
}
|
||||
|
||||
fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
@ -133,7 +133,7 @@ fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
|
||||
let output_to_check = get_output(props, &proc_res);
|
||||
check_correct_failure_status(&proc_res);
|
||||
check_error_patterns(props, testfile, output_to_check.as_slice(), &proc_res);
|
||||
check_error_patterns(props, testfile, &output_to_check, &proc_res);
|
||||
}
|
||||
|
||||
fn check_correct_failure_status(proc_res: &ProcRes) {
|
||||
@ -141,8 +141,8 @@ fn check_correct_failure_status(proc_res: &ProcRes) {
|
||||
static RUST_ERR: int = 101;
|
||||
if !proc_res.status.matches_exit_status(RUST_ERR) {
|
||||
fatal_proc_rec(
|
||||
format!("failure produced the wrong error: {:?}",
|
||||
proc_res.status).as_slice(),
|
||||
&format!("failure produced the wrong error: {:?}",
|
||||
proc_res.status),
|
||||
proc_res);
|
||||
}
|
||||
}
|
||||
@ -211,11 +211,10 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
props,
|
||||
testfile,
|
||||
srcs[round].to_string(),
|
||||
props.pretty_mode.as_slice());
|
||||
&props.pretty_mode);
|
||||
|
||||
if !proc_res.status.success() {
|
||||
fatal_proc_rec(format!("pretty-printing failed in round {}",
|
||||
round).as_slice(),
|
||||
fatal_proc_rec(&format!("pretty-printing failed in round {}", round),
|
||||
&proc_res);
|
||||
}
|
||||
|
||||
@ -237,11 +236,11 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
if props.pp_exact.is_some() {
|
||||
// Now we have to care about line endings
|
||||
let cr = "\r".to_string();
|
||||
actual = actual.replace(cr.as_slice(), "").to_string();
|
||||
expected = expected.replace(cr.as_slice(), "").to_string();
|
||||
actual = actual.replace(&cr, "").to_string();
|
||||
expected = expected.replace(&cr, "").to_string();
|
||||
}
|
||||
|
||||
compare_source(expected.as_slice(), actual.as_slice());
|
||||
compare_source(&expected, &actual);
|
||||
|
||||
// If we're only making sure that the output matches then just stop here
|
||||
if props.pretty_compare_only { return; }
|
||||
@ -282,7 +281,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
testfile,
|
||||
pretty_type.to_string()),
|
||||
props.exec_env.clone(),
|
||||
config.compile_lib_path.as_slice(),
|
||||
&config.compile_lib_path,
|
||||
Some(aux_dir.as_str().unwrap()),
|
||||
Some(src))
|
||||
}
|
||||
@ -335,9 +334,9 @@ actual:\n\
|
||||
fn make_typecheck_args(config: &Config, props: &TestProps, testfile: &Path) -> ProcArgs {
|
||||
let aux_dir = aux_output_dir_name(config, testfile);
|
||||
let target = if props.force_host {
|
||||
config.host.as_slice()
|
||||
&*config.host
|
||||
} else {
|
||||
config.target.as_slice()
|
||||
&*config.target
|
||||
};
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let mut args = vec!("-".to_string(),
|
||||
@ -382,7 +381,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
let exe_file = make_exe_name(config, testfile);
|
||||
|
||||
let debugger_run_result;
|
||||
match config.target.as_slice() {
|
||||
match &*config.target {
|
||||
"arm-linux-androideabi" => {
|
||||
|
||||
cmds = cmds.replace("run", "continue").to_string();
|
||||
@ -397,12 +396,12 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
debug!("script_str = {}", script_str);
|
||||
dump_output_file(config,
|
||||
testfile,
|
||||
script_str.as_slice(),
|
||||
&script_str,
|
||||
"debugger.script");
|
||||
|
||||
|
||||
procsrv::run("",
|
||||
config.adb_path.as_slice(),
|
||||
&config.adb_path,
|
||||
None,
|
||||
&[
|
||||
"push".to_string(),
|
||||
@ -411,10 +410,10 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
],
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format!("failed to exec `{:?}`", config.adb_path).as_slice());
|
||||
.expect(&format!("failed to exec `{:?}`", config.adb_path));
|
||||
|
||||
procsrv::run("",
|
||||
config.adb_path.as_slice(),
|
||||
&config.adb_path,
|
||||
None,
|
||||
&[
|
||||
"forward".to_string(),
|
||||
@ -423,7 +422,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
],
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format!("failed to exec `{:?}`", config.adb_path).as_slice());
|
||||
.expect(&format!("failed to exec `{:?}`", config.adb_path));
|
||||
|
||||
let adb_arg = format!("export LD_LIBRARY_PATH={}; \
|
||||
gdbserver :5039 {}/{}",
|
||||
@ -434,8 +433,8 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
.unwrap()).unwrap());
|
||||
|
||||
let mut process = procsrv::run_background("",
|
||||
config.adb_path
|
||||
.as_slice(),
|
||||
&config.adb_path
|
||||
,
|
||||
None,
|
||||
&[
|
||||
"shell".to_string(),
|
||||
@ -444,7 +443,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
vec!(("".to_string(),
|
||||
"".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format!("failed to exec `{:?}`", config.adb_path).as_slice());
|
||||
.expect(&format!("failed to exec `{:?}`", config.adb_path));
|
||||
loop {
|
||||
//waiting 1 second for gdbserver start
|
||||
timer::sleep(Duration::milliseconds(1000));
|
||||
@ -477,16 +476,16 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
err,
|
||||
status
|
||||
} = procsrv::run("",
|
||||
gdb_path.as_slice(),
|
||||
&gdb_path,
|
||||
None,
|
||||
debugger_opts.as_slice(),
|
||||
&debugger_opts,
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
None)
|
||||
.expect(format!("failed to exec `{:?}`", gdb_path).as_slice());
|
||||
.expect(&format!("failed to exec `{:?}`", gdb_path));
|
||||
let cmdline = {
|
||||
let cmdline = make_cmdline("",
|
||||
"arm-linux-androideabi-gdb",
|
||||
debugger_opts.as_slice());
|
||||
&debugger_opts);
|
||||
logv(config, format!("executing {}", cmdline));
|
||||
cmdline
|
||||
};
|
||||
@ -517,16 +516,16 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
match config.gdb_version {
|
||||
Some(ref version) => {
|
||||
println!("NOTE: compiletest thinks it is using GDB version {}",
|
||||
version.as_slice());
|
||||
version);
|
||||
|
||||
if header::gdb_version_to_int(version.as_slice()) >
|
||||
if header::gdb_version_to_int(version) >
|
||||
header::gdb_version_to_int("7.4") {
|
||||
// Add the directory containing the pretty printers to
|
||||
// GDB's script auto loading safe path
|
||||
script_str.push_str(
|
||||
format!("add-auto-load-safe-path {}\n",
|
||||
rust_pp_module_abs_path.replace("\\", "\\\\").as_slice())
|
||||
.as_slice());
|
||||
&format!("add-auto-load-safe-path {}\n",
|
||||
rust_pp_module_abs_path.replace("\\", "\\\\"))
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
@ -553,13 +552,13 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
*line)[]);
|
||||
}
|
||||
|
||||
script_str.push_str(cmds.as_slice());
|
||||
script_str.push_str(&cmds);
|
||||
script_str.push_str("quit\n");
|
||||
|
||||
debug!("script_str = {}", script_str);
|
||||
dump_output_file(config,
|
||||
testfile,
|
||||
script_str.as_slice(),
|
||||
&script_str,
|
||||
"debugger.script");
|
||||
|
||||
// run debugger script with gdb
|
||||
@ -592,7 +591,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
testfile,
|
||||
proc_args,
|
||||
environment,
|
||||
config.run_lib_path.as_slice(),
|
||||
&config.run_lib_path,
|
||||
None,
|
||||
None);
|
||||
}
|
||||
@ -602,7 +601,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
fatal("gdb failed to execute");
|
||||
}
|
||||
|
||||
check_debugger_output(&debugger_run_result, check_lines.as_slice());
|
||||
check_debugger_output(&debugger_run_result, &check_lines);
|
||||
}
|
||||
|
||||
fn find_rust_src_root(config: &Config) -> Option<Path> {
|
||||
@ -644,7 +643,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||
match config.lldb_version {
|
||||
Some(ref version) => {
|
||||
println!("NOTE: compiletest thinks it is using LLDB version {}",
|
||||
version.as_slice());
|
||||
version);
|
||||
}
|
||||
_ => {
|
||||
println!("NOTE: compiletest does not know which version of \
|
||||
@ -684,13 +683,12 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||
|
||||
// Set breakpoints on every line that contains the string "#break"
|
||||
for line in &breakpoint_lines {
|
||||
script_str.push_str(format!("breakpoint set --line {}\n",
|
||||
line).as_slice());
|
||||
script_str.push_str(&format!("breakpoint set --line {}\n", line));
|
||||
}
|
||||
|
||||
// Append the other commands
|
||||
for line in &commands {
|
||||
script_str.push_str(line.as_slice());
|
||||
script_str.push_str(line);
|
||||
script_str.push_str("\n");
|
||||
}
|
||||
|
||||
@ -701,7 +699,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||
debug!("script_str = {}", script_str);
|
||||
dump_output_file(config,
|
||||
testfile,
|
||||
script_str.as_slice(),
|
||||
&script_str,
|
||||
"debugger.script");
|
||||
let debugger_script = make_out_name(config, testfile, "debugger.script");
|
||||
|
||||
@ -715,7 +713,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||
fatal_proc_rec("Error while running LLDB", &debugger_run_result);
|
||||
}
|
||||
|
||||
check_debugger_output(&debugger_run_result, check_lines.as_slice());
|
||||
check_debugger_output(&debugger_run_result, &check_lines);
|
||||
|
||||
fn run_lldb(config: &Config,
|
||||
test_executable: &Path,
|
||||
@ -729,7 +727,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||
cmd.arg(lldb_script_path)
|
||||
.arg(test_executable)
|
||||
.arg(debugger_script)
|
||||
.env_set_all(&[("PYTHONPATH", config.lldb_python_dir.clone().unwrap().as_slice())]);
|
||||
.env_set_all(&[("PYTHONPATH", config.lldb_python_dir.clone().unwrap())]);
|
||||
|
||||
let (status, out, err) = match cmd.spawn() {
|
||||
Ok(process) => {
|
||||
@ -741,12 +739,12 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||
String::from_utf8(error).unwrap())
|
||||
},
|
||||
Err(e) => {
|
||||
fatal(format!("Failed to setup Python process for \
|
||||
LLDB script: {}", e).as_slice())
|
||||
fatal(&format!("Failed to setup Python process for \
|
||||
LLDB script: {}", e))
|
||||
}
|
||||
};
|
||||
|
||||
dump_output(config, test_executable, out.as_slice(), err.as_slice());
|
||||
dump_output(config, test_executable, &out, &err);
|
||||
return ProcRes {
|
||||
status: status,
|
||||
stdout: out,
|
||||
@ -782,20 +780,19 @@ fn parse_debugger_commands(file_path: &Path, debugger_prefix: &str)
|
||||
}
|
||||
|
||||
header::parse_name_value_directive(
|
||||
line.as_slice(),
|
||||
command_directive.as_slice()).map(|cmd| {
|
||||
&line,
|
||||
&command_directive).map(|cmd| {
|
||||
commands.push(cmd)
|
||||
});
|
||||
|
||||
header::parse_name_value_directive(
|
||||
line.as_slice(),
|
||||
check_directive.as_slice()).map(|cmd| {
|
||||
&line,
|
||||
&check_directive).map(|cmd| {
|
||||
check_lines.push(cmd)
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
fatal(format!("Error while parsing debugger commands: {}",
|
||||
e).as_slice())
|
||||
fatal(&format!("Error while parsing debugger commands: {}", e))
|
||||
}
|
||||
}
|
||||
counter += 1;
|
||||
@ -834,7 +831,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
|
||||
// bits in the wrong case of an enum) with the notation "[...]".
|
||||
let check_fragments: Vec<Vec<String>> =
|
||||
check_lines.iter().map(|s| {
|
||||
s.as_slice()
|
||||
s
|
||||
.trim()
|
||||
.split_str("[...]")
|
||||
.map(|x| x.to_string())
|
||||
@ -849,13 +846,13 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
|
||||
let mut failed = false;
|
||||
for frag in &check_fragments[i] {
|
||||
let found = if first {
|
||||
if rest.starts_with(frag.as_slice()) {
|
||||
if rest.starts_with(frag) {
|
||||
Some(0)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
rest.find_str(frag.as_slice())
|
||||
rest.find_str(frag)
|
||||
};
|
||||
match found {
|
||||
None => {
|
||||
@ -877,8 +874,8 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
|
||||
}
|
||||
}
|
||||
if i != num_check_lines {
|
||||
fatal_proc_rec(format!("line not found in debugger output: {}",
|
||||
check_lines.get(i).unwrap()).as_slice(),
|
||||
fatal_proc_rec(&format!("line not found in debugger output: {}",
|
||||
check_lines.get(i).unwrap()),
|
||||
debugger_run_result);
|
||||
}
|
||||
}
|
||||
@ -889,14 +886,13 @@ fn check_error_patterns(props: &TestProps,
|
||||
output_to_check: &str,
|
||||
proc_res: &ProcRes) {
|
||||
if props.error_patterns.is_empty() {
|
||||
fatal(format!("no error pattern specified in {:?}",
|
||||
testfile.display()).as_slice());
|
||||
fatal(&format!("no error pattern specified in {:?}", testfile.display()));
|
||||
}
|
||||
let mut next_err_idx = 0;
|
||||
let mut next_err_pat = &props.error_patterns[next_err_idx];
|
||||
let mut done = false;
|
||||
for line in output_to_check.lines() {
|
||||
if line.contains(next_err_pat.as_slice()) {
|
||||
if line.contains(next_err_pat) {
|
||||
debug!("found error pattern {}", next_err_pat);
|
||||
next_err_idx += 1;
|
||||
if next_err_idx == props.error_patterns.len() {
|
||||
@ -911,13 +907,11 @@ fn check_error_patterns(props: &TestProps,
|
||||
|
||||
let missing_patterns = &props.error_patterns[next_err_idx..];
|
||||
if missing_patterns.len() == 1 {
|
||||
fatal_proc_rec(format!("error pattern '{}' not found!",
|
||||
missing_patterns[0]).as_slice(),
|
||||
fatal_proc_rec(&format!("error pattern '{}' not found!", missing_patterns[0]),
|
||||
proc_res);
|
||||
} else {
|
||||
for pattern in missing_patterns {
|
||||
error(format!("error pattern '{}' not found!",
|
||||
*pattern).as_slice());
|
||||
error(&format!("error pattern '{}' not found!", *pattern));
|
||||
}
|
||||
fatal_proc_rec("multiple error patterns not found", proc_res);
|
||||
}
|
||||
@ -936,7 +930,7 @@ fn check_forbid_output(props: &TestProps,
|
||||
output_to_check: &str,
|
||||
proc_res: &ProcRes) {
|
||||
for pat in &props.forbid_output {
|
||||
if output_to_check.contains(pat.as_slice()) {
|
||||
if output_to_check.contains(pat) {
|
||||
fatal_proc_rec("forbidden pattern found in compiler output", proc_res);
|
||||
}
|
||||
}
|
||||
@ -959,7 +953,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||
|
||||
#[cfg(windows)]
|
||||
fn prefix_matches( line : &str, prefix : &str ) -> bool {
|
||||
line.to_ascii_lowercase().starts_with(prefix.to_ascii_lowercase().as_slice())
|
||||
line.to_ascii_lowercase().starts_with(&prefix.to_ascii_lowercase())
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
@ -988,13 +982,13 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||
for (i, ee) in expected_errors.iter().enumerate() {
|
||||
if !found_flags[i] {
|
||||
debug!("prefix={} ee.kind={} ee.msg={} line={}",
|
||||
prefixes[i].as_slice(),
|
||||
prefixes[i],
|
||||
ee.kind,
|
||||
ee.msg,
|
||||
line);
|
||||
if (prefix_matches(line, prefixes[i].as_slice()) || continuation(line)) &&
|
||||
line.contains(ee.kind.as_slice()) &&
|
||||
line.contains(ee.msg.as_slice()) {
|
||||
if (prefix_matches(line, &prefixes[i]) || continuation(line)) &&
|
||||
line.contains(&ee.kind) &&
|
||||
line.contains(&ee.msg) {
|
||||
found_flags[i] = true;
|
||||
was_expected = true;
|
||||
break;
|
||||
@ -1008,8 +1002,8 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||
}
|
||||
|
||||
if !was_expected && is_compiler_error_or_warning(line) {
|
||||
fatal_proc_rec(format!("unexpected compiler error or warning: '{}'",
|
||||
line).as_slice(),
|
||||
fatal_proc_rec(&format!("unexpected compiler error or warning: '{}'",
|
||||
line),
|
||||
proc_res);
|
||||
}
|
||||
}
|
||||
@ -1017,8 +1011,8 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||
for (i, &flag) in found_flags.iter().enumerate() {
|
||||
if !flag {
|
||||
let ee = &expected_errors[i];
|
||||
fatal_proc_rec(format!("expected {} on line {} not found: {}",
|
||||
ee.kind, ee.line, ee.msg).as_slice(),
|
||||
fatal_proc_rec(&format!("expected {} on line {} not found: {}",
|
||||
ee.kind, ee.line, ee.msg),
|
||||
proc_res);
|
||||
}
|
||||
}
|
||||
@ -1139,7 +1133,7 @@ fn exec_compiled_test(config: &Config, props: &TestProps,
|
||||
|
||||
let env = props.exec_env.clone();
|
||||
|
||||
match config.target.as_slice() {
|
||||
match &*config.target {
|
||||
|
||||
"arm-linux-androideabi" => {
|
||||
_arm_exec_compiled_test(config, props, testfile, env)
|
||||
@ -1151,7 +1145,7 @@ fn exec_compiled_test(config: &Config, props: &TestProps,
|
||||
testfile,
|
||||
make_run_args(config, props, testfile),
|
||||
env,
|
||||
config.run_lib_path.as_slice(),
|
||||
&config.run_lib_path,
|
||||
Some(aux_dir.as_str().unwrap()),
|
||||
None)
|
||||
}
|
||||
@ -1174,7 +1168,7 @@ fn compose_and_run_compiler(
|
||||
let extra_link_args = vec!("-L".to_string(), aux_dir.as_str().unwrap().to_string());
|
||||
|
||||
for rel_ab in &props.aux_builds {
|
||||
let abs_ab = config.aux_base.join(rel_ab.as_slice());
|
||||
let abs_ab = config.aux_base.join(rel_ab);
|
||||
let aux_props = header::load_props(&abs_ab);
|
||||
let mut crate_type = if aux_props.no_prefer_dynamic {
|
||||
Vec::new()
|
||||
@ -1195,17 +1189,17 @@ fn compose_and_run_compiler(
|
||||
&abs_ab,
|
||||
aux_args,
|
||||
Vec::new(),
|
||||
config.compile_lib_path.as_slice(),
|
||||
&config.compile_lib_path,
|
||||
Some(aux_dir.as_str().unwrap()),
|
||||
None);
|
||||
if !auxres.status.success() {
|
||||
fatal_proc_rec(
|
||||
format!("auxiliary build of {:?} failed to compile: ",
|
||||
abs_ab.display()).as_slice(),
|
||||
&format!("auxiliary build of {:?} failed to compile: ",
|
||||
abs_ab.display()),
|
||||
&auxres);
|
||||
}
|
||||
|
||||
match config.target.as_slice() {
|
||||
match &*config.target {
|
||||
"arm-linux-androideabi" => {
|
||||
_arm_push_aux_shared_library(config, testfile);
|
||||
}
|
||||
@ -1217,7 +1211,7 @@ fn compose_and_run_compiler(
|
||||
testfile,
|
||||
args,
|
||||
Vec::new(),
|
||||
config.compile_lib_path.as_slice(),
|
||||
&config.compile_lib_path,
|
||||
Some(aux_dir.as_str().unwrap()),
|
||||
input)
|
||||
}
|
||||
@ -1252,16 +1246,16 @@ fn make_compile_args<F>(config: &Config,
|
||||
{
|
||||
let xform_file = xform(config, testfile);
|
||||
let target = if props.force_host {
|
||||
config.host.as_slice()
|
||||
&*config.host
|
||||
} else {
|
||||
config.target.as_slice()
|
||||
&*config.target
|
||||
};
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let mut args = vec!(testfile.as_str().unwrap().to_string(),
|
||||
"-L".to_string(),
|
||||
config.build_base.as_str().unwrap().to_string(),
|
||||
format!("--target={}", target));
|
||||
args.push_all(extras.as_slice());
|
||||
args.push_all(&extras);
|
||||
if !props.no_prefer_dynamic {
|
||||
args.push("-C".to_string());
|
||||
args.push("prefer-dynamic".to_string());
|
||||
@ -1329,7 +1323,7 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path) ->
|
||||
fn split_maybe_args(argstr: &Option<String>) -> Vec<String> {
|
||||
match *argstr {
|
||||
Some(ref s) => {
|
||||
s.as_slice()
|
||||
s
|
||||
.split(' ')
|
||||
.filter_map(|s| {
|
||||
if s.chars().all(|c| c.is_whitespace()) {
|
||||
@ -1350,8 +1344,8 @@ fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String
|
||||
let cmdline =
|
||||
{
|
||||
let cmdline = make_cmdline(lib_path,
|
||||
prog.as_slice(),
|
||||
args.as_slice());
|
||||
&prog,
|
||||
&args);
|
||||
logv(config, format!("executing {}", cmdline));
|
||||
cmdline
|
||||
};
|
||||
@ -1360,12 +1354,12 @@ fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String
|
||||
err,
|
||||
status
|
||||
} = procsrv::run(lib_path,
|
||||
prog.as_slice(),
|
||||
&prog,
|
||||
aux_path,
|
||||
args.as_slice(),
|
||||
&args,
|
||||
env,
|
||||
input).expect(format!("failed to exec `{}`", prog).as_slice());
|
||||
dump_output(config, testfile, out.as_slice(), err.as_slice());
|
||||
input).expect(&format!("failed to exec `{}`", prog));
|
||||
dump_output(config, testfile, &out, &err);
|
||||
return ProcRes {
|
||||
status: status,
|
||||
stdout: out,
|
||||
@ -1422,7 +1416,7 @@ fn output_testname(testfile: &Path) -> Path {
|
||||
fn output_base_name(config: &Config, testfile: &Path) -> Path {
|
||||
config.build_base
|
||||
.join(&output_testname(testfile))
|
||||
.with_extension(config.stage_id.as_slice())
|
||||
.with_extension(&config.stage_id)
|
||||
}
|
||||
|
||||
fn maybe_dump_to_stdout(config: &Config, out: &str, err: &str) {
|
||||
@ -1465,12 +1459,11 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
-> ProcRes {
|
||||
let args = make_run_args(config, props, testfile);
|
||||
let cmdline = make_cmdline("",
|
||||
args.prog.as_slice(),
|
||||
args.args.as_slice());
|
||||
&args.prog,
|
||||
&args.args);
|
||||
|
||||
// get bare program string
|
||||
let mut tvec: Vec<String> = args.prog
|
||||
.as_slice()
|
||||
.split('/')
|
||||
.map(|ts| ts.to_string())
|
||||
.collect();
|
||||
@ -1478,7 +1471,7 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
|
||||
// copy to target
|
||||
let copy_result = procsrv::run("",
|
||||
config.adb_path.as_slice(),
|
||||
&config.adb_path,
|
||||
None,
|
||||
&[
|
||||
"push".to_string(),
|
||||
@ -1487,7 +1480,7 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
],
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format!("failed to exec `{}`", config.adb_path).as_slice());
|
||||
.expect(&format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
if config.verbose {
|
||||
println!("push ({}) {} {} {}",
|
||||
@ -1514,11 +1507,11 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
runargs.push(tv.to_string());
|
||||
}
|
||||
procsrv::run("",
|
||||
config.adb_path.as_slice(),
|
||||
&config.adb_path,
|
||||
None,
|
||||
runargs.as_slice(),
|
||||
&runargs,
|
||||
vec!(("".to_string(), "".to_string())), Some("".to_string()))
|
||||
.expect(format!("failed to exec `{}`", config.adb_path).as_slice());
|
||||
.expect(&format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
// get exitcode of result
|
||||
runargs = Vec::new();
|
||||
@ -1528,12 +1521,12 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
|
||||
let procsrv::Result{ out: exitcode_out, err: _, status: _ } =
|
||||
procsrv::run("",
|
||||
config.adb_path.as_slice(),
|
||||
&config.adb_path,
|
||||
None,
|
||||
runargs.as_slice(),
|
||||
&runargs,
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format!("failed to exec `{}`", config.adb_path).as_slice());
|
||||
.expect(&format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
let mut exitcode: int = 0;
|
||||
for c in exitcode_out.chars() {
|
||||
@ -1552,12 +1545,12 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
|
||||
let procsrv::Result{ out: stdout_out, err: _, status: _ } =
|
||||
procsrv::run("",
|
||||
config.adb_path.as_slice(),
|
||||
&config.adb_path,
|
||||
None,
|
||||
runargs.as_slice(),
|
||||
&runargs,
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format!("failed to exec `{}`", config.adb_path).as_slice());
|
||||
.expect(&format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
// get stderr of result
|
||||
runargs = Vec::new();
|
||||
@ -1567,17 +1560,17 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
|
||||
let procsrv::Result{ out: stderr_out, err: _, status: _ } =
|
||||
procsrv::run("",
|
||||
config.adb_path.as_slice(),
|
||||
&config.adb_path,
|
||||
None,
|
||||
runargs.as_slice(),
|
||||
&runargs,
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format!("failed to exec `{}`", config.adb_path).as_slice());
|
||||
.expect(&format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
dump_output(config,
|
||||
testfile,
|
||||
stdout_out.as_slice(),
|
||||
stderr_out.as_slice());
|
||||
&stdout_out,
|
||||
&stderr_out);
|
||||
|
||||
ProcRes {
|
||||
status: process::ProcessExit::ExitStatus(exitcode),
|
||||
@ -1595,7 +1588,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
|
||||
if file.extension_str() == Some("so") {
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let copy_result = procsrv::run("",
|
||||
config.adb_path.as_slice(),
|
||||
&config.adb_path,
|
||||
None,
|
||||
&[
|
||||
"push".to_string(),
|
||||
@ -1607,7 +1600,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
|
||||
vec!(("".to_string(),
|
||||
"".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format!("failed to exec `{}`", config.adb_path).as_slice());
|
||||
.expect(&format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
if config.verbose {
|
||||
println!("push ({}) {:?} {} {}",
|
||||
@ -1702,7 +1695,7 @@ fn disassemble_extract(config: &Config, _props: &TestProps,
|
||||
|
||||
fn count_extracted_lines(p: &Path) -> uint {
|
||||
let x = File::open(&p.with_extension("ll")).read_to_end().unwrap();
|
||||
let x = str::from_utf8(x.as_slice()).unwrap();
|
||||
let x = str::from_utf8(&x).unwrap();
|
||||
x.lines().count()
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, token::Token>) -> TokenAn
|
||||
let toknum = &s[content_end + 3 .. toknum_end];
|
||||
|
||||
let proto_tok = tokens.get(toknum).expect(format!("didn't find token {:?} in the map",
|
||||
toknum).as_slice());
|
||||
toknum));
|
||||
|
||||
let nm = parse::token::intern(content);
|
||||
|
||||
@ -242,8 +242,8 @@ fn main() {
|
||||
|
||||
let args = std::os::args();
|
||||
|
||||
let mut token_file = File::open(&Path::new(args[2].as_slice()));
|
||||
let token_map = parse_token_list(token_file.read_to_string().unwrap().as_slice());
|
||||
let mut token_file = File::open(&Path::new(args[2]));
|
||||
let token_map = parse_token_list(token_file.read_to_string().unwrap());
|
||||
|
||||
let mut stdin = std::io::stdin();
|
||||
let mut lock = stdin.lock();
|
||||
@ -251,7 +251,7 @@ fn main() {
|
||||
let mut antlr_tokens = lines.map(|l| parse_antlr_token(l.unwrap().trim(),
|
||||
&token_map));
|
||||
|
||||
let code = File::open(&Path::new(args[1].as_slice())).unwrap().read_to_string().unwrap();
|
||||
let code = File::open(&Path::new(args[1])).unwrap().read_to_string().unwrap();
|
||||
let options = config::basic_options();
|
||||
let session = session::build_session(options, None,
|
||||
syntax::diagnostics::registry::Registry::new(&[]));
|
||||
|
@ -77,7 +77,7 @@ pub fn find_rand_n<M, T, I, F>(n: uint,
|
||||
insert(map, *k);
|
||||
}
|
||||
|
||||
rng.shuffle(keys.as_mut_slice());
|
||||
rng.shuffle(&mut keys);
|
||||
|
||||
// measure
|
||||
let mut i = 0;
|
||||
|
@ -1910,7 +1910,7 @@ mod tests {
|
||||
fn test_0_elements() {
|
||||
let act = Bitv::new();
|
||||
let exp = Vec::new();
|
||||
assert!(act.eq_vec(exp.as_slice()));
|
||||
assert!(act.eq_vec(&exp));
|
||||
assert!(act.none() && act.all());
|
||||
}
|
||||
|
||||
|
@ -1054,12 +1054,12 @@ mod tests {
|
||||
// Non-empty to non-empty
|
||||
let v = vec![1,2,3,4,5];
|
||||
let u = vec![9,8,1,2,3,4,5];
|
||||
let mut m = list_from(v.as_slice());
|
||||
let mut n = list_from(u.as_slice());
|
||||
let mut m = list_from(&v);
|
||||
let mut n = list_from(&u);
|
||||
m.append(&mut n);
|
||||
check_links(&m);
|
||||
let mut sum = v;
|
||||
sum.push_all(u.as_slice());
|
||||
sum.push_all(&u);
|
||||
assert_eq!(sum.len(), m.len());
|
||||
for elt in sum {
|
||||
assert_eq!(m.pop_front(), Some(elt))
|
||||
@ -1090,7 +1090,7 @@ mod tests {
|
||||
// not singleton, forwards
|
||||
{
|
||||
let u = vec![1,2,3,4,5];
|
||||
let mut m = list_from(u.as_slice());
|
||||
let mut m = list_from(&u);
|
||||
let mut n = m.split_off(2);
|
||||
assert_eq!(m.len(), 2);
|
||||
assert_eq!(n.len(), 3);
|
||||
@ -1104,7 +1104,7 @@ mod tests {
|
||||
// not singleton, backwards
|
||||
{
|
||||
let u = vec![1,2,3,4,5];
|
||||
let mut m = list_from(u.as_slice());
|
||||
let mut m = list_from(&u);
|
||||
let mut n = m.split_off(4);
|
||||
assert_eq!(m.len(), 4);
|
||||
assert_eq!(n.len(), 1);
|
||||
|
@ -1528,7 +1528,7 @@ mod tests {
|
||||
// Test on-stack from_fn.
|
||||
let mut v = (0u..3).map(square).collect::<Vec<_>>();
|
||||
{
|
||||
let v = v.as_slice();
|
||||
let v = v;
|
||||
assert_eq!(v.len(), 3u);
|
||||
assert_eq!(v[0], 0u);
|
||||
assert_eq!(v[1], 1u);
|
||||
@ -1538,7 +1538,7 @@ mod tests {
|
||||
// Test on-heap from_fn.
|
||||
v = (0u..5).map(square).collect::<Vec<_>>();
|
||||
{
|
||||
let v = v.as_slice();
|
||||
let v = v;
|
||||
assert_eq!(v.len(), 5u);
|
||||
assert_eq!(v[0], 0u);
|
||||
assert_eq!(v[1], 1u);
|
||||
@ -1553,7 +1553,7 @@ mod tests {
|
||||
// Test on-stack from_elem.
|
||||
let mut v = vec![10u, 10u];
|
||||
{
|
||||
let v = v.as_slice();
|
||||
let v = v;
|
||||
assert_eq!(v.len(), 2u);
|
||||
assert_eq!(v[0], 10u);
|
||||
assert_eq!(v[1], 10u);
|
||||
@ -1562,7 +1562,7 @@ mod tests {
|
||||
// Test on-heap from_elem.
|
||||
v = vec![20u, 20u, 20u, 20u, 20u, 20u];
|
||||
{
|
||||
let v = v.as_slice();
|
||||
let v = v;
|
||||
assert_eq!(v[0], 20u);
|
||||
assert_eq!(v[1], 20u);
|
||||
assert_eq!(v[2], 20u);
|
||||
@ -1715,7 +1715,7 @@ mod tests {
|
||||
let vec_fixed = [1, 2, 3, 4];
|
||||
let v_a = vec_fixed[1u..vec_fixed.len()].to_vec();
|
||||
assert_eq!(v_a.len(), 3u);
|
||||
let v_a = v_a.as_slice();
|
||||
let v_a = v_a;
|
||||
assert_eq!(v_a[0], 2);
|
||||
assert_eq!(v_a[1], 3);
|
||||
assert_eq!(v_a[2], 4);
|
||||
@ -1724,7 +1724,7 @@ mod tests {
|
||||
let vec_stack: &[_] = &[1, 2, 3];
|
||||
let v_b = vec_stack[1u..3u].to_vec();
|
||||
assert_eq!(v_b.len(), 2u);
|
||||
let v_b = v_b.as_slice();
|
||||
let v_b = v_b;
|
||||
assert_eq!(v_b[0], 2);
|
||||
assert_eq!(v_b[1], 3);
|
||||
|
||||
@ -1732,7 +1732,7 @@ mod tests {
|
||||
let vec_unique = vec![1, 2, 3, 4, 5, 6];
|
||||
let v_d = vec_unique[1u..6u].to_vec();
|
||||
assert_eq!(v_d.len(), 5u);
|
||||
let v_d = v_d.as_slice();
|
||||
let v_d = v_d;
|
||||
assert_eq!(v_d[0], 2);
|
||||
assert_eq!(v_d[1], 3);
|
||||
assert_eq!(v_d[2], 4);
|
||||
@ -1813,20 +1813,20 @@ mod tests {
|
||||
let mut v = vec![];
|
||||
v.push(1);
|
||||
assert_eq!(v.len(), 1u);
|
||||
assert_eq!(v.as_slice()[0], 1);
|
||||
assert_eq!(v[0], 1);
|
||||
|
||||
// Test on-heap push().
|
||||
v.push(2);
|
||||
assert_eq!(v.len(), 2u);
|
||||
assert_eq!(v.as_slice()[0], 1);
|
||||
assert_eq!(v.as_slice()[1], 2);
|
||||
assert_eq!(v[0], 1);
|
||||
assert_eq!(v[1], 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_truncate() {
|
||||
let mut v = vec![box 6,box 5,box 4];
|
||||
v.truncate(1);
|
||||
let v = v.as_slice();
|
||||
let v = v;
|
||||
assert_eq!(v.len(), 1);
|
||||
assert_eq!(*(v[0]), 6);
|
||||
// If the unsafe block didn't drop things properly, we blow up here.
|
||||
@ -2587,7 +2587,7 @@ mod tests {
|
||||
($x:expr, $x_str:expr) => ({
|
||||
let (x, x_str) = ($x, $x_str);
|
||||
assert_eq!(format!("{:?}", x), x_str);
|
||||
assert_eq!(format!("{:?}", x.as_slice()), x_str);
|
||||
assert_eq!(format!("{:?}", x), x_str);
|
||||
})
|
||||
}
|
||||
let empty: Vec<int> = vec![];
|
||||
@ -2910,7 +2910,7 @@ mod bench {
|
||||
fn starts_with_same_vector(b: &mut Bencher) {
|
||||
let vec: Vec<uint> = (0u..100).collect();
|
||||
b.iter(|| {
|
||||
vec.starts_with(vec.as_slice())
|
||||
vec.starts_with(&vec)
|
||||
})
|
||||
}
|
||||
|
||||
@ -2918,7 +2918,7 @@ mod bench {
|
||||
fn starts_with_single_element(b: &mut Bencher) {
|
||||
let vec: Vec<uint> = vec![0];
|
||||
b.iter(|| {
|
||||
vec.starts_with(vec.as_slice())
|
||||
vec.starts_with(&vec)
|
||||
})
|
||||
}
|
||||
|
||||
@ -2928,7 +2928,7 @@ mod bench {
|
||||
let mut match_vec: Vec<uint> = (0u..99).collect();
|
||||
match_vec.push(0);
|
||||
b.iter(|| {
|
||||
vec.starts_with(match_vec.as_slice())
|
||||
vec.starts_with(&match_vec)
|
||||
})
|
||||
}
|
||||
|
||||
@ -2936,7 +2936,7 @@ mod bench {
|
||||
fn ends_with_same_vector(b: &mut Bencher) {
|
||||
let vec: Vec<uint> = (0u..100).collect();
|
||||
b.iter(|| {
|
||||
vec.ends_with(vec.as_slice())
|
||||
vec.ends_with(&vec)
|
||||
})
|
||||
}
|
||||
|
||||
@ -2944,7 +2944,7 @@ mod bench {
|
||||
fn ends_with_single_element(b: &mut Bencher) {
|
||||
let vec: Vec<uint> = vec![0];
|
||||
b.iter(|| {
|
||||
vec.ends_with(vec.as_slice())
|
||||
vec.ends_with(&vec)
|
||||
})
|
||||
}
|
||||
|
||||
@ -2952,9 +2952,9 @@ mod bench {
|
||||
fn ends_with_diff_one_element_at_beginning(b: &mut Bencher) {
|
||||
let vec: Vec<uint> = (0u..100).collect();
|
||||
let mut match_vec: Vec<uint> = (0u..100).collect();
|
||||
match_vec.as_mut_slice()[0] = 200;
|
||||
match_vec[0] = 200;
|
||||
b.iter(|| {
|
||||
vec.starts_with(match_vec.as_slice())
|
||||
vec.starts_with(&match_vec)
|
||||
})
|
||||
}
|
||||
|
||||
@ -3042,7 +3042,7 @@ mod bench {
|
||||
let mut rng = weak_rng();
|
||||
b.iter(|| {
|
||||
let mut v = rng.gen_iter::<u64>().take(5).collect::<Vec<u64>>();
|
||||
v.as_mut_slice().sort();
|
||||
v.sort();
|
||||
});
|
||||
b.bytes = 5 * mem::size_of::<u64>() as u64;
|
||||
}
|
||||
@ -3052,7 +3052,7 @@ mod bench {
|
||||
let mut rng = weak_rng();
|
||||
b.iter(|| {
|
||||
let mut v = rng.gen_iter::<u64>().take(100).collect::<Vec<u64>>();
|
||||
v.as_mut_slice().sort();
|
||||
v.sort();
|
||||
});
|
||||
b.bytes = 100 * mem::size_of::<u64>() as u64;
|
||||
}
|
||||
@ -3062,7 +3062,7 @@ mod bench {
|
||||
let mut rng = weak_rng();
|
||||
b.iter(|| {
|
||||
let mut v = rng.gen_iter::<u64>().take(10000).collect::<Vec<u64>>();
|
||||
v.as_mut_slice().sort();
|
||||
v.sort();
|
||||
});
|
||||
b.bytes = 10000 * mem::size_of::<u64>() as u64;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ impl<'a> Iterator for Decompositions<'a> {
|
||||
let class =
|
||||
unicode::char::canonical_combining_class(d);
|
||||
if class == 0 && !*sorted {
|
||||
canonical_sort(buffer.as_mut_slice());
|
||||
canonical_sort(buffer);
|
||||
*sorted = true;
|
||||
}
|
||||
buffer.push((d, class));
|
||||
@ -224,7 +224,7 @@ impl<'a> Iterator for Decompositions<'a> {
|
||||
}
|
||||
|
||||
if !self.sorted {
|
||||
canonical_sort(self.buffer.as_mut_slice());
|
||||
canonical_sort(&mut self.buffer);
|
||||
self.sorted = true;
|
||||
}
|
||||
|
||||
@ -1480,7 +1480,7 @@ mod tests {
|
||||
fn test_concat_for_different_types() {
|
||||
test_concat!("ab", vec![s("a"), s("b")]);
|
||||
test_concat!("ab", vec!["a", "b"]);
|
||||
test_concat!("ab", vec!["a", "b"].as_slice());
|
||||
test_concat!("ab", vec!["a", "b"]);
|
||||
test_concat!("ab", vec![s("a"), s("b")]);
|
||||
}
|
||||
|
||||
@ -1506,9 +1506,9 @@ mod tests {
|
||||
fn test_connect_for_different_types() {
|
||||
test_connect!("a-b", ["a", "b"], "-");
|
||||
let hyphen = "-".to_string();
|
||||
test_connect!("a-b", [s("a"), s("b")], hyphen.as_slice());
|
||||
test_connect!("a-b", vec!["a", "b"], hyphen.as_slice());
|
||||
test_connect!("a-b", vec!["a", "b"].as_slice(), "-");
|
||||
test_connect!("a-b", [s("a"), s("b")], &*hyphen);
|
||||
test_connect!("a-b", vec!["a", "b"], &*hyphen);
|
||||
test_connect!("a-b", &*vec!["a", "b"], "-");
|
||||
test_connect!("a-b", vec![s("a"), s("b")], "-");
|
||||
}
|
||||
|
||||
@ -1960,7 +1960,7 @@ mod tests {
|
||||
let s1: String = String::from_str("All mimsy were the borogoves");
|
||||
|
||||
let v: Vec<u8> = s1.as_bytes().to_vec();
|
||||
let s2: String = String::from_str(from_utf8(v.as_slice()).unwrap());
|
||||
let s2: String = String::from_str(from_utf8(&v).unwrap());
|
||||
let mut i: uint = 0u;
|
||||
let n1: uint = s1.len();
|
||||
let n2: uint = v.len();
|
||||
@ -2791,11 +2791,11 @@ mod tests {
|
||||
|
||||
let s = String::from_str("01234");
|
||||
assert_eq!(5, sum_len(&["012", "", "34"]));
|
||||
assert_eq!(5, sum_len(&[String::from_str("01").as_slice(),
|
||||
String::from_str("2").as_slice(),
|
||||
String::from_str("34").as_slice(),
|
||||
String::from_str("").as_slice()]));
|
||||
assert_eq!(5, sum_len(&[s.as_slice()]));
|
||||
assert_eq!(5, sum_len(&[&String::from_str("01"),
|
||||
&String::from_str("2"),
|
||||
&String::from_str("34"),
|
||||
&String::from_str("")]));
|
||||
assert_eq!(5, sum_len(&[&s]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -126,7 +126,7 @@ impl String {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
|
||||
match str::from_utf8(vec.as_slice()) {
|
||||
match str::from_utf8(&vec) {
|
||||
Ok(..) => Ok(String { vec: vec }),
|
||||
Err(e) => Err(FromUtf8Error { bytes: vec, error: e })
|
||||
}
|
||||
@ -489,7 +489,7 @@ impl String {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
|
||||
self.vec.as_slice()
|
||||
&self.vec
|
||||
}
|
||||
|
||||
/// Shortens a string to the specified length.
|
||||
@ -804,7 +804,7 @@ impl Str for String {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn as_slice<'a>(&'a self) -> &'a str {
|
||||
unsafe { mem::transmute(self.vec.as_slice()) }
|
||||
unsafe { mem::transmute(&*self.vec) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -882,7 +882,7 @@ impl ops::Index<ops::RangeFull> for String {
|
||||
type Output = str;
|
||||
#[inline]
|
||||
fn index(&self, _index: &ops::RangeFull) -> &str {
|
||||
unsafe { mem::transmute(self.vec.as_slice()) }
|
||||
unsafe { mem::transmute(&*self.vec) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -980,7 +980,7 @@ pub type CowString<'a> = Cow<'a, String, str>;
|
||||
impl<'a> Str for CowString<'a> {
|
||||
#[inline]
|
||||
fn as_slice<'b>(&'b self) -> &'b str {
|
||||
(**self).as_slice()
|
||||
&**self
|
||||
}
|
||||
}
|
||||
|
||||
@ -1005,13 +1005,13 @@ mod tests {
|
||||
#[test]
|
||||
fn test_as_string() {
|
||||
let x = "foo";
|
||||
assert_eq!(x, as_string(x).as_slice());
|
||||
assert_eq!(x, &**as_string(x));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_str() {
|
||||
let owned: Option<::std::string::String> = "string".parse().ok();
|
||||
assert_eq!(owned.as_ref().map(|s| s.as_slice()), Some("string"));
|
||||
assert_eq!(owned.as_ref().map(|s| &**s), Some("string"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1121,15 +1121,15 @@ mod tests {
|
||||
for p in &pairs {
|
||||
let (s, u) = (*p).clone();
|
||||
let s_as_utf16 = s.utf16_units().collect::<Vec<u16>>();
|
||||
let u_as_string = String::from_utf16(u.as_slice()).unwrap();
|
||||
let u_as_string = String::from_utf16(&u).unwrap();
|
||||
|
||||
assert!(::unicode::str::is_utf16(u.as_slice()));
|
||||
assert!(::unicode::str::is_utf16(&u));
|
||||
assert_eq!(s_as_utf16, u);
|
||||
|
||||
assert_eq!(u_as_string, s);
|
||||
assert_eq!(String::from_utf16_lossy(u.as_slice()), s);
|
||||
assert_eq!(String::from_utf16_lossy(&u), s);
|
||||
|
||||
assert_eq!(String::from_utf16(s_as_utf16.as_slice()).unwrap(), s);
|
||||
assert_eq!(String::from_utf16(&s_as_utf16).unwrap(), s);
|
||||
assert_eq!(u_as_string.utf16_units().collect::<Vec<u16>>(), u);
|
||||
}
|
||||
}
|
||||
@ -1419,7 +1419,7 @@ mod tests {
|
||||
fn from_utf8_lossy_100_invalid(b: &mut Bencher) {
|
||||
let s = repeat(0xf5u8).take(100).collect::<Vec<_>>();
|
||||
b.iter(|| {
|
||||
let _ = String::from_utf8_lossy(s.as_slice());
|
||||
let _ = String::from_utf8_lossy(&s);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ impl<T> Vec<T> {
|
||||
pub fn into_boxed_slice(mut self) -> Box<[T]> {
|
||||
self.shrink_to_fit();
|
||||
unsafe {
|
||||
let xs: Box<[T]> = mem::transmute(self.as_mut_slice());
|
||||
let xs: Box<[T]> = mem::transmute(&mut *self);
|
||||
mem::forget(self);
|
||||
xs
|
||||
}
|
||||
@ -604,7 +604,7 @@ impl<T> Vec<T> {
|
||||
let len = self.len();
|
||||
let mut del = 0u;
|
||||
{
|
||||
let v = self.as_mut_slice();
|
||||
let v = &mut **self;
|
||||
|
||||
for i in 0u..len {
|
||||
if !f(&v[i]) {
|
||||
@ -1246,7 +1246,7 @@ unsafe fn dealloc<T>(ptr: *mut T, len: uint) {
|
||||
|
||||
#[unstable(feature = "collections")]
|
||||
impl<T:Clone> Clone for Vec<T> {
|
||||
fn clone(&self) -> Vec<T> { ::slice::SliceExt::to_vec(self.as_slice()) }
|
||||
fn clone(&self) -> Vec<T> { ::slice::SliceExt::to_vec(&**self) }
|
||||
|
||||
fn clone_from(&mut self, other: &Vec<T>) {
|
||||
// drop anything in self that will not be overwritten
|
||||
@ -1269,7 +1269,7 @@ impl<T:Clone> Clone for Vec<T> {
|
||||
impl<S: hash::Writer + hash::Hasher, T: Hash<S>> Hash<S> for Vec<T> {
|
||||
#[inline]
|
||||
fn hash(&self, state: &mut S) {
|
||||
self.as_slice().hash(state);
|
||||
Hash::hash(&**self, state)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1279,7 +1279,8 @@ impl<T> Index<uint> for Vec<T> {
|
||||
|
||||
#[inline]
|
||||
fn index<'a>(&'a self, index: &uint) -> &'a T {
|
||||
&self.as_slice()[*index]
|
||||
// NB built-in indexing via `&[T]`
|
||||
&(**self)[*index]
|
||||
}
|
||||
}
|
||||
|
||||
@ -1289,7 +1290,8 @@ impl<T> IndexMut<uint> for Vec<T> {
|
||||
|
||||
#[inline]
|
||||
fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut T {
|
||||
&mut self.as_mut_slice()[*index]
|
||||
// NB built-in indexing via `&mut [T]`
|
||||
&mut (**self)[*index]
|
||||
}
|
||||
}
|
||||
|
||||
@ -1299,7 +1301,7 @@ impl<T> ops::Index<ops::Range<uint>> for Vec<T> {
|
||||
type Output = [T];
|
||||
#[inline]
|
||||
fn index(&self, index: &ops::Range<uint>) -> &[T] {
|
||||
self.as_slice().index(index)
|
||||
Index::index(&**self, index)
|
||||
}
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -1307,7 +1309,7 @@ impl<T> ops::Index<ops::RangeTo<uint>> for Vec<T> {
|
||||
type Output = [T];
|
||||
#[inline]
|
||||
fn index(&self, index: &ops::RangeTo<uint>) -> &[T] {
|
||||
self.as_slice().index(index)
|
||||
Index::index(&**self, index)
|
||||
}
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -1315,7 +1317,7 @@ impl<T> ops::Index<ops::RangeFrom<uint>> for Vec<T> {
|
||||
type Output = [T];
|
||||
#[inline]
|
||||
fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
|
||||
self.as_slice().index(index)
|
||||
Index::index(&**self, index)
|
||||
}
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -1332,7 +1334,7 @@ impl<T> ops::IndexMut<ops::Range<uint>> for Vec<T> {
|
||||
type Output = [T];
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: &ops::Range<uint>) -> &mut [T] {
|
||||
self.as_mut_slice().index_mut(index)
|
||||
IndexMut::index_mut(&mut **self, index)
|
||||
}
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -1340,7 +1342,7 @@ impl<T> ops::IndexMut<ops::RangeTo<uint>> for Vec<T> {
|
||||
type Output = [T];
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: &ops::RangeTo<uint>) -> &mut [T] {
|
||||
self.as_mut_slice().index_mut(index)
|
||||
IndexMut::index_mut(&mut **self, index)
|
||||
}
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -1348,7 +1350,7 @@ impl<T> ops::IndexMut<ops::RangeFrom<uint>> for Vec<T> {
|
||||
type Output = [T];
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: &ops::RangeFrom<uint>) -> &mut [T] {
|
||||
self.as_mut_slice().index_mut(index)
|
||||
IndexMut::index_mut(&mut **self, index)
|
||||
}
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -1489,7 +1491,7 @@ impl_eq_for_cowvec! { &'b mut [B] }
|
||||
impl<T: PartialOrd> PartialOrd for Vec<T> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Vec<T>) -> Option<Ordering> {
|
||||
self.as_slice().partial_cmp(other.as_slice())
|
||||
PartialOrd::partial_cmp(&**self, &**other)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1500,7 +1502,7 @@ impl<T: Eq> Eq for Vec<T> {}
|
||||
impl<T: Ord> Ord for Vec<T> {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Vec<T>) -> Ordering {
|
||||
self.as_slice().cmp(other.as_slice())
|
||||
Ord::cmp(&**self, &**other)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1567,7 +1569,7 @@ impl<T> Default for Vec<T> {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: fmt::Debug> fmt::Debug for Vec<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Debug::fmt(self.as_slice(), f)
|
||||
fmt::Debug::fmt(&**self, f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1931,7 +1933,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_as_vec() {
|
||||
let xs = [1u8, 2u8, 3u8];
|
||||
assert_eq!(as_vec(&xs).as_slice(), xs);
|
||||
assert_eq!(&**as_vec(&xs), xs);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -2396,7 +2398,7 @@ mod tests {
|
||||
fn test_into_boxed_slice() {
|
||||
let xs = vec![1u, 2, 3];
|
||||
let ys = xs.into_boxed_slice();
|
||||
assert_eq!(ys.as_slice(), [1u, 2, 3]);
|
||||
assert_eq!(ys, [1u, 2, 3]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -2636,7 +2638,7 @@ mod tests {
|
||||
|
||||
b.iter(|| {
|
||||
let mut dst = dst.clone();
|
||||
dst.push_all(src.as_slice());
|
||||
dst.push_all(&src);
|
||||
assert_eq!(dst.len(), dst_len + src_len);
|
||||
assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
|
||||
});
|
||||
|
@ -123,7 +123,7 @@ macro_rules! impl_hash {
|
||||
let a: [u8; ::$ty::BYTES] = unsafe {
|
||||
mem::transmute((*self as $uty).to_le() as $ty)
|
||||
};
|
||||
state.write(a.as_slice())
|
||||
state.write(&a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ fn test_escape_unicode() {
|
||||
fn test_encode_utf8() {
|
||||
fn check(input: char, expect: &[u8]) {
|
||||
let mut buf = [0u8; 4];
|
||||
let n = input.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
|
||||
let n = input.encode_utf8(&mut buf).unwrap_or(0);
|
||||
assert_eq!(&buf[..n], expect);
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ fn test_encode_utf8() {
|
||||
fn test_encode_utf16() {
|
||||
fn check(input: char, expect: &[u16]) {
|
||||
let mut buf = [0u16; 2];
|
||||
let n = input.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
|
||||
let n = input.encode_utf16(&mut buf).unwrap_or(0);
|
||||
assert_eq!(&buf[..n], expect);
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ fn test_siphash() {
|
||||
fn to_hex_str(r: &[u8; 8]) -> String {
|
||||
let mut s = String::new();
|
||||
for b in r {
|
||||
s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice());
|
||||
s.push_str(format!("{}", fmt::radix(*b, 16)));
|
||||
}
|
||||
s
|
||||
}
|
||||
@ -131,7 +131,7 @@ fn test_siphash() {
|
||||
let r = result_bytes(h);
|
||||
let mut s = String::new();
|
||||
for b in &r {
|
||||
s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice());
|
||||
s.push_str(format!("{}", fmt::radix(*b, 16)));
|
||||
}
|
||||
s
|
||||
}
|
||||
@ -139,12 +139,12 @@ fn test_siphash() {
|
||||
while t < 64 {
|
||||
debug!("siphash test {}: {}", t, buf);
|
||||
let vec = u8to64_le!(vecs[t], 0);
|
||||
let out = hash_with_keys(k0, k1, &Bytes(buf.as_slice()));
|
||||
let out = hash_with_keys(k0, k1, &Bytes(buf));
|
||||
debug!("got {}, expected {}", out, vec);
|
||||
assert_eq!(vec, out);
|
||||
|
||||
state_full.reset();
|
||||
state_full.write(buf.as_slice());
|
||||
state_full.write(buf);
|
||||
let f = result_str(state_full.result());
|
||||
let i = result_str(state_inc.result());
|
||||
let v = to_hex_str(&vecs[t]);
|
||||
|
@ -147,24 +147,24 @@ mod tests {
|
||||
for _ in 0..20 {
|
||||
let mut input = vec![];
|
||||
for _ in 0..2000 {
|
||||
input.push_all(r.choose(words.as_slice()).unwrap().as_slice());
|
||||
input.push_all(r.choose(&words).unwrap());
|
||||
}
|
||||
debug!("de/inflate of {} bytes of random word-sequences",
|
||||
input.len());
|
||||
let cmp = deflate_bytes(input.as_slice()).expect("deflation failed");
|
||||
let out = inflate_bytes(cmp.as_slice()).expect("inflation failed");
|
||||
let cmp = deflate_bytes(&input).expect("deflation failed");
|
||||
let out = inflate_bytes(&cmp).expect("inflation failed");
|
||||
debug!("{} bytes deflated to {} ({:.1}% size)",
|
||||
input.len(), cmp.len(),
|
||||
100.0 * ((cmp.len() as f64) / (input.len() as f64)));
|
||||
assert_eq!(input, out.as_slice());
|
||||
assert_eq!(&*input, &*out);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_zlib_flate() {
|
||||
let bytes = vec!(1, 2, 3, 4, 5);
|
||||
let deflated = deflate_bytes(bytes.as_slice()).expect("deflation failed");
|
||||
let inflated = inflate_bytes(deflated.as_slice()).expect("inflation failed");
|
||||
assert_eq!(inflated.as_slice(), bytes);
|
||||
let deflated = deflate_bytes(&bytes).expect("deflation failed");
|
||||
let inflated = inflate_bytes(&deflated).expect("inflation failed");
|
||||
assert_eq!(&*inflated, &*bytes);
|
||||
}
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ impl Matches {
|
||||
/// Returns true if any of several options were matched.
|
||||
pub fn opts_present(&self, names: &[String]) -> bool {
|
||||
for nm in names {
|
||||
match find_opt(self.opts.as_slice(), Name::from_str(&nm[])) {
|
||||
match find_opt(&self.opts, Name::from_str(&**nm)) {
|
||||
Some(id) if !self.vals[id].is_empty() => return true,
|
||||
_ => (),
|
||||
};
|
||||
@ -627,7 +627,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
|
||||
interpreted correctly
|
||||
*/
|
||||
|
||||
let opt_id = match find_opt(opts.as_slice(), opt.clone()) {
|
||||
let opt_id = match find_opt(&opts, opt.clone()) {
|
||||
Some(id) => id,
|
||||
None => return Err(UnrecognizedOption(opt.to_string()))
|
||||
};
|
||||
@ -650,7 +650,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
|
||||
let mut name_pos = 0;
|
||||
for nm in &names {
|
||||
name_pos += 1;
|
||||
let optid = match find_opt(opts.as_slice(), (*nm).clone()) {
|
||||
let optid = match find_opt(&opts, (*nm).clone()) {
|
||||
Some(id) => id,
|
||||
None => return Err(UnrecognizedOption(nm.to_string()))
|
||||
};
|
||||
@ -981,7 +981,7 @@ mod tests {
|
||||
fn test_reqopt() {
|
||||
let long_args = vec!("--test=20".to_string());
|
||||
let opts = vec!(reqopt("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(long_args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&long_args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert!(m.opt_present("test"));
|
||||
@ -992,7 +992,7 @@ mod tests {
|
||||
_ => { panic!("test_reqopt failed (long arg)"); }
|
||||
}
|
||||
let short_args = vec!("-t".to_string(), "20".to_string());
|
||||
match getopts(short_args.as_slice(), opts.as_slice()) {
|
||||
match getopts(&short_args, &opts) {
|
||||
Ok(ref m) => {
|
||||
assert!((m.opt_present("test")));
|
||||
assert_eq!(m.opt_str("test").unwrap(), "20");
|
||||
@ -1007,7 +1007,7 @@ mod tests {
|
||||
fn test_reqopt_missing() {
|
||||
let args = vec!("blah".to_string());
|
||||
let opts = vec!(reqopt("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Err(OptionMissing(_)) => {},
|
||||
_ => panic!()
|
||||
@ -1018,13 +1018,13 @@ mod tests {
|
||||
fn test_reqopt_no_arg() {
|
||||
let long_args = vec!("--test".to_string());
|
||||
let opts = vec!(reqopt("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(long_args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&long_args, &opts);
|
||||
match rs {
|
||||
Err(ArgumentMissing(_)) => {},
|
||||
_ => panic!()
|
||||
}
|
||||
let short_args = vec!("-t".to_string());
|
||||
match getopts(short_args.as_slice(), opts.as_slice()) {
|
||||
match getopts(&short_args, &opts) {
|
||||
Err(ArgumentMissing(_)) => {},
|
||||
_ => panic!()
|
||||
}
|
||||
@ -1034,7 +1034,7 @@ mod tests {
|
||||
fn test_reqopt_multi() {
|
||||
let args = vec!("--test=20".to_string(), "-t".to_string(), "30".to_string());
|
||||
let opts = vec!(reqopt("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Err(OptionDuplicated(_)) => {},
|
||||
_ => panic!()
|
||||
@ -1046,7 +1046,7 @@ mod tests {
|
||||
fn test_optopt() {
|
||||
let long_args = vec!("--test=20".to_string());
|
||||
let opts = vec!(optopt("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(long_args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&long_args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert!(m.opt_present("test"));
|
||||
@ -1057,7 +1057,7 @@ mod tests {
|
||||
_ => panic!()
|
||||
}
|
||||
let short_args = vec!("-t".to_string(), "20".to_string());
|
||||
match getopts(short_args.as_slice(), opts.as_slice()) {
|
||||
match getopts(&short_args, &opts) {
|
||||
Ok(ref m) => {
|
||||
assert!((m.opt_present("test")));
|
||||
assert_eq!(m.opt_str("test").unwrap(), "20");
|
||||
@ -1072,7 +1072,7 @@ mod tests {
|
||||
fn test_optopt_missing() {
|
||||
let args = vec!("blah".to_string());
|
||||
let opts = vec!(optopt("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert!(!m.opt_present("test"));
|
||||
@ -1086,13 +1086,13 @@ mod tests {
|
||||
fn test_optopt_no_arg() {
|
||||
let long_args = vec!("--test".to_string());
|
||||
let opts = vec!(optopt("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(long_args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&long_args, &opts);
|
||||
match rs {
|
||||
Err(ArgumentMissing(_)) => {},
|
||||
_ => panic!()
|
||||
}
|
||||
let short_args = vec!("-t".to_string());
|
||||
match getopts(short_args.as_slice(), opts.as_slice()) {
|
||||
match getopts(&short_args, &opts) {
|
||||
Err(ArgumentMissing(_)) => {},
|
||||
_ => panic!()
|
||||
}
|
||||
@ -1102,7 +1102,7 @@ mod tests {
|
||||
fn test_optopt_multi() {
|
||||
let args = vec!("--test=20".to_string(), "-t".to_string(), "30".to_string());
|
||||
let opts = vec!(optopt("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Err(OptionDuplicated(_)) => {},
|
||||
_ => panic!()
|
||||
@ -1114,7 +1114,7 @@ mod tests {
|
||||
fn test_optflag() {
|
||||
let long_args = vec!("--test".to_string());
|
||||
let opts = vec!(optflag("t", "test", "testing"));
|
||||
let rs = getopts(long_args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&long_args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert!(m.opt_present("test"));
|
||||
@ -1123,7 +1123,7 @@ mod tests {
|
||||
_ => panic!()
|
||||
}
|
||||
let short_args = vec!("-t".to_string());
|
||||
match getopts(short_args.as_slice(), opts.as_slice()) {
|
||||
match getopts(&short_args, &opts) {
|
||||
Ok(ref m) => {
|
||||
assert!(m.opt_present("test"));
|
||||
assert!(m.opt_present("t"));
|
||||
@ -1136,7 +1136,7 @@ mod tests {
|
||||
fn test_optflag_missing() {
|
||||
let args = vec!("blah".to_string());
|
||||
let opts = vec!(optflag("t", "test", "testing"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert!(!m.opt_present("test"));
|
||||
@ -1150,7 +1150,7 @@ mod tests {
|
||||
fn test_optflag_long_arg() {
|
||||
let args = vec!("--test=20".to_string());
|
||||
let opts = vec!(optflag("t", "test", "testing"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Err(UnexpectedArgument(_)) => {},
|
||||
_ => panic!()
|
||||
@ -1161,7 +1161,7 @@ mod tests {
|
||||
fn test_optflag_multi() {
|
||||
let args = vec!("--test".to_string(), "-t".to_string());
|
||||
let opts = vec!(optflag("t", "test", "testing"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Err(OptionDuplicated(_)) => {},
|
||||
_ => panic!()
|
||||
@ -1172,7 +1172,7 @@ mod tests {
|
||||
fn test_optflag_short_arg() {
|
||||
let args = vec!("-t".to_string(), "20".to_string());
|
||||
let opts = vec!(optflag("t", "test", "testing"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
// The next variable after the flag is just a free argument
|
||||
@ -1188,7 +1188,7 @@ mod tests {
|
||||
fn test_optflagmulti_short1() {
|
||||
let args = vec!("-v".to_string());
|
||||
let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert_eq!(m.opt_count("v"), 1);
|
||||
@ -1201,7 +1201,7 @@ mod tests {
|
||||
fn test_optflagmulti_short2a() {
|
||||
let args = vec!("-v".to_string(), "-v".to_string());
|
||||
let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert_eq!(m.opt_count("v"), 2);
|
||||
@ -1214,7 +1214,7 @@ mod tests {
|
||||
fn test_optflagmulti_short2b() {
|
||||
let args = vec!("-vv".to_string());
|
||||
let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert_eq!(m.opt_count("v"), 2);
|
||||
@ -1227,7 +1227,7 @@ mod tests {
|
||||
fn test_optflagmulti_long1() {
|
||||
let args = vec!("--verbose".to_string());
|
||||
let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert_eq!(m.opt_count("verbose"), 1);
|
||||
@ -1240,7 +1240,7 @@ mod tests {
|
||||
fn test_optflagmulti_long2() {
|
||||
let args = vec!("--verbose".to_string(), "--verbose".to_string());
|
||||
let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert_eq!(m.opt_count("verbose"), 2);
|
||||
@ -1254,7 +1254,7 @@ mod tests {
|
||||
let args = vec!("--verbose".to_string(), "-v".to_string(),
|
||||
"-vv".to_string(), "verbose".to_string());
|
||||
let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert_eq!(m.opt_count("verbose"), 4);
|
||||
@ -1269,7 +1269,7 @@ mod tests {
|
||||
fn test_optmulti() {
|
||||
let long_args = vec!("--test=20".to_string());
|
||||
let opts = vec!(optmulti("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(long_args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&long_args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert!((m.opt_present("test")));
|
||||
@ -1280,7 +1280,7 @@ mod tests {
|
||||
_ => panic!()
|
||||
}
|
||||
let short_args = vec!("-t".to_string(), "20".to_string());
|
||||
match getopts(short_args.as_slice(), opts.as_slice()) {
|
||||
match getopts(&short_args, &opts) {
|
||||
Ok(ref m) => {
|
||||
assert!((m.opt_present("test")));
|
||||
assert_eq!(m.opt_str("test").unwrap(), "20");
|
||||
@ -1295,7 +1295,7 @@ mod tests {
|
||||
fn test_optmulti_missing() {
|
||||
let args = vec!("blah".to_string());
|
||||
let opts = vec!(optmulti("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert!(!m.opt_present("test"));
|
||||
@ -1309,13 +1309,13 @@ mod tests {
|
||||
fn test_optmulti_no_arg() {
|
||||
let long_args = vec!("--test".to_string());
|
||||
let opts = vec!(optmulti("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(long_args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&long_args, &opts);
|
||||
match rs {
|
||||
Err(ArgumentMissing(_)) => {},
|
||||
_ => panic!()
|
||||
}
|
||||
let short_args = vec!("-t".to_string());
|
||||
match getopts(short_args.as_slice(), opts.as_slice()) {
|
||||
match getopts(&short_args, &opts) {
|
||||
Err(ArgumentMissing(_)) => {},
|
||||
_ => panic!()
|
||||
}
|
||||
@ -1325,7 +1325,7 @@ mod tests {
|
||||
fn test_optmulti_multi() {
|
||||
let args = vec!("--test=20".to_string(), "-t".to_string(), "30".to_string());
|
||||
let opts = vec!(optmulti("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert!(m.opt_present("test"));
|
||||
@ -1344,13 +1344,13 @@ mod tests {
|
||||
fn test_unrecognized_option() {
|
||||
let long_args = vec!("--untest".to_string());
|
||||
let opts = vec!(optmulti("t", "test", "testing", "TEST"));
|
||||
let rs = getopts(long_args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&long_args, &opts);
|
||||
match rs {
|
||||
Err(UnrecognizedOption(_)) => {},
|
||||
_ => panic!()
|
||||
}
|
||||
let short_args = vec!("-u".to_string());
|
||||
match getopts(short_args.as_slice(), opts.as_slice()) {
|
||||
match getopts(&short_args, &opts) {
|
||||
Err(UnrecognizedOption(_)) => {},
|
||||
_ => panic!()
|
||||
}
|
||||
@ -1383,7 +1383,7 @@ mod tests {
|
||||
optmulti("m", "", "mmmmmm", "YUM"),
|
||||
optmulti("n", "", "nothing", "NOTHING"),
|
||||
optopt("", "notpresent", "nothing to see here", "NOPE"));
|
||||
let rs = getopts(args.as_slice(), opts.as_slice());
|
||||
let rs = getopts(&args, &opts);
|
||||
match rs {
|
||||
Ok(ref m) => {
|
||||
assert!(m.free[0] == "prog");
|
||||
@ -1412,8 +1412,7 @@ mod tests {
|
||||
optopt("f", "", "flag", "FLAG"));
|
||||
|
||||
let args_single = vec!("-e".to_string(), "foo".to_string());
|
||||
let matches_single = &match getopts(args_single.as_slice(),
|
||||
opts.as_slice()) {
|
||||
let matches_single = &match getopts(&args_single, &opts) {
|
||||
result::Result::Ok(m) => m,
|
||||
result::Result::Err(_) => panic!()
|
||||
};
|
||||
@ -1432,8 +1431,7 @@ mod tests {
|
||||
|
||||
let args_both = vec!("-e".to_string(), "foo".to_string(), "--encrypt".to_string(),
|
||||
"foo".to_string());
|
||||
let matches_both = &match getopts(args_both.as_slice(),
|
||||
opts.as_slice()) {
|
||||
let matches_both = &match getopts(&args_both, &opts) {
|
||||
result::Result::Ok(m) => m,
|
||||
result::Result::Err(_) => panic!()
|
||||
};
|
||||
@ -1458,7 +1456,7 @@ mod tests {
|
||||
let args = vec!("-Lfoo".to_string(), "-M.".to_string());
|
||||
let opts = vec!(optmulti("L", "", "library directory", "LIB"),
|
||||
optmulti("M", "", "something", "MMMM"));
|
||||
let matches = &match getopts(args.as_slice(), opts.as_slice()) {
|
||||
let matches = &match getopts(&args, &opts) {
|
||||
result::Result::Ok(m) => m,
|
||||
result::Result::Err(_) => panic!()
|
||||
};
|
||||
@ -1474,7 +1472,7 @@ mod tests {
|
||||
let args = vec!("-vvLverbose".to_string(), "-v".to_string() );
|
||||
let opts = vec!(optmulti("L", "", "library directory", "LIB"),
|
||||
optflagmulti("v", "verbose", "Verbose"));
|
||||
let matches = &match getopts(args.as_slice(), opts.as_slice()) {
|
||||
let matches = &match getopts(&args, &opts) {
|
||||
result::Result::Ok(m) => m,
|
||||
result::Result::Err(e) => panic!( "{}", e )
|
||||
};
|
||||
@ -1508,7 +1506,7 @@ mod tests {
|
||||
|
||||
let args = vec!("-a".to_string(), "--apple".to_string(), "-a".to_string());
|
||||
|
||||
let matches = getopts(args.as_slice(), opts.as_slice()).unwrap();
|
||||
let matches = getopts(&args, &opts).unwrap();
|
||||
assert_eq!(3, matches.opt_count("a"));
|
||||
assert_eq!(3, matches.opt_count("apple"));
|
||||
}
|
||||
@ -1535,7 +1533,7 @@ Options:
|
||||
-l VAL Desc
|
||||
";
|
||||
|
||||
let generated_usage = usage("Usage: fruits", optgroups.as_slice());
|
||||
let generated_usage = usage("Usage: fruits", &optgroups);
|
||||
|
||||
debug!("expected: <<{}>>", expected);
|
||||
debug!("generated: <<{}>>", generated_usage);
|
||||
@ -1562,7 +1560,7 @@ Options:
|
||||
wrapped..+..
|
||||
";
|
||||
|
||||
let usage = usage("Usage: fruits", optgroups.as_slice());
|
||||
let usage = usage("Usage: fruits", &optgroups);
|
||||
|
||||
debug!("expected: <<{}>>", expected);
|
||||
debug!("generated: <<{}>>", usage);
|
||||
@ -1588,7 +1586,7 @@ Options:
|
||||
some parts of Europe.
|
||||
";
|
||||
|
||||
let usage = usage("Usage: fruits", optgroups.as_slice());
|
||||
let usage = usage("Usage: fruits", &optgroups);
|
||||
|
||||
debug!("expected: <<{}>>", expected);
|
||||
debug!("generated: <<{}>>", usage);
|
||||
@ -1606,7 +1604,7 @@ Options:
|
||||
optmulti("l", "", "Desc", "VAL"));
|
||||
|
||||
let expected = "Usage: fruits -b VAL [-a VAL] [-k] [-p [VAL]] [-l VAL]..".to_string();
|
||||
let generated_usage = short_usage("fruits", optgroups.as_slice());
|
||||
let generated_usage = short_usage("fruits", &optgroups);
|
||||
|
||||
debug!("expected: <<{}>>", expected);
|
||||
debug!("generated: <<{}>>", generated_usage);
|
||||
|
@ -565,7 +565,7 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
|
||||
} else {
|
||||
let escaped = g.node_label(n).escape();
|
||||
try!(writeln(w, &[id.as_slice(),
|
||||
"[label=\"", escaped.as_slice(), "\"];"]));
|
||||
"[label=\"", &escaped, "\"];"]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -582,7 +582,7 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
|
||||
} else {
|
||||
try!(writeln(w, &[source_id.as_slice(),
|
||||
" -> ", target_id.as_slice(),
|
||||
"[label=\"", escaped_label.as_slice(), "\"];"]));
|
||||
"[label=\"", &escaped_label, "\"];"]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -746,7 +746,7 @@ mod tests {
|
||||
fn test_input(g: LabelledGraph) -> IoResult<String> {
|
||||
let mut writer = Vec::new();
|
||||
render(&g, &mut writer).unwrap();
|
||||
(&mut writer.as_slice()).read_to_string()
|
||||
(&mut &*writer).read_to_string()
|
||||
}
|
||||
|
||||
// All of the tests use raw-strings as the format for the expected outputs,
|
||||
@ -858,7 +858,7 @@ r#"digraph hasse_diagram {
|
||||
edge(1, 3, ";"), edge(2, 3, ";" )));
|
||||
|
||||
render(&g, &mut writer).unwrap();
|
||||
let r = (&mut writer.as_slice()).read_to_string();
|
||||
let r = (&mut &*writer).read_to_string();
|
||||
|
||||
assert_eq!(r.unwrap(),
|
||||
r#"digraph syntax_tree {
|
||||
|
@ -213,8 +213,8 @@ mod test {
|
||||
#[test]
|
||||
fn test_rng_rand_seeded() {
|
||||
let s = ::test::rng().gen_iter::<u32>().take(8).collect::<Vec<u32>>();
|
||||
let mut ra: ChaChaRng = SeedableRng::from_seed(s.as_slice());
|
||||
let mut rb: ChaChaRng = SeedableRng::from_seed(s.as_slice());
|
||||
let mut ra: ChaChaRng = SeedableRng::from_seed(&*s);
|
||||
let mut rb: ChaChaRng = SeedableRng::from_seed(&*s);
|
||||
assert!(order::equals(ra.gen_ascii_chars().take(100),
|
||||
rb.gen_ascii_chars().take(100)));
|
||||
}
|
||||
@ -231,10 +231,10 @@ mod test {
|
||||
#[test]
|
||||
fn test_rng_reseed() {
|
||||
let s = ::test::rng().gen_iter::<u32>().take(8).collect::<Vec<u32>>();
|
||||
let mut r: ChaChaRng = SeedableRng::from_seed(s.as_slice());
|
||||
let mut r: ChaChaRng = SeedableRng::from_seed(&*s);
|
||||
let string1: String = r.gen_ascii_chars().take(100).collect();
|
||||
|
||||
r.reseed(s.as_slice());
|
||||
r.reseed(&s);
|
||||
|
||||
let string2: String = r.gen_ascii_chars().take(100).collect();
|
||||
assert_eq!(string1, string2);
|
||||
|
@ -300,7 +300,7 @@ mod tests {
|
||||
macro_rules! t {
|
||||
($items:expr, $expected:expr) => {{
|
||||
let mut items = $items;
|
||||
let wc = WeightedChoice::new(items.as_mut_slice());
|
||||
let wc = WeightedChoice::new(&mut items);
|
||||
let expected = $expected;
|
||||
|
||||
let mut rng = CountingRng { i: 0 };
|
||||
|
@ -514,16 +514,16 @@ mod test {
|
||||
#[test]
|
||||
fn test_rng_32_rand_seeded() {
|
||||
let s = ::test::rng().gen_iter::<u32>().take(256).collect::<Vec<u32>>();
|
||||
let mut ra: IsaacRng = SeedableRng::from_seed(s.as_slice());
|
||||
let mut rb: IsaacRng = SeedableRng::from_seed(s.as_slice());
|
||||
let mut ra: IsaacRng = SeedableRng::from_seed(&*s);
|
||||
let mut rb: IsaacRng = SeedableRng::from_seed(&*s);
|
||||
assert!(order::equals(ra.gen_ascii_chars().take(100),
|
||||
rb.gen_ascii_chars().take(100)));
|
||||
}
|
||||
#[test]
|
||||
fn test_rng_64_rand_seeded() {
|
||||
let s = ::test::rng().gen_iter::<u64>().take(256).collect::<Vec<u64>>();
|
||||
let mut ra: Isaac64Rng = SeedableRng::from_seed(s.as_slice());
|
||||
let mut rb: Isaac64Rng = SeedableRng::from_seed(s.as_slice());
|
||||
let mut ra: Isaac64Rng = SeedableRng::from_seed(&*s);
|
||||
let mut rb: Isaac64Rng = SeedableRng::from_seed(&*s);
|
||||
assert!(order::equals(ra.gen_ascii_chars().take(100),
|
||||
rb.gen_ascii_chars().take(100)));
|
||||
}
|
||||
@ -548,10 +548,10 @@ mod test {
|
||||
#[test]
|
||||
fn test_rng_32_reseed() {
|
||||
let s = ::test::rng().gen_iter::<u32>().take(256).collect::<Vec<u32>>();
|
||||
let mut r: IsaacRng = SeedableRng::from_seed(s.as_slice());
|
||||
let mut r: IsaacRng = SeedableRng::from_seed(&*s);
|
||||
let string1: String = r.gen_ascii_chars().take(100).collect();
|
||||
|
||||
r.reseed(s.as_slice());
|
||||
r.reseed(&s);
|
||||
|
||||
let string2: String = r.gen_ascii_chars().take(100).collect();
|
||||
assert_eq!(string1, string2);
|
||||
@ -559,10 +559,10 @@ mod test {
|
||||
#[test]
|
||||
fn test_rng_64_reseed() {
|
||||
let s = ::test::rng().gen_iter::<u64>().take(256).collect::<Vec<u64>>();
|
||||
let mut r: Isaac64Rng = SeedableRng::from_seed(s.as_slice());
|
||||
let mut r: Isaac64Rng = SeedableRng::from_seed(&*s);
|
||||
let string1: String = r.gen_ascii_chars().take(100).collect();
|
||||
|
||||
r.reseed(s.as_slice());
|
||||
r.reseed(&s);
|
||||
|
||||
let string2: String = r.gen_ascii_chars().take(100).collect();
|
||||
assert_eq!(string1, string2);
|
||||
|
@ -504,6 +504,7 @@ mod std {
|
||||
pub use core::marker;
|
||||
// for-loops
|
||||
pub use core::iter;
|
||||
pub use core::ops; // slicing syntax
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -216,7 +216,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_rng_fill_bytes() {
|
||||
let mut v = repeat(0u8).take(FILL_BYTES_V_LEN).collect::<Vec<_>>();
|
||||
::test::rng().fill_bytes(v.as_mut_slice());
|
||||
::test::rng().fill_bytes(&mut v);
|
||||
|
||||
// Sanity test: if we've gotten here, `fill_bytes` has not infinitely
|
||||
// recursed.
|
||||
|
@ -71,7 +71,7 @@ impl SeekableMemWriter {
|
||||
/// No method is exposed for acquiring a mutable reference to the buffer
|
||||
/// because it could corrupt the state of this `MemWriter`.
|
||||
#[inline]
|
||||
pub fn get_ref<'a>(&'a self) -> &'a [u8] { self.buf.as_slice() }
|
||||
pub fn get_ref<'a>(&'a self) -> &'a [u8] { &self.buf }
|
||||
|
||||
/// Unwraps this `SeekableMemWriter`, returning the underlying buffer
|
||||
#[inline]
|
||||
@ -190,7 +190,7 @@ mod tests {
|
||||
b.iter(|| {
|
||||
let mut wr = SeekableMemWriter::new();
|
||||
for _ in 0..times {
|
||||
wr.write(src.as_slice()).unwrap();
|
||||
wr.write(&src).unwrap();
|
||||
}
|
||||
|
||||
let v = wr.unwrap();
|
||||
|
@ -1194,7 +1194,7 @@ mod bench {
|
||||
b.iter(|| {
|
||||
let mut i = 0;
|
||||
while i < data.len() {
|
||||
sum += reader::vuint_at(data.as_slice(), i).unwrap().val;
|
||||
sum += reader::vuint_at(&data, i).unwrap().val;
|
||||
i += 4;
|
||||
}
|
||||
});
|
||||
@ -1212,7 +1212,7 @@ mod bench {
|
||||
b.iter(|| {
|
||||
let mut i = 1;
|
||||
while i < data.len() {
|
||||
sum += reader::vuint_at(data.as_slice(), i).unwrap().val;
|
||||
sum += reader::vuint_at(&data, i).unwrap().val;
|
||||
i += 4;
|
||||
}
|
||||
});
|
||||
@ -1231,7 +1231,7 @@ mod bench {
|
||||
b.iter(|| {
|
||||
let mut i = 0;
|
||||
while i < data.len() {
|
||||
sum += reader::vuint_at(data.as_slice(), i).unwrap().val;
|
||||
sum += reader::vuint_at(&data, i).unwrap().val;
|
||||
i += 4;
|
||||
}
|
||||
});
|
||||
@ -1250,7 +1250,7 @@ mod bench {
|
||||
b.iter(|| {
|
||||
let mut i = 1;
|
||||
while i < data.len() {
|
||||
sum += reader::vuint_at(data.as_slice(), i).unwrap().val;
|
||||
sum += reader::vuint_at(&data, i).unwrap().val;
|
||||
i += 4;
|
||||
}
|
||||
});
|
||||
|
@ -1082,12 +1082,12 @@ impl NonUpperCaseGlobals {
|
||||
.map(|c| c.to_uppercase()).collect();
|
||||
if uc != s.get() {
|
||||
cx.span_lint(NON_UPPER_CASE_GLOBALS, span,
|
||||
format!("{} `{}` should have an upper case name such as `{}`",
|
||||
sort, s, uc).as_slice());
|
||||
&format!("{} `{}` should have an upper case name such as `{}`",
|
||||
sort, s, uc));
|
||||
} else {
|
||||
cx.span_lint(NON_UPPER_CASE_GLOBALS, span,
|
||||
format!("{} `{}` should have an upper case name",
|
||||
sort, s).as_slice());
|
||||
&format!("{} `{}` should have an upper case name",
|
||||
sort, s));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2084,11 +2084,11 @@ impl LintPass for PrivateNoMangleFns {
|
||||
fn check_item(&mut self, cx: &Context, it: &ast::Item) {
|
||||
match it.node {
|
||||
ast::ItemFn(..) => {
|
||||
if attr::contains_name(it.attrs.as_slice(), "no_mangle") &&
|
||||
if attr::contains_name(&it.attrs, "no_mangle") &&
|
||||
!cx.exported_items.contains(&it.id) {
|
||||
let msg = format!("function {} is marked #[no_mangle], but not exported",
|
||||
it.ident);
|
||||
cx.span_lint(PRIVATE_NO_MANGLE_FNS, it.span, msg.as_slice());
|
||||
cx.span_lint(PRIVATE_NO_MANGLE_FNS, it.span, &msg);
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
|
@ -509,8 +509,8 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
|
||||
.collect(),
|
||||
None => {
|
||||
self.span_lint(builtin::UNKNOWN_LINTS, span,
|
||||
format!("unknown `{}` attribute: `{}`",
|
||||
level.as_str(), lint_name).as_slice());
|
||||
&format!("unknown `{}` attribute: `{}`",
|
||||
level.as_str(), lint_name));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -797,8 +797,8 @@ pub fn check_crate(tcx: &ty::ctxt,
|
||||
for (id, v) in &*tcx.sess.lints.borrow() {
|
||||
for &(lint, span, ref msg) in v {
|
||||
tcx.sess.span_bug(span,
|
||||
format!("unprocessed lint {} at {}: {}",
|
||||
lint.as_str(), tcx.map.node_to_string(*id), *msg).as_slice())
|
||||
&format!("unprocessed lint {} at {}: {}",
|
||||
lint.as_str(), tcx.map.node_to_string(*id), *msg))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec<ast_map::PathElem>
|
||||
// FIXME #1920: This path is not always correct if the crate is not linked
|
||||
// into the root namespace.
|
||||
let mut r = vec![ast_map::PathMod(token::intern(&cdata.name[]))];
|
||||
r.push_all(path.as_slice());
|
||||
r.push_all(&path);
|
||||
r
|
||||
}
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id));
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_path(rbml_w, path);
|
||||
encode_attributes(rbml_w, item.attrs.as_slice());
|
||||
encode_attributes(rbml_w, &item.attrs);
|
||||
encode_inlined_item(ecx, rbml_w, IIItemRef(item));
|
||||
encode_visibility(rbml_w, vis);
|
||||
encode_stability(rbml_w, stab);
|
||||
@ -1307,7 +1307,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
let trait_def = ty::lookup_trait_def(tcx, def_id);
|
||||
encode_unsafety(rbml_w, trait_def.unsafety);
|
||||
encode_paren_sugar(rbml_w, trait_def.paren_sugar);
|
||||
encode_associated_type_names(rbml_w, trait_def.associated_type_names.as_slice());
|
||||
encode_associated_type_names(rbml_w, &trait_def.associated_type_names);
|
||||
encode_generics(rbml_w, ecx, &trait_def.generics, tag_item_generics);
|
||||
encode_trait_ref(rbml_w, ecx, &*trait_def.trait_ref, tag_item_trait_ref);
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
|
@ -394,8 +394,8 @@ impl<'a> Context<'a> {
|
||||
file.ends_with(".rlib") {
|
||||
(&file[(rlib_prefix.len()) .. (file.len() - ".rlib".len())],
|
||||
true)
|
||||
} else if file.starts_with(dylib_prefix.as_slice()) &&
|
||||
file.ends_with(dypair.1.as_slice()) {
|
||||
} else if file.starts_with(&dylib_prefix) &&
|
||||
file.ends_with(&dypair.1) {
|
||||
(&file[(dylib_prefix.len()) .. (file.len() - dypair.1.len())],
|
||||
false)
|
||||
} else {
|
||||
|
@ -555,7 +555,7 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
|
||||
'P' => {
|
||||
assert_eq!(next(st), '[');
|
||||
let trait_ref = parse_trait_ref_(st, conv);
|
||||
let name = token::intern(parse_str(st, ']').as_slice());
|
||||
let name = token::intern(&parse_str(st, ']'));
|
||||
return ty::mk_projection(tcx, trait_ref, name);
|
||||
}
|
||||
'e' => {
|
||||
@ -781,7 +781,7 @@ fn parse_projection_predicate_<'a,'tcx, F>(
|
||||
ty::ProjectionPredicate {
|
||||
projection_ty: ty::ProjectionTy {
|
||||
trait_ref: parse_trait_ref_(st, conv),
|
||||
item_name: token::str_to_ident(parse_str(st, '|').as_slice()).name,
|
||||
item_name: token::str_to_ident(&parse_str(st, '|')).name,
|
||||
},
|
||||
ty: parse_ty_(st, conv),
|
||||
}
|
||||
|
@ -1185,7 +1185,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
|
||||
rbml_w.tag(c::tag_table_freevars, |rbml_w| {
|
||||
rbml_w.id(id);
|
||||
rbml_w.tag(c::tag_table_val, |rbml_w| {
|
||||
rbml_w.emit_from_vec(fv.as_slice(), |rbml_w, fv_entry| {
|
||||
rbml_w.emit_from_vec(fv, |rbml_w, fv_entry| {
|
||||
Ok(encode_freevar_entry(rbml_w, fv_entry))
|
||||
});
|
||||
})
|
||||
|
@ -310,7 +310,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
Entry => on_entry,
|
||||
Exit => {
|
||||
let mut t = on_entry.to_vec();
|
||||
self.apply_gen_kill(cfgidx, t.as_mut_slice());
|
||||
self.apply_gen_kill(cfgidx, &mut t);
|
||||
temp_bits = t;
|
||||
&temp_bits[]
|
||||
}
|
||||
@ -405,7 +405,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
Some(cfg_idx) => {
|
||||
let (start, end) = self.compute_id_range(cfg_idx);
|
||||
let kills = &self.kills[start.. end];
|
||||
if bitwise(orig_kills.as_mut_slice(), kills, &Union) {
|
||||
if bitwise(&mut orig_kills, kills, &Union) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@ -450,8 +450,8 @@ impl<'a, 'tcx, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, 'tcx, O> {
|
||||
let mut temp: Vec<_> = repeat(0).take(words_per_id).collect();
|
||||
while propcx.changed {
|
||||
propcx.changed = false;
|
||||
propcx.reset(temp.as_mut_slice());
|
||||
propcx.walk_cfg(cfg, temp.as_mut_slice());
|
||||
propcx.reset(&mut temp);
|
||||
propcx.walk_cfg(cfg, &mut temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
|
||||
let def_map = &self.tcx.def_map;
|
||||
match pat.node {
|
||||
ast::PatStruct(_, ref fields, _) => {
|
||||
self.handle_field_pattern_match(pat, fields.as_slice());
|
||||
self.handle_field_pattern_match(pat, fields);
|
||||
}
|
||||
_ if pat_util::pat_is_const(def_map, pat) => {
|
||||
// it might be the only use of a const
|
||||
@ -313,7 +313,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
|
||||
if attr::contains_name(attrs.as_slice(), "lang") {
|
||||
if attr::contains_name(attrs, "lang") {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -347,7 +347,7 @@ struct LifeSeeder {
|
||||
|
||||
impl<'v> Visitor<'v> for LifeSeeder {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
let allow_dead_code = has_allow_dead_code_or_lang_attr(item.attrs.as_slice());
|
||||
let allow_dead_code = has_allow_dead_code_or_lang_attr(&item.attrs);
|
||||
if allow_dead_code {
|
||||
self.worklist.push(item.id);
|
||||
}
|
||||
@ -376,7 +376,7 @@ impl<'v> Visitor<'v> for LifeSeeder {
|
||||
// Check for method here because methods are not ast::Item
|
||||
match fk {
|
||||
visit::FkMethod(_, _, method) => {
|
||||
if has_allow_dead_code_or_lang_attr(method.attrs.as_slice()) {
|
||||
if has_allow_dead_code_or_lang_attr(&method.attrs) {
|
||||
self.worklist.push(id);
|
||||
}
|
||||
}
|
||||
@ -467,12 +467,12 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||
is_named
|
||||
&& !self.symbol_is_live(node.id, None)
|
||||
&& !is_marker_field
|
||||
&& !has_allow_dead_code_or_lang_attr(node.attrs.as_slice())
|
||||
&& !has_allow_dead_code_or_lang_attr(&node.attrs)
|
||||
}
|
||||
|
||||
fn should_warn_about_variant(&mut self, variant: &ast::Variant_) -> bool {
|
||||
!self.symbol_is_live(variant.id, None)
|
||||
&& !has_allow_dead_code_or_lang_attr(variant.attrs.as_slice())
|
||||
&& !has_allow_dead_code_or_lang_attr(&variant.attrs)
|
||||
}
|
||||
|
||||
// id := node id of an item's definition.
|
||||
|
@ -56,7 +56,7 @@ pub fn find_entry_point(session: &Session, ast_map: &ast_map::Map) {
|
||||
}
|
||||
|
||||
// If the user wants no main function at all, then stop here.
|
||||
if attr::contains_name(ast_map.krate().attrs.as_slice(), "no_main") {
|
||||
if attr::contains_name(&ast_map.krate().attrs, "no_main") {
|
||||
session.entry_type.set(Some(config::EntryNone));
|
||||
return
|
||||
}
|
||||
@ -96,7 +96,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext) {
|
||||
});
|
||||
}
|
||||
|
||||
if attr::contains_name(item.attrs.as_slice(), "main") {
|
||||
if attr::contains_name(&item.attrs, "main") {
|
||||
if ctxt.attr_main_fn.is_none() {
|
||||
ctxt.attr_main_fn = Some((item.id, item.span));
|
||||
} else {
|
||||
@ -105,7 +105,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext) {
|
||||
}
|
||||
}
|
||||
|
||||
if attr::contains_name(item.attrs.as_slice(), "start") {
|
||||
if attr::contains_name(&item.attrs, "start") {
|
||||
if ctxt.start_fn.is_none() {
|
||||
ctxt.start_fn = Some((item.id, item.span));
|
||||
} else {
|
||||
|
@ -639,8 +639,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
||||
None => {
|
||||
self.tcx().sess.span_bug(
|
||||
callee.span,
|
||||
format!("unexpected callee type {}",
|
||||
callee_ty.repr(self.tcx())).as_slice())
|
||||
&format!("unexpected callee type {}", callee_ty.repr(self.tcx())))
|
||||
}
|
||||
};
|
||||
match overloaded_call_type {
|
||||
@ -1150,7 +1149,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
||||
let msg = format!("Pattern has unexpected type: {:?} and type {}",
|
||||
def,
|
||||
cmt_pat.ty.repr(tcx));
|
||||
tcx.sess.span_bug(pat.span, msg.as_slice())
|
||||
tcx.sess.span_bug(pat.span, &msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,14 +112,12 @@ impl<N,E> Graph<N,E> {
|
||||
|
||||
#[inline]
|
||||
pub fn all_nodes<'a>(&'a self) -> &'a [Node<N>] {
|
||||
let nodes: &'a [Node<N>] = self.nodes.as_slice();
|
||||
nodes
|
||||
&self.nodes
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn all_edges<'a>(&'a self) -> &'a [Edge<E>] {
|
||||
let edges: &'a [Edge<E>] = self.edges.as_slice();
|
||||
edges
|
||||
&self.edges
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -208,8 +208,8 @@ pub trait Combine<'tcx> : Sized {
|
||||
}
|
||||
|
||||
let inputs = try!(argvecs(self,
|
||||
a.inputs.as_slice(),
|
||||
b.inputs.as_slice()));
|
||||
&a.inputs,
|
||||
&b.inputs));
|
||||
|
||||
let output = try!(match (a.output, b.output) {
|
||||
(ty::FnConverging(a_ty), ty::FnConverging(b_ty)) =>
|
||||
|
@ -1707,7 +1707,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
|
||||
Some(node) => match node {
|
||||
ast_map::NodeItem(item) => match item.node {
|
||||
ast::ItemImpl(_, _, ref gen, _, _, _) => {
|
||||
taken.push_all(gen.lifetimes.as_slice());
|
||||
taken.push_all(&gen.lifetimes);
|
||||
}
|
||||
_ => ()
|
||||
},
|
||||
|
@ -127,10 +127,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
|
||||
ty::ty_infer(ty::FreshIntTy(c)) => {
|
||||
if c >= self.freshen_count {
|
||||
self.tcx().sess.bug(
|
||||
format!("Encountered a freshend type with id {} \
|
||||
but our counter is only at {}",
|
||||
c,
|
||||
self.freshen_count).as_slice());
|
||||
&format!("Encountered a freshend type with id {} \
|
||||
but our counter is only at {}",
|
||||
c,
|
||||
self.freshen_count));
|
||||
}
|
||||
t
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
|
||||
self.tcx(),
|
||||
&result0,
|
||||
|r, debruijn| generalize_region(self.infcx(), span, snapshot, debruijn,
|
||||
new_vars.as_slice(), &a_map, r));
|
||||
&new_vars, &a_map, r));
|
||||
|
||||
debug!("lub({},{}) = {}",
|
||||
a.repr(self.tcx()),
|
||||
@ -227,8 +227,8 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
|
||||
self.tcx(),
|
||||
&result0,
|
||||
|r, debruijn| generalize_region(self.infcx(), span, snapshot, debruijn,
|
||||
new_vars.as_slice(),
|
||||
&a_map, a_vars.as_slice(), b_vars.as_slice(),
|
||||
&new_vars,
|
||||
&a_map, &a_vars, &b_vars,
|
||||
r));
|
||||
|
||||
debug!("glb({},{}) = {}",
|
||||
|
@ -71,7 +71,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
|
||||
|
||||
let output_path = {
|
||||
let output_template = match requested_output {
|
||||
Some(ref s) if s.as_slice() == "help" => {
|
||||
Some(ref s) if &**s == "help" => {
|
||||
static PRINTED_YET: AtomicBool = ATOMIC_BOOL_INIT;
|
||||
if !PRINTED_YET.load(Ordering::SeqCst) {
|
||||
print_help_message();
|
||||
@ -92,7 +92,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
|
||||
let mut new_str = String::new();
|
||||
for c in output_template.chars() {
|
||||
if c == '%' {
|
||||
new_str.push_str(subject_node.to_string().as_slice());
|
||||
new_str.push_str(&subject_node.to_string());
|
||||
} else {
|
||||
new_str.push(c);
|
||||
}
|
||||
@ -104,11 +104,11 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
|
||||
};
|
||||
|
||||
let constraints = &*region_vars.constraints.borrow();
|
||||
match dump_region_constraints_to(tcx, constraints, output_path.as_slice()) {
|
||||
match dump_region_constraints_to(tcx, constraints, &output_path) {
|
||||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
let msg = format!("io error dumping region constraints: {}", e);
|
||||
region_vars.tcx.sess.err(msg.as_slice())
|
||||
region_vars.tcx.sess.err(&msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -157,7 +157,7 @@ impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> {
|
||||
|
||||
impl<'a, 'tcx> dot::Labeller<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> {
|
||||
fn graph_id(&self) -> dot::Id {
|
||||
dot::Id::new(self.graph_name.as_slice()).ok().unwrap()
|
||||
dot::Id::new(&*self.graph_name).ok().unwrap()
|
||||
}
|
||||
fn node_id(&self, n: &Node) -> dot::Id {
|
||||
dot::Id::new(format!("node_{}", self.node_ids.get(n).unwrap())).ok().unwrap()
|
||||
|
@ -973,8 +973,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||
debug!("----() End constraint listing {:?}---", self.dump_constraints());
|
||||
graphviz::maybe_print_constraints_for(self, subject);
|
||||
|
||||
self.expansion(var_data.as_mut_slice());
|
||||
self.contraction(var_data.as_mut_slice());
|
||||
self.expansion(&mut var_data);
|
||||
self.contraction(&mut var_data);
|
||||
let values =
|
||||
self.extract_values_and_collect_conflicts(&var_data[],
|
||||
errors);
|
||||
@ -1303,12 +1303,12 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||
match var_data[idx].classification {
|
||||
Expanding => {
|
||||
self.collect_error_for_expanding_node(
|
||||
graph, var_data, dup_vec.as_mut_slice(),
|
||||
graph, var_data, &mut dup_vec,
|
||||
node_vid, errors);
|
||||
}
|
||||
Contracting => {
|
||||
self.collect_error_for_contracting_node(
|
||||
graph, var_data, dup_vec.as_mut_slice(),
|
||||
graph, var_data, &mut dup_vec,
|
||||
node_vid, errors);
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ struct LanguageItemCollector<'a> {
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for LanguageItemCollector<'a> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
match extract(item.attrs.as_slice()) {
|
||||
match extract(&item.attrs) {
|
||||
Some(value) => {
|
||||
let item_index = self.item_refs.get(value.get()).map(|x| *x);
|
||||
|
||||
|
@ -456,13 +456,13 @@ impl<'a> LifetimeContext<'a> {
|
||||
if let Some((_, lifetime_def)) = search_lifetimes(lifetimes, lifetime) {
|
||||
self.sess.span_warn(
|
||||
lifetime.span,
|
||||
format!("lifetime name `{}` shadows another \
|
||||
lifetime name that is already in scope",
|
||||
token::get_name(lifetime.name)).as_slice());
|
||||
&format!("lifetime name `{}` shadows another \
|
||||
lifetime name that is already in scope",
|
||||
token::get_name(lifetime.name)));
|
||||
self.sess.span_note(
|
||||
lifetime_def.span,
|
||||
format!("shadowed lifetime `{}` declared here",
|
||||
token::get_name(lifetime.name)).as_slice());
|
||||
&format!("shadowed lifetime `{}` declared here",
|
||||
token::get_name(lifetime.name)));
|
||||
self.sess.span_note(
|
||||
lifetime.span,
|
||||
"shadowed lifetimes are deprecated \
|
||||
|
@ -57,7 +57,7 @@ impl<'a> Annotator<'a> {
|
||||
attrs: &Vec<Attribute>, item_sp: Span, f: F, required: bool) where
|
||||
F: FnOnce(&mut Annotator),
|
||||
{
|
||||
match attr::find_stability(self.sess.diagnostic(), attrs.as_slice(), item_sp) {
|
||||
match attr::find_stability(self.sess.diagnostic(), attrs, item_sp) {
|
||||
Some(stab) => {
|
||||
self.index.local.insert(id, stab.clone());
|
||||
|
||||
|
@ -406,7 +406,7 @@ impl<T> VecPerParamSpace<T> {
|
||||
}
|
||||
|
||||
pub fn as_slice(&self) -> &[T] {
|
||||
self.content.as_slice()
|
||||
&self.content
|
||||
}
|
||||
|
||||
pub fn into_vec(self) -> Vec<T> {
|
||||
|
@ -24,7 +24,7 @@ reference to a trait. So, for example, if there is a generic function like:
|
||||
|
||||
and then a call to that function:
|
||||
|
||||
let v: Vec<int> = clone_slice([1, 2, 3].as_slice())
|
||||
let v: Vec<int> = clone_slice([1, 2, 3])
|
||||
|
||||
it is the job of trait resolution to figure out (in which case)
|
||||
whether there exists an impl of `int : Clone`
|
||||
|
@ -93,7 +93,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
Piece::String(s) => Some(s),
|
||||
Piece::NextArgument(a) => match a.position {
|
||||
Position::ArgumentNamed(s) => match generic_map.get(s) {
|
||||
Some(val) => Some(val.as_slice()),
|
||||
Some(val) => Some(val),
|
||||
None => {
|
||||
span_err!(infcx.tcx.sess, err_sp, E0272,
|
||||
"the #[rustc_on_unimplemented] \
|
||||
@ -181,7 +181,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
obligation.cause.span);
|
||||
if let Some(s) = custom_note {
|
||||
infcx.tcx.sess.span_note(obligation.cause.span,
|
||||
s.as_slice());
|
||||
&s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -289,12 +289,12 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
// Ambiguity. Coherence should have reported an error.
|
||||
infcx.tcx.sess.span_bug(
|
||||
obligation.cause.span,
|
||||
format!(
|
||||
&format!(
|
||||
"coherence failed to report ambiguity: \
|
||||
cannot locate the impl of the trait `{}` for \
|
||||
the type `{}`",
|
||||
trait_ref.user_string(infcx.tcx),
|
||||
self_ty.user_string(infcx.tcx)).as_slice());
|
||||
self_ty.user_string(infcx.tcx)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -330,14 +330,14 @@ fn note_obligation_cause_code<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
let item_name = ty::item_path_str(tcx, item_def_id);
|
||||
tcx.sess.span_note(
|
||||
cause_span,
|
||||
format!("required by `{}`", item_name).as_slice());
|
||||
&format!("required by `{}`", item_name));
|
||||
}
|
||||
ObligationCauseCode::ObjectCastObligation(object_ty) => {
|
||||
tcx.sess.span_note(
|
||||
cause_span,
|
||||
format!(
|
||||
&format!(
|
||||
"required for the cast to the object type `{}`",
|
||||
infcx.ty_to_string(object_ty)).as_slice());
|
||||
infcx.ty_to_string(object_ty)));
|
||||
}
|
||||
ObligationCauseCode::RepeatVec => {
|
||||
tcx.sess.span_note(
|
||||
|
@ -180,7 +180,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
||||
{
|
||||
match self.region_obligations.get(&body_id) {
|
||||
None => Default::default(),
|
||||
Some(vec) => vec.as_slice(),
|
||||
Some(vec) => vec,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -605,8 +605,8 @@ fn assemble_candidates_from_object_type<'cx,'tcx>(
|
||||
_ => {
|
||||
selcx.tcx().sess.span_bug(
|
||||
obligation.cause.span,
|
||||
format!("assemble_candidates_from_object_type called with non-object: {}",
|
||||
object_ty.repr(selcx.tcx())).as_slice());
|
||||
&format!("assemble_candidates_from_object_type called with non-object: {}",
|
||||
object_ty.repr(selcx.tcx())));
|
||||
}
|
||||
};
|
||||
let projection_bounds = data.projection_bounds_with_self_ty(selcx.tcx(), object_ty);
|
||||
@ -693,8 +693,8 @@ fn assemble_candidates_from_impls<'cx,'tcx>(
|
||||
// These traits have no associated types.
|
||||
selcx.tcx().sess.span_bug(
|
||||
obligation.cause.span,
|
||||
format!("Cannot project an associated type from `{}`",
|
||||
vtable.repr(selcx.tcx())).as_slice());
|
||||
&format!("Cannot project an associated type from `{}`",
|
||||
vtable.repr(selcx.tcx())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -813,10 +813,10 @@ fn confirm_param_env_candidate<'cx,'tcx>(
|
||||
Err(e) => {
|
||||
selcx.tcx().sess.span_bug(
|
||||
obligation.cause.span,
|
||||
format!("Failed to unify `{}` and `{}` in projection: {}",
|
||||
obligation.repr(selcx.tcx()),
|
||||
projection.repr(selcx.tcx()),
|
||||
ty::type_err_to_str(selcx.tcx(), &e)).as_slice());
|
||||
&format!("Failed to unify `{}` and `{}` in projection: {}",
|
||||
obligation.repr(selcx.tcx()),
|
||||
projection.repr(selcx.tcx()),
|
||||
ty::type_err_to_str(selcx.tcx(), &e)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -933,9 +933,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
_ => {
|
||||
self.tcx().sess.span_bug(
|
||||
obligation.cause.span,
|
||||
format!("match_projection_obligation_against_bounds_from_trait() called \
|
||||
but self-ty not a projection: {}",
|
||||
skol_trait_predicate.trait_ref.self_ty().repr(self.tcx())).as_slice());
|
||||
&format!("match_projection_obligation_against_bounds_from_trait() called \
|
||||
but self-ty not a projection: {}",
|
||||
skol_trait_predicate.trait_ref.self_ty().repr(self.tcx())));
|
||||
}
|
||||
};
|
||||
debug!("match_projection_obligation_against_bounds_from_trait: \
|
||||
@ -1787,9 +1787,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
Ok(obligations) => obligations,
|
||||
Err(()) => {
|
||||
self.tcx().sess.bug(
|
||||
format!("Where clause `{}` was applicable to `{}` but now is not",
|
||||
param.repr(self.tcx()),
|
||||
obligation.repr(self.tcx())).as_slice());
|
||||
&format!("Where clause `{}` was applicable to `{}` but now is not",
|
||||
param.repr(self.tcx()),
|
||||
obligation.repr(self.tcx())));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1953,9 +1953,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
Some(r) => r,
|
||||
None => {
|
||||
self.tcx().sess.span_bug(obligation.cause.span,
|
||||
format!("unable to upcast from {} to {}",
|
||||
poly_trait_ref.repr(self.tcx()),
|
||||
obligation_def_id.repr(self.tcx())).as_slice());
|
||||
&format!("unable to upcast from {} to {}",
|
||||
poly_trait_ref.repr(self.tcx()),
|
||||
obligation_def_id.repr(self.tcx())));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -279,7 +279,7 @@ pub fn trait_ref_for_builtin_bound<'tcx>(
|
||||
}))
|
||||
}
|
||||
Err(e) => {
|
||||
tcx.sess.err(e.as_slice());
|
||||
tcx.sess.err(&e);
|
||||
Err(ErrorReported)
|
||||
}
|
||||
}
|
||||
|
@ -2793,7 +2793,7 @@ pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>,
|
||||
bounds: ExistentialBounds<'tcx>)
|
||||
-> Ty<'tcx>
|
||||
{
|
||||
assert!(bound_list_is_sorted(bounds.projection_bounds.as_slice()));
|
||||
assert!(bound_list_is_sorted(&bounds.projection_bounds));
|
||||
|
||||
let inner = box TyTrait {
|
||||
principal: principal,
|
||||
@ -3406,8 +3406,8 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
||||
// FIXME(#14449): `borrowed_contents` below assumes `&mut` closure.
|
||||
let param_env = ty::empty_parameter_environment(cx);
|
||||
let upvars = closure_upvars(¶m_env, did, substs).unwrap();
|
||||
TypeContents::union(upvars.as_slice(),
|
||||
|f| tc_ty(cx, f.ty, cache))
|
||||
TypeContents::union(&upvars,
|
||||
|f| tc_ty(cx, &f.ty, cache))
|
||||
| borrowed_contents(*r, MutMutable)
|
||||
}
|
||||
|
||||
@ -3672,8 +3672,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
|
||||
ty_closure(..) => {
|
||||
// this check is run on type definitions, so we don't expect to see
|
||||
// inference by-products or closure types
|
||||
cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}",
|
||||
ty).as_slice())
|
||||
cx.sess.bug(&format!("requires check invoked on inapplicable type: {:?}", ty))
|
||||
}
|
||||
|
||||
ty_tup(ref ts) => {
|
||||
@ -3766,8 +3765,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
|
||||
ty_closure(..) => {
|
||||
// this check is run on type definitions, so we don't expect
|
||||
// to see closure types
|
||||
cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}",
|
||||
ty).as_slice())
|
||||
cx.sess.bug(&format!("requires check invoked on inapplicable type: {:?}", ty))
|
||||
}
|
||||
_ => Representable,
|
||||
}
|
||||
@ -6365,9 +6363,9 @@ pub fn construct_parameter_environment<'a,'tcx>(
|
||||
_ => {
|
||||
// All named regions are instantiated with free regions.
|
||||
tcx.sess.bug(
|
||||
format!("record_region_bounds: non free region: {} / {}",
|
||||
r_a.repr(tcx),
|
||||
r_b.repr(tcx)).as_slice());
|
||||
&format!("record_region_bounds: non free region: {} / {}",
|
||||
r_a.repr(tcx),
|
||||
r_b.repr(tcx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ impl<'tcx> TypeWalker<'tcx> {
|
||||
}
|
||||
ty::ty_trait(box ty::TyTrait { ref principal, ref bounds }) => {
|
||||
self.push_reversed(principal.substs().types.as_slice());
|
||||
self.push_reversed(bounds.projection_bounds.iter().map(|pred| {
|
||||
self.push_reversed(&bounds.projection_bounds.iter().map(|pred| {
|
||||
pred.0.ty
|
||||
}).collect::<Vec<_>>().as_slice());
|
||||
}).collect::<Vec<_>>());
|
||||
}
|
||||
ty::ty_enum(_, ref substs) |
|
||||
ty::ty_struct(_, ref substs) |
|
||||
@ -49,7 +49,7 @@ impl<'tcx> TypeWalker<'tcx> {
|
||||
self.push_reversed(substs.types.as_slice());
|
||||
}
|
||||
ty::ty_tup(ref ts) => {
|
||||
self.push_reversed(ts.as_slice());
|
||||
self.push_reversed(ts);
|
||||
}
|
||||
ty::ty_bare_fn(_, ref ft) => {
|
||||
self.push_sig_subtypes(&ft.sig);
|
||||
@ -62,7 +62,7 @@ impl<'tcx> TypeWalker<'tcx> {
|
||||
ty::FnConverging(output) => { self.stack.push(output); }
|
||||
ty::FnDiverging => { }
|
||||
}
|
||||
self.push_reversed(sig.0.inputs.as_slice());
|
||||
self.push_reversed(&sig.0.inputs);
|
||||
}
|
||||
|
||||
fn push_reversed(&mut self, tys: &[Ty<'tcx>]) {
|
||||
|
@ -85,8 +85,8 @@ fn verify(sess: &Session, items: &lang_items::LanguageItems) {
|
||||
|
||||
$(
|
||||
if missing.contains(&lang_items::$item) && items.$name().is_none() {
|
||||
sess.err(format!("language item required, but not found: `{}`",
|
||||
stringify!($name)).as_slice());
|
||||
sess.err(&format!("language item required, but not found: `{}`",
|
||||
stringify!($name)));
|
||||
|
||||
}
|
||||
)*
|
||||
@ -108,7 +108,7 @@ impl<'a> Context<'a> {
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for Context<'a> {
|
||||
fn visit_foreign_item(&mut self, i: &ast::ForeignItem) {
|
||||
match lang_items::extract(i.attrs.as_slice()) {
|
||||
match lang_items::extract(&i.attrs) {
|
||||
None => {}
|
||||
Some(lang_item) => self.register(lang_item.get(), i.span),
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ struct RegistrarFinder {
|
||||
impl<'v> Visitor<'v> for RegistrarFinder {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
if let ast::ItemFn(..) = item.node {
|
||||
if attr::contains_name(item.attrs.as_slice(),
|
||||
if attr::contains_name(&item.attrs,
|
||||
"plugin_registrar") {
|
||||
self.registrars.push((item.id, item.span));
|
||||
}
|
||||
|
@ -82,8 +82,8 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate,
|
||||
visit::walk_crate(&mut loader, krate);
|
||||
|
||||
if let Some(plugins) = addl_plugins {
|
||||
for plugin in &plugins {
|
||||
loader.load_plugin(CrateOrString::Str(plugin.as_slice()),
|
||||
for plugin in plugins {
|
||||
loader.load_plugin(CrateOrString::Str(&plugin),
|
||||
None, None, None)
|
||||
}
|
||||
}
|
||||
|
@ -638,7 +638,7 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
|
||||
let target = match Target::search(&opts.target_triple[]) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
sp.handler().fatal((format!("Error loading target specification: {}", e)).as_slice());
|
||||
sp.handler().fatal(&format!("Error loading target specification: {}", e));
|
||||
}
|
||||
};
|
||||
|
||||
@ -856,7 +856,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
let unparsed_output_types = matches.opt_strs("emit");
|
||||
for unparsed_output_type in &unparsed_output_types {
|
||||
for part in unparsed_output_type.split(',') {
|
||||
let output_type = match part.as_slice() {
|
||||
let output_type = match part {
|
||||
"asm" => OutputTypeAssembly,
|
||||
"llvm-ir" => OutputTypeLlvmAssembly,
|
||||
"llvm-bc" => OutputTypeBitcode,
|
||||
@ -897,9 +897,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
Some(2) => Default,
|
||||
Some(3) => Aggressive,
|
||||
Some(arg) => {
|
||||
early_error(format!("optimization level needs to be \
|
||||
between 0-3 (instead was `{}`)",
|
||||
arg).as_slice());
|
||||
early_error(&format!("optimization level needs to be \
|
||||
between 0-3 (instead was `{}`)",
|
||||
arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -916,9 +916,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
Some(1) => LimitedDebugInfo,
|
||||
Some(2) => FullDebugInfo,
|
||||
Some(arg) => {
|
||||
early_error(format!("debug info level needs to be between \
|
||||
0-2 (instead was `{}`)",
|
||||
arg).as_slice());
|
||||
early_error(&format!("debug info level needs to be between \
|
||||
0-2 (instead was `{}`)",
|
||||
arg));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -937,9 +937,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
"framework" => cstore::NativeFramework,
|
||||
"static" => cstore::NativeStatic,
|
||||
s => {
|
||||
early_error(format!("unknown library kind `{}`, expected \
|
||||
one of dylib, framework, or static",
|
||||
s).as_slice());
|
||||
early_error(&format!("unknown library kind `{}`, expected \
|
||||
one of dylib, framework, or static",
|
||||
s));
|
||||
}
|
||||
};
|
||||
return (name.to_string(), kind)
|
||||
@ -968,12 +968,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
let write_dependency_info = (output_types.contains(&OutputTypeDepInfo), None);
|
||||
|
||||
let prints = matches.opt_strs("print").into_iter().map(|s| {
|
||||
match s.as_slice() {
|
||||
match &*s {
|
||||
"crate-name" => PrintRequest::CrateName,
|
||||
"file-names" => PrintRequest::FileNames,
|
||||
"sysroot" => PrintRequest::Sysroot,
|
||||
req => {
|
||||
early_error(format!("unknown print request `{}`", req).as_slice())
|
||||
early_error(&format!("unknown print request `{}`", req))
|
||||
}
|
||||
}
|
||||
}).collect::<Vec<_>>();
|
||||
|
@ -332,7 +332,7 @@ pub fn build_session_(sopts: config::Options,
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
span_diagnostic.handler()
|
||||
.fatal((format!("Error loading host specification: {}", e)).as_slice());
|
||||
.fatal(&format!("Error loading host specification: {}", e));
|
||||
}
|
||||
};
|
||||
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
|
||||
|
@ -116,7 +116,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
|
||||
region::CodeExtent::Remainder(r) => {
|
||||
new_string = format!("block suffix following statement {}",
|
||||
r.first_statement_index);
|
||||
new_string.as_slice()
|
||||
&*new_string
|
||||
}
|
||||
};
|
||||
explain_span(cx, scope_decorated_tag, span)
|
||||
@ -263,7 +263,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
||||
match unsafety {
|
||||
ast::Unsafety::Normal => {}
|
||||
ast::Unsafety::Unsafe => {
|
||||
s.push_str(unsafety.to_string().as_slice());
|
||||
s.push_str(&unsafety.to_string());
|
||||
s.push(' ');
|
||||
}
|
||||
};
|
||||
@ -315,7 +315,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
||||
.iter()
|
||||
.map(|a| ty_to_string(cx, *a))
|
||||
.collect::<Vec<_>>();
|
||||
s.push_str(strs.connect(", ").as_slice());
|
||||
s.push_str(&strs.connect(", "));
|
||||
if sig.0.variadic {
|
||||
s.push_str(", ...");
|
||||
}
|
||||
@ -392,7 +392,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
||||
ty_enum(did, substs) | ty_struct(did, substs) => {
|
||||
let base = ty::item_path_str(cx, did);
|
||||
let generics = ty::lookup_item_type(cx, did).generics;
|
||||
parameterized(cx, base.as_slice(), substs, &generics, did, &[])
|
||||
parameterized(cx, &base, substs, &generics, did, &[])
|
||||
}
|
||||
ty_trait(ref data) => {
|
||||
data.user_string(cx)
|
||||
@ -643,7 +643,7 @@ impl<'tcx> UserString<'tcx> for TraitAndProjections<'tcx> {
|
||||
let base = ty::item_path_str(tcx, trait_ref.def_id);
|
||||
let trait_def = ty::lookup_trait_def(tcx, trait_ref.def_id);
|
||||
parameterized(tcx,
|
||||
base.as_slice(),
|
||||
&base,
|
||||
trait_ref.substs,
|
||||
&trait_def.generics,
|
||||
trait_ref.def_id,
|
||||
@ -780,7 +780,7 @@ impl<'tcx> Repr<'tcx> for ty::TraitRef<'tcx> {
|
||||
let trait_def = ty::lookup_trait_def(tcx, self.def_id);
|
||||
format!("TraitRef({}, {})",
|
||||
self.substs.self_ty().repr(tcx),
|
||||
parameterized(tcx, base.as_slice(), self.substs,
|
||||
parameterized(tcx, &base, self.substs,
|
||||
&trait_def.generics, self.def_id, &[]))
|
||||
}
|
||||
}
|
||||
@ -1235,7 +1235,7 @@ impl<'tcx> UserString<'tcx> for ty::TraitRef<'tcx> {
|
||||
fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
|
||||
let path_str = ty::item_path_str(tcx, self.def_id);
|
||||
let trait_def = ty::lookup_trait_def(tcx, self.def_id);
|
||||
parameterized(tcx, path_str.as_slice(), self.substs,
|
||||
parameterized(tcx, &path_str, self.substs,
|
||||
&trait_def.generics, self.def_id, &[])
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ pub trait Digest {
|
||||
/// newly allocated vec of bytes.
|
||||
fn result_bytes(&mut self) -> Vec<u8> {
|
||||
let mut buf: Vec<u8> = repeat(0u8).take((self.output_bits()+7)/8).collect();
|
||||
self.result(buf.as_mut_slice());
|
||||
self.result(&mut buf);
|
||||
buf
|
||||
}
|
||||
|
||||
@ -560,7 +560,7 @@ mod tests {
|
||||
// Test that it works when accepting the message all at once
|
||||
for t in tests {
|
||||
sh.reset();
|
||||
sh.input_str(t.input.as_slice());
|
||||
sh.input_str(&t.input);
|
||||
let out_str = sh.result_str();
|
||||
assert!(out_str == t.output_str);
|
||||
}
|
||||
@ -606,7 +606,7 @@ mod tests {
|
||||
|
||||
let mut sh = box Sha256::new();
|
||||
|
||||
test_hash(&mut *sh, tests.as_slice());
|
||||
test_hash(&mut *sh, &tests);
|
||||
}
|
||||
|
||||
/// Feed 1,000,000 'a's into the digest with varying input sizes and check that the result is
|
||||
@ -630,7 +630,7 @@ mod tests {
|
||||
let result_str = digest.result_str();
|
||||
let result_bytes = digest.result_bytes();
|
||||
|
||||
assert_eq!(expected, result_str.as_slice());
|
||||
assert_eq!(expected, result_str);
|
||||
|
||||
let expected_vec: Vec<u8> = expected.from_hex()
|
||||
.unwrap()
|
||||
|
@ -798,8 +798,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
}
|
||||
mc::AliasableClosure(id) => {
|
||||
self.tcx.sess.span_err(span,
|
||||
format!("{} in a captured outer \
|
||||
variable in an `Fn` closure", prefix).as_slice());
|
||||
&format!("{} in a captured outer \
|
||||
variable in an `Fn` closure", prefix));
|
||||
if let BorrowViolation(euv::ClosureCapture(_)) = kind {
|
||||
// The aliasability violation with closure captures can
|
||||
// happen for nested closures, so we know the enclosing
|
||||
|
@ -350,7 +350,7 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input)
|
||||
}
|
||||
|
||||
if let Some(ref s) = sess.opts.show_span {
|
||||
syntax::show_span::run(sess.diagnostic(), s.as_slice(), &krate);
|
||||
syntax::show_span::run(sess.diagnostic(), s, &krate);
|
||||
}
|
||||
|
||||
krate
|
||||
|
@ -93,7 +93,7 @@ pub mod driver;
|
||||
pub mod pretty;
|
||||
|
||||
pub fn run(args: Vec<String>) -> int {
|
||||
monitor(move || run_compiler(args.as_slice()));
|
||||
monitor(move || run_compiler(&args));
|
||||
0
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ fn run_compiler(args: &[String]) {
|
||||
let pretty = if sess.opts.debugging_opts.unstable_options {
|
||||
matches.opt_default("pretty", "normal").map(|a| {
|
||||
// stable pretty-print variants only
|
||||
pretty::parse_pretty(&sess, a.as_slice(), false)
|
||||
pretty::parse_pretty(&sess, &a, false)
|
||||
})
|
||||
} else {
|
||||
None
|
||||
@ -174,7 +174,7 @@ fn run_compiler(args: &[String]) {
|
||||
sess.unstable_options() {
|
||||
matches.opt_str("xpretty").map(|a| {
|
||||
// extended with unstable pretty-print variants
|
||||
pretty::parse_pretty(&sess, a.as_slice(), true)
|
||||
pretty::parse_pretty(&sess, &a, true)
|
||||
})
|
||||
} else {
|
||||
pretty
|
||||
@ -313,7 +313,7 @@ Additional help:
|
||||
-C help Print codegen options
|
||||
-W help Print 'lint' options and default settings
|
||||
-Z help Print internal options for debugging rustc{}\n",
|
||||
getopts::usage(message.as_slice(), groups.as_slice()),
|
||||
getopts::usage(&message, &groups),
|
||||
extra_help);
|
||||
}
|
||||
|
||||
@ -481,20 +481,20 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
|
||||
// unstable ones.
|
||||
let all_groups : Vec<getopts::OptGroup>
|
||||
= config::rustc_optgroups().into_iter().map(|x|x.opt_group).collect();
|
||||
match getopts::getopts(args.as_slice(), all_groups.as_slice()) {
|
||||
match getopts::getopts(&args, &all_groups) {
|
||||
Ok(m_unstable) => {
|
||||
let r = m_unstable.opt_strs("Z");
|
||||
let include_unstable_options = r.iter().any(|x| *x == "unstable-options");
|
||||
if include_unstable_options {
|
||||
m_unstable
|
||||
} else {
|
||||
early_error(f_stable_attempt.to_string().as_slice());
|
||||
early_error(&f_stable_attempt.to_string());
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
// ignore the error from the unstable attempt; just
|
||||
// pass the error we got from the first try.
|
||||
early_error(f_stable_attempt.to_string().as_slice());
|
||||
early_error(&f_stable_attempt.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -552,13 +552,13 @@ fn print_crate_info(sess: &Session,
|
||||
Some(input) => input,
|
||||
None => early_error("no input file provided"),
|
||||
};
|
||||
let attrs = attrs.as_ref().unwrap().as_slice();
|
||||
let attrs = attrs.as_ref().unwrap();
|
||||
let t_outputs = driver::build_output_filenames(input,
|
||||
odir,
|
||||
ofile,
|
||||
attrs,
|
||||
sess);
|
||||
let id = link::find_crate_name(Some(sess), attrs.as_slice(),
|
||||
let id = link::find_crate_name(Some(sess), attrs,
|
||||
input);
|
||||
if *req == PrintRequest::CrateName {
|
||||
println!("{}", id);
|
||||
@ -569,7 +569,7 @@ fn print_crate_info(sess: &Session,
|
||||
*sess.crate_metadata.borrow_mut() = metadata;
|
||||
for &style in &crate_types {
|
||||
let fname = link::filename_for_input(sess, style,
|
||||
id.as_slice(),
|
||||
&id,
|
||||
&t_outputs.with_extension(""));
|
||||
println!("{}", fname.filename_display());
|
||||
}
|
||||
|
@ -87,15 +87,15 @@ pub fn parse_pretty(sess: &Session,
|
||||
("flowgraph,unlabelled", true) => PpmFlowGraph(PpFlowGraphMode::UnlabelledEdges),
|
||||
_ => {
|
||||
if extended {
|
||||
sess.fatal(format!(
|
||||
sess.fatal(&format!(
|
||||
"argument to `xpretty` must be one of `normal`, \
|
||||
`expanded`, `flowgraph[,unlabelled]=<nodeid>`, `typed`, `identified`, \
|
||||
`expanded,identified`, or `everybody_loops`; got {}", name).as_slice());
|
||||
`expanded,identified`, or `everybody_loops`; got {}", name));
|
||||
} else {
|
||||
sess.fatal(format!(
|
||||
sess.fatal(&format!(
|
||||
"argument to `pretty` must be one of `normal`, \
|
||||
`expanded`, `typed`, `identified`, \
|
||||
or `expanded,identified`; got {}", name).as_slice());
|
||||
or `expanded,identified`; got {}", name));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -517,7 +517,7 @@ pub fn pretty_print_input(sess: Session,
|
||||
krate
|
||||
};
|
||||
|
||||
let id = link::find_crate_name(Some(&sess), krate.attrs.as_slice(), input);
|
||||
let id = link::find_crate_name(Some(&sess), &krate.attrs, input);
|
||||
|
||||
let is_expanded = needs_expansion(&ppm);
|
||||
let compute_ast_map = needs_ast_map(&ppm, &opt_uii);
|
||||
|
@ -56,7 +56,7 @@ fn remove_message(e: &mut ExpectErrorEmitter, msg: &str, lvl: Level) {
|
||||
}
|
||||
|
||||
debug!("Error: {}", msg);
|
||||
match e.messages.iter().position(|m| msg.contains(m.as_slice())) {
|
||||
match e.messages.iter().position(|m| msg.contains(m)) {
|
||||
Some(i) => {
|
||||
e.messages.remove(i);
|
||||
}
|
||||
|
@ -1726,7 +1726,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
in this module",
|
||||
namespace_name,
|
||||
token::get_name(name).get());
|
||||
span_err!(self.session, import_directive.span, E0251, "{}", msg.as_slice());
|
||||
span_err!(self.session, import_directive.span, E0251, "{}", msg);
|
||||
} else {
|
||||
let target = Target::new(containing_module.clone(),
|
||||
name_bindings.clone(),
|
||||
@ -3756,15 +3756,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
}
|
||||
Some(_) => {
|
||||
self.resolve_error(path.span,
|
||||
format!("`{}` is not an enum variant, struct or const",
|
||||
&format!("`{}` is not an enum variant, struct or const",
|
||||
token::get_ident(
|
||||
path.segments.last().unwrap().identifier)).as_slice());
|
||||
path.segments.last().unwrap().identifier)));
|
||||
}
|
||||
None => {
|
||||
self.resolve_error(path.span,
|
||||
format!("unresolved enum variant, struct or const `{}`",
|
||||
token::get_ident(
|
||||
path.segments.last().unwrap().identifier)).as_slice());
|
||||
&format!("unresolved enum variant, struct or const `{}`",
|
||||
token::get_ident(path.segments.last().unwrap().identifier)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4061,7 +4060,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
Some((span, msg)) => (span, msg),
|
||||
None => {
|
||||
let msg = format!("Use of undeclared type or module `{}`",
|
||||
self.names_to_string(module_path.as_slice()));
|
||||
self.names_to_string(&module_path));
|
||||
(path.span, msg)
|
||||
}
|
||||
};
|
||||
@ -4163,7 +4162,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
let search_result = match namespace {
|
||||
ValueNS => {
|
||||
let renamed = mtwt::resolve(ident);
|
||||
self.search_ribs(self.value_ribs.as_slice(), renamed, span)
|
||||
self.search_ribs(&self.value_ribs, renamed, span)
|
||||
}
|
||||
TypeNS => {
|
||||
let name = ident.name;
|
||||
@ -4424,15 +4423,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
Some((DefVariant(_, _, true), _)) => {
|
||||
let path_name = self.path_names_to_string(path);
|
||||
self.resolve_error(expr.span,
|
||||
format!("`{}` is a struct variant name, but \
|
||||
this expression \
|
||||
uses it like a function name",
|
||||
path_name).as_slice());
|
||||
&format!("`{}` is a struct variant name, but \
|
||||
this expression \
|
||||
uses it like a function name",
|
||||
path_name));
|
||||
|
||||
self.session.span_help(expr.span,
|
||||
format!("Did you mean to write: \
|
||||
`{} {{ /* fields */ }}`?",
|
||||
path_name).as_slice());
|
||||
&format!("Did you mean to write: \
|
||||
`{} {{ /* fields */ }}`?",
|
||||
path_name));
|
||||
}
|
||||
Some(def) => {
|
||||
// Write the result into the def map.
|
||||
@ -4452,15 +4451,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
Some((DefTy(struct_id, _), _))
|
||||
if self.structs.contains_key(&struct_id) => {
|
||||
self.resolve_error(expr.span,
|
||||
format!("`{}` is a structure name, but \
|
||||
this expression \
|
||||
uses it like a function name",
|
||||
path_name).as_slice());
|
||||
&format!("`{}` is a structure name, but \
|
||||
this expression \
|
||||
uses it like a function name",
|
||||
path_name));
|
||||
|
||||
self.session.span_help(expr.span,
|
||||
format!("Did you mean to write: \
|
||||
`{} {{ /* fields */ }}`?",
|
||||
path_name).as_slice());
|
||||
&format!("Did you mean to write: \
|
||||
`{} {{ /* fields */ }}`?",
|
||||
path_name));
|
||||
|
||||
}
|
||||
_ => {
|
||||
@ -4489,7 +4488,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
NoSuggestion => {
|
||||
// limit search to 5 to reduce the number
|
||||
// of stupid suggestions
|
||||
self.find_best_match_for_name(path_name.as_slice(), 5)
|
||||
self.find_best_match_for_name(&path_name, 5)
|
||||
.map_or("".to_string(),
|
||||
|x| format!("`{}`", x))
|
||||
}
|
||||
@ -4509,9 +4508,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
|
||||
self.resolve_error(
|
||||
expr.span,
|
||||
format!("unresolved name `{}`{}",
|
||||
path_name,
|
||||
msg).as_slice());
|
||||
&format!("unresolved name `{}`{}",
|
||||
path_name,
|
||||
msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ fn link_rlib<'a>(sess: &'a Session,
|
||||
// extension to it. This is to work around a bug in LLDB that
|
||||
// would cause it to crash if the name of a file in an archive
|
||||
// was exactly 16 bytes.
|
||||
let bc_filename = obj_filename.with_extension(format!("{}.bc", i).as_slice());
|
||||
let bc_filename = obj_filename.with_extension(&format!("{}.bc", i));
|
||||
let bc_deflated_filename = obj_filename.with_extension(
|
||||
&format!("{}.bytecode.deflate", i)[]);
|
||||
|
||||
@ -1087,8 +1087,8 @@ fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
|
||||
// -force_load is the OSX equivalent of --whole-archive, but it
|
||||
// involves passing the full path to the library to link.
|
||||
let lib = archive::find_library(&l[],
|
||||
sess.target.target.options.staticlib_prefix.as_slice(),
|
||||
sess.target.target.options.staticlib_suffix.as_slice(),
|
||||
&sess.target.target.options.staticlib_prefix,
|
||||
&sess.target.target.options.staticlib_suffix,
|
||||
&search_path[],
|
||||
&sess.diagnostic().handler);
|
||||
let mut v = b"-Wl,-force_load,".to_vec();
|
||||
|
@ -64,7 +64,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
||||
debug!("reading {}", file);
|
||||
for i in iter::count(0us, 1) {
|
||||
let bc_encoded = time(sess.time_passes(),
|
||||
format!("check for {}.{}.bytecode.deflate", name, i).as_slice(),
|
||||
&format!("check for {}.{}.bytecode.deflate", name, i),
|
||||
(),
|
||||
|_| {
|
||||
archive.read(&format!("{}.{}.bytecode.deflate",
|
||||
@ -84,7 +84,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
||||
};
|
||||
|
||||
let bc_decoded = if is_versioned_bytecode_format(bc_encoded) {
|
||||
time(sess.time_passes(), format!("decode {}.{}.bc", file, i).as_slice(), (), |_| {
|
||||
time(sess.time_passes(), &format!("decode {}.{}.bc", file, i), (), |_| {
|
||||
// Read the version
|
||||
let version = extract_bytecode_format_version(bc_encoded);
|
||||
|
||||
@ -108,7 +108,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
||||
}
|
||||
})
|
||||
} else {
|
||||
time(sess.time_passes(), format!("decode {}.{}.bc", file, i).as_slice(), (), |_| {
|
||||
time(sess.time_passes(), &format!("decode {}.{}.bc", file, i), (), |_| {
|
||||
// the object must be in the old, pre-versioning format, so simply
|
||||
// inflate everything and let LLVM decide if it can make sense of it
|
||||
match flate::inflate_bytes(bc_encoded) {
|
||||
|
@ -50,7 +50,7 @@ pub fn llvm_err(handler: &diagnostic::Handler, msg: String) -> ! {
|
||||
handler.fatal(&msg[]);
|
||||
} else {
|
||||
let err = ffi::c_str_to_bytes(&cstr);
|
||||
let err = String::from_utf8_lossy(err.as_slice()).to_string();
|
||||
let err = String::from_utf8_lossy(err).to_string();
|
||||
libc::free(cstr as *mut _);
|
||||
handler.fatal(&format!("{}: {}",
|
||||
&msg[],
|
||||
@ -223,8 +223,8 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
||||
let tm = unsafe {
|
||||
let triple = CString::from_slice(triple.as_bytes());
|
||||
let cpu = match sess.opts.cg.target_cpu {
|
||||
Some(ref s) => s.as_slice(),
|
||||
None => sess.target.target.options.cpu.as_slice()
|
||||
Some(ref s) => &**s,
|
||||
None => &*sess.target.target.options.cpu
|
||||
};
|
||||
let cpu = CString::from_slice(cpu.as_bytes());
|
||||
let features = CString::from_slice(target_feature(sess).as_bytes());
|
||||
@ -375,7 +375,7 @@ unsafe extern "C" fn diagnostic_handler(info: DiagnosticInfoRef, user: *mut c_vo
|
||||
match llvm::diagnostic::Diagnostic::unpack(info) {
|
||||
llvm::diagnostic::InlineAsm(inline) => {
|
||||
report_inline_asm(cgcx,
|
||||
llvm::twine_to_string(inline.message).as_slice(),
|
||||
&*llvm::twine_to_string(inline.message),
|
||||
inline.cookie);
|
||||
}
|
||||
|
||||
@ -390,11 +390,11 @@ unsafe extern "C" fn diagnostic_handler(info: DiagnosticInfoRef, user: *mut c_vo
|
||||
|
||||
if enabled {
|
||||
let loc = llvm::debug_loc_to_string(llcx, opt.debug_loc);
|
||||
cgcx.handler.note(format!("optimization {} for {} at {}: {}",
|
||||
opt.kind.describe(),
|
||||
pass_name,
|
||||
if loc.is_empty() { "[unknown]" } else { loc.as_slice() },
|
||||
llvm::twine_to_string(opt.message)).as_slice());
|
||||
cgcx.handler.note(&format!("optimization {} for {} at {}: {}",
|
||||
opt.kind.describe(),
|
||||
pass_name,
|
||||
if loc.is_empty() { "[unknown]" } else { &*loc },
|
||||
llvm::twine_to_string(opt.message)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -423,7 +423,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
|
||||
|
||||
if config.emit_no_opt_bc {
|
||||
let ext = format!("{}.no-opt.bc", name_extra);
|
||||
let out = output_names.with_extension(ext.as_slice());
|
||||
let out = output_names.with_extension(&ext);
|
||||
let out = CString::from_slice(out.as_vec());
|
||||
llvm::LLVMWriteBitcodeToFile(llmod, out.as_ptr());
|
||||
}
|
||||
@ -455,8 +455,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
|
||||
for pass in &config.passes {
|
||||
let pass = CString::from_slice(pass.as_bytes());
|
||||
if !llvm::LLVMRustAddPass(mpm, pass.as_ptr()) {
|
||||
cgcx.handler.warn(format!("unknown pass {:?}, ignoring",
|
||||
pass).as_slice());
|
||||
cgcx.handler.warn(&format!("unknown pass {:?}, ignoring", pass));
|
||||
}
|
||||
}
|
||||
|
||||
@ -477,7 +476,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
|
||||
|
||||
if config.emit_lto_bc {
|
||||
let name = format!("{}.lto.bc", name_extra);
|
||||
let out = output_names.with_extension(name.as_slice());
|
||||
let out = output_names.with_extension(&name);
|
||||
let out = CString::from_slice(out.as_vec());
|
||||
llvm::LLVMWriteBitcodeToFile(llmod, out.as_ptr());
|
||||
}
|
||||
@ -511,7 +510,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
|
||||
|
||||
if config.emit_bc {
|
||||
let ext = format!("{}.bc", name_extra);
|
||||
let out = output_names.with_extension(ext.as_slice());
|
||||
let out = output_names.with_extension(&ext);
|
||||
let out = CString::from_slice(out.as_vec());
|
||||
llvm::LLVMWriteBitcodeToFile(llmod, out.as_ptr());
|
||||
}
|
||||
@ -519,7 +518,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
|
||||
time(config.time_passes, "codegen passes", (), |()| {
|
||||
if config.emit_ir {
|
||||
let ext = format!("{}.ll", name_extra);
|
||||
let out = output_names.with_extension(ext.as_slice());
|
||||
let out = output_names.with_extension(&ext);
|
||||
let out = CString::from_slice(out.as_vec());
|
||||
with_codegen(tm, llmod, config.no_builtins, |cpm| {
|
||||
llvm::LLVMRustPrintModule(cpm, llmod, out.as_ptr());
|
||||
@ -1013,7 +1012,7 @@ unsafe fn configure_llvm(sess: &Session) {
|
||||
if sess.print_llvm_passes() { add("-debug-pass=Structure"); }
|
||||
|
||||
// FIXME #21627 disable faulty FastISel on AArch64 (even for -O0)
|
||||
if sess.target.target.arch.as_slice() == "aarch64" { add("-fast-isel=0"); }
|
||||
if sess.target.target.arch == "aarch64" { add("-fast-isel=0"); }
|
||||
|
||||
for arg in &sess.opts.cg.llvm_args {
|
||||
add(&(*arg)[]);
|
||||
|
@ -309,7 +309,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
||||
Some(def_id) => {
|
||||
result.push_str(" as ");
|
||||
result.push_str(
|
||||
ty::item_path_str(&self.analysis.ty_cx, def_id).as_slice());
|
||||
&ty::item_path_str(&self.analysis.ty_cx, def_id));
|
||||
},
|
||||
None => {}
|
||||
}
|
||||
@ -643,7 +643,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
||||
item.id);
|
||||
|
||||
for field in &struct_def.fields {
|
||||
self.process_struct_field_def(field, qualname.as_slice(), variant.node.id);
|
||||
self.process_struct_field_def(field, &qualname, variant.node.id);
|
||||
self.visit_ty(&*field.node.ty);
|
||||
}
|
||||
}
|
||||
@ -795,7 +795,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
||||
let def_map = self.analysis.ty_cx.def_map.borrow();
|
||||
if !def_map.contains_key(&id) {
|
||||
self.sess.span_bug(span,
|
||||
format!("def_map has no key for {} in visit_expr", id).as_slice());
|
||||
&format!("def_map has no key for {} in visit_expr", id));
|
||||
}
|
||||
let def = &(*def_map)[id];
|
||||
let sub_span = self.span.span_for_last_ident(span);
|
||||
@ -1117,7 +1117,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
||||
self.fmt.use_glob_str(path.span,
|
||||
sub_span,
|
||||
item.id,
|
||||
name_string.as_slice(),
|
||||
&name_string,
|
||||
self.cur_scope);
|
||||
self.write_sub_paths(path, true);
|
||||
}
|
||||
@ -1200,7 +1200,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
||||
&value[]);
|
||||
|
||||
self.visit_ty(&**ty);
|
||||
self.process_generic_params(ty_params, item.span, qualname.as_slice(), item.id);
|
||||
self.process_generic_params(ty_params, item.span, &qualname, item.id);
|
||||
},
|
||||
ast::ItemMac(_) => (),
|
||||
_ => visit::walk_item(self, item),
|
||||
|
@ -229,8 +229,8 @@ impl<'a> FmtStrs<'a> {
|
||||
|
||||
if !needs_span {
|
||||
self.span.sess.span_bug(span,
|
||||
format!("Called record_with_span for '{}' \
|
||||
which does not require a span", label).as_slice());
|
||||
&format!("Called record_with_span for '{}' \
|
||||
which does not require a span", label));
|
||||
}
|
||||
|
||||
let values_str = match self.make_values_str(label, fields, values, span) {
|
||||
|
@ -1029,8 +1029,8 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
field_vals.len())
|
||||
);
|
||||
let mut vals = field_vals;
|
||||
vals.push_all(vals_left.as_slice());
|
||||
compile_submatch(bcx, pats.as_slice(), vals.as_slice(), chk, has_genuine_default);
|
||||
vals.push_all(&vals_left);
|
||||
compile_submatch(bcx, &pats, &vals, chk, has_genuine_default);
|
||||
return;
|
||||
}
|
||||
_ => ()
|
||||
|
@ -265,9 +265,9 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
// Use the minimum integer type we figured out above
|
||||
let fields : Vec<_> = cases.iter().map(|c| {
|
||||
let mut ftys = vec!(ty_of_inttype(cx.tcx(), min_ity));
|
||||
ftys.push_all(c.tys.as_slice());
|
||||
ftys.push_all(&c.tys);
|
||||
if dtor { ftys.push(cx.tcx().types.bool); }
|
||||
mk_struct(cx, ftys.as_slice(), false, t)
|
||||
mk_struct(cx, &ftys, false, t)
|
||||
}).collect();
|
||||
|
||||
|
||||
@ -283,7 +283,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
// This check is needed to avoid increasing the size of types when
|
||||
// the alignment of the first field is smaller than the overall
|
||||
// alignment of the type.
|
||||
let (_, align) = union_size_and_align(fields.as_slice());
|
||||
let (_, align) = union_size_and_align(&fields);
|
||||
let mut use_align = true;
|
||||
for st in &fields {
|
||||
// Get the first non-zero-sized field
|
||||
|
@ -125,7 +125,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
|
||||
let r = InlineAsmCall(bcx,
|
||||
asm.as_ptr(),
|
||||
constraints.as_ptr(),
|
||||
inputs.as_slice(),
|
||||
&inputs,
|
||||
output_type,
|
||||
ia.volatile,
|
||||
ia.alignstack,
|
||||
|
@ -115,7 +115,7 @@ pub fn with_insn_ctxt<F>(blk: F) where
|
||||
F: FnOnce(&[&'static str]),
|
||||
{
|
||||
TASK_LOCAL_INSN_KEY.with(move |slot| {
|
||||
slot.borrow().as_ref().map(move |s| blk(s.as_slice()));
|
||||
slot.borrow().as_ref().map(move |s| blk(s));
|
||||
})
|
||||
}
|
||||
|
||||
@ -1354,8 +1354,8 @@ fn build_cfg(tcx: &ty::ctxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>)
|
||||
// glue, shims, etc
|
||||
None if id == ast::DUMMY_NODE_ID => return (ast::DUMMY_NODE_ID, None),
|
||||
|
||||
_ => tcx.sess.bug(format!("unexpected variant in has_nested_returns: {}",
|
||||
tcx.map.path_to_string(id)).as_slice())
|
||||
_ => tcx.sess.bug(&format!("unexpected variant in has_nested_returns: {}",
|
||||
tcx.map.path_to_string(id)))
|
||||
};
|
||||
|
||||
(blk.id, Some(cfg::CFG::new(tcx, &**blk)))
|
||||
@ -2247,7 +2247,7 @@ pub fn update_linkage(ccx: &CrateContext,
|
||||
if let Some(id) = id {
|
||||
let item = ccx.tcx().map.get(id);
|
||||
if let ast_map::NodeItem(i) = item {
|
||||
if let Some(name) = attr::first_attr_value_str_by_name(i.attrs.as_slice(), "linkage") {
|
||||
if let Some(name) = attr::first_attr_value_str_by_name(&i.attrs, "linkage") {
|
||||
if let Some(linkage) = llvm_linkage_by_name(name.get()) {
|
||||
llvm::SetLinkage(llval, linkage);
|
||||
} else {
|
||||
@ -2987,10 +2987,10 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &ast::Crate) -> Vec<u8> {
|
||||
let encode_parms = crate_ctxt_to_encode_parms(cx, encode_inlined_item);
|
||||
let metadata = encoder::encode_metadata(encode_parms, krate);
|
||||
let mut compressed = encoder::metadata_encoding_version.to_vec();
|
||||
compressed.push_all(match flate::deflate_bytes(metadata.as_slice()) {
|
||||
compressed.push_all(&match flate::deflate_bytes(&metadata) {
|
||||
Some(compressed) => compressed,
|
||||
None => cx.sess().fatal("failed to compress metadata"),
|
||||
}.as_slice());
|
||||
});
|
||||
let llmeta = C_bytes_in_context(cx.metadata_llcx(), &compressed[]);
|
||||
let llconst = C_struct_in_context(cx.metadata_llcx(), &[llmeta], false);
|
||||
let name = format!("rust_metadata_{}_{}",
|
||||
@ -3062,7 +3062,7 @@ fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet<String>) {
|
||||
let name = ffi::c_str_to_bytes(&llvm::LLVMGetValueName(val))
|
||||
.to_vec();
|
||||
if !declared.contains(&name) &&
|
||||
!reachable.contains(str::from_utf8(name.as_slice()).unwrap()) {
|
||||
!reachable.contains(str::from_utf8(&name).unwrap()) {
|
||||
llvm::SetLinkage(val, llvm::InternalLinkage);
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ fn coerce_to_int(ccx: &CrateContext, size: uint) -> Vec<Type> {
|
||||
|
||||
fn struct_ty(ccx: &CrateContext, ty: Type) -> Type {
|
||||
let size = ty_size(ty) * 8;
|
||||
Type::struct_(ccx, coerce_to_int(ccx, size).as_slice(), false)
|
||||
Type::struct_(ccx, &coerce_to_int(ccx, size), false)
|
||||
}
|
||||
|
||||
pub fn compute_abi_info(ccx: &CrateContext,
|
||||
|
@ -154,7 +154,7 @@ fn coerce_to_int(ccx: &CrateContext, size: uint) -> Vec<Type> {
|
||||
|
||||
fn struct_ty(ccx: &CrateContext, ty: Type) -> Type {
|
||||
let size = ty_size(ty) * 8;
|
||||
Type::struct_(ccx, coerce_to_int(ccx, size).as_slice(), false)
|
||||
Type::struct_(ccx, &coerce_to_int(ccx, size), false)
|
||||
}
|
||||
|
||||
pub fn compute_abi_info(ccx: &CrateContext,
|
||||
|
@ -237,7 +237,7 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
|
||||
unify(cls, ix + off / 8, SSEDs);
|
||||
}
|
||||
Struct => {
|
||||
classify_struct(ty.field_types().as_slice(), cls, ix, off, ty.is_packed());
|
||||
classify_struct(&ty.field_types(), cls, ix, off, ty.is_packed());
|
||||
}
|
||||
Array => {
|
||||
let len = ty.array_length();
|
||||
@ -322,11 +322,11 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
|
||||
let words = (ty_size(ty) + 7) / 8;
|
||||
let mut cls: Vec<_> = repeat(NoClass).take(words).collect();
|
||||
if words > 4 {
|
||||
all_mem(cls.as_mut_slice());
|
||||
all_mem(&mut cls);
|
||||
return cls;
|
||||
}
|
||||
classify(ty, cls.as_mut_slice(), 0, 0);
|
||||
fixup(ty, cls.as_mut_slice());
|
||||
classify(ty, &mut cls, 0, 0);
|
||||
fixup(ty, &mut cls);
|
||||
return cls;
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ fn llreg_ty(ccx: &CrateContext, cls: &[RegClass]) -> Type {
|
||||
// if the type contains only a vector, pass it as that vector.
|
||||
tys[0]
|
||||
} else {
|
||||
Type::struct_(ccx, tys.as_slice(), false)
|
||||
Type::struct_(ccx, &tys, false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,11 +398,11 @@ pub fn compute_abi_info(ccx: &CrateContext,
|
||||
{
|
||||
if !ty.is_reg_ty() {
|
||||
let cls = classify_ty(ty);
|
||||
if is_mem_cls(cls.as_slice()) {
|
||||
if is_mem_cls(&cls) {
|
||||
ArgType::indirect(ty, Some(ind_attr))
|
||||
} else {
|
||||
ArgType::direct(ty,
|
||||
Some(llreg_ty(ccx, cls.as_slice())),
|
||||
Some(llreg_ty(ccx, &cls)),
|
||||
None,
|
||||
None)
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
|
||||
})
|
||||
}
|
||||
ast::ExprVec(ref es) => {
|
||||
const_vec(cx, e, es.as_slice()).0
|
||||
const_vec(cx, e, es).0
|
||||
}
|
||||
ast::ExprRepeat(ref elem, ref count) => {
|
||||
let vec_ty = ty::expr_ty(cx.tcx(), e);
|
||||
|
@ -224,11 +224,11 @@ unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextR
|
||||
let mod_name = CString::from_slice(mod_name.as_bytes());
|
||||
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
|
||||
|
||||
let data_layout = sess.target.target.data_layout.as_slice();
|
||||
let data_layout = &*sess.target.target.data_layout;
|
||||
let data_layout = CString::from_slice(data_layout.as_bytes());
|
||||
llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
|
||||
|
||||
let llvm_target = sess.target.target.llvm_target.as_slice();
|
||||
let llvm_target = &*sess.target.target.llvm_target;
|
||||
let llvm_target = CString::from_slice(llvm_target.as_bytes());
|
||||
llvm::LLVMRustSetNormalizedTarget(llmod, llvm_target.as_ptr());
|
||||
(llcx, llmod)
|
||||
|
@ -1246,7 +1246,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
let (ident, fn_decl, generics, top_level_block, span, has_path) = match fnitem {
|
||||
ast_map::NodeItem(ref item) => {
|
||||
if contains_nodebug_attribute(item.attrs.as_slice()) {
|
||||
if contains_nodebug_attribute(&item.attrs) {
|
||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
|
||||
@ -1263,7 +1263,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
ast_map::NodeImplItem(ref item) => {
|
||||
match **item {
|
||||
ast::MethodImplItem(ref method) => {
|
||||
if contains_nodebug_attribute(method.attrs.as_slice()) {
|
||||
if contains_nodebug_attribute(&method.attrs) {
|
||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
|
||||
@ -1302,7 +1302,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
ast_map::NodeTraitItem(ref trait_method) => {
|
||||
match **trait_method {
|
||||
ast::ProvidedMethod(ref method) => {
|
||||
if contains_nodebug_attribute(method.attrs.as_slice()) {
|
||||
if contains_nodebug_attribute(&method.attrs) {
|
||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
|
||||
@ -1399,7 +1399,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
};
|
||||
|
||||
let scope_map = create_scope_map(cx,
|
||||
fn_decl.inputs.as_slice(),
|
||||
&fn_decl.inputs,
|
||||
&*top_level_block,
|
||||
fn_metadata,
|
||||
fn_ast_id);
|
||||
@ -2483,7 +2483,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
bytes_to_bits(discriminant_size),
|
||||
bytes_to_bits(discriminant_align),
|
||||
create_DIArray(DIB(cx), enumerators_metadata.as_slice()),
|
||||
create_DIArray(DIB(cx), &enumerators_metadata),
|
||||
discriminant_base_type_metadata)
|
||||
};
|
||||
|
||||
@ -3764,7 +3764,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
match optional_length {
|
||||
Some(len) => {
|
||||
output.push_str(format!("; {}", len).as_slice());
|
||||
output.push_str(&format!("; {}", len));
|
||||
}
|
||||
None => { /* nothing to do */ }
|
||||
};
|
||||
@ -4070,11 +4070,10 @@ fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CrateContext)
|
||||
|
||||
fn needs_gdb_debug_scripts_section(ccx: &CrateContext) -> bool {
|
||||
let omit_gdb_pretty_printer_section =
|
||||
attr::contains_name(ccx.tcx()
|
||||
.map
|
||||
.krate()
|
||||
.attrs
|
||||
.as_slice(),
|
||||
attr::contains_name(&ccx.tcx()
|
||||
.map
|
||||
.krate()
|
||||
.attrs,
|
||||
"omit_gdb_pretty_printer_section");
|
||||
|
||||
!omit_gdb_pretty_printer_section &&
|
||||
|
@ -1056,7 +1056,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
if let Some(did) = did {
|
||||
let substs = Substs::new_type(ty_params, vec![]);
|
||||
trans_struct(bcx,
|
||||
fields.as_slice(),
|
||||
&fields,
|
||||
None,
|
||||
expr.span,
|
||||
expr.id,
|
||||
@ -1398,7 +1398,7 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
trans_adt(bcx,
|
||||
ty,
|
||||
discr,
|
||||
numbered_fields.as_slice(),
|
||||
&numbered_fields,
|
||||
optbase,
|
||||
dest,
|
||||
DebugLoc::At(expr_id, expr_span))
|
||||
|
@ -788,7 +788,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
debug!("calling llrustfn = {}, t = {}",
|
||||
ccx.tn().val_to_string(llrustfn), t.repr(ccx.tcx()));
|
||||
let attributes = base::get_fn_llvm_attributes(ccx, t);
|
||||
let llrust_ret_val = builder.call(llrustfn, llrust_args.as_slice(), Some(attributes));
|
||||
let llrust_ret_val = builder.call(llrustfn, &llrust_args, Some(attributes));
|
||||
|
||||
// Get the return value where the foreign fn expects it.
|
||||
let llforeign_ret_ty = match tys.fn_ty.ret_ty.cast {
|
||||
@ -898,7 +898,7 @@ fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
_ => ccx.sess().bug("foreign_types_for_fn_ty called on non-function type")
|
||||
};
|
||||
let fn_sig = ty::erase_late_bound_regions(ccx.tcx(), fn_sig);
|
||||
let llsig = foreign_signature(ccx, &fn_sig, fn_sig.inputs.as_slice());
|
||||
let llsig = foreign_signature(ccx, &fn_sig, &fn_sig.inputs);
|
||||
let fn_ty = cabi::compute_abi_info(ccx,
|
||||
&llsig.llarg_tys[],
|
||||
llsig.llret_ty,
|
||||
@ -911,7 +911,7 @@ fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
ty.repr(ccx.tcx()),
|
||||
ccx.tn().types_to_str(&llsig.llarg_tys[]),
|
||||
ccx.tn().type_to_string(llsig.llret_ty),
|
||||
ccx.tn().types_to_str(fn_ty.arg_tys.iter().map(|t| t.ty).collect::<Vec<_>>().as_slice()),
|
||||
ccx.tn().types_to_str(&fn_ty.arg_tys.iter().map(|t| t.ty).collect::<Vec<_>>()),
|
||||
ccx.tn().type_to_string(fn_ty.ret_ty.ty),
|
||||
llsig.ret_def);
|
||||
|
||||
@ -959,7 +959,7 @@ fn lltype_for_fn_from_foreign_types(ccx: &CrateContext, tys: &ForeignTypes) -> T
|
||||
}
|
||||
|
||||
if tys.fn_sig.variadic {
|
||||
Type::variadic_func(llargument_tys.as_slice(), &llreturn_ty)
|
||||
Type::variadic_func(&llargument_tys, &llreturn_ty)
|
||||
} else {
|
||||
Type::func(&llargument_tys[], &llreturn_ty)
|
||||
}
|
||||
|
@ -118,25 +118,25 @@ pub fn check_intrinsics(ccx: &CrateContext) {
|
||||
if transmute_restriction.original_from != transmute_restriction.substituted_from {
|
||||
ccx.sess().span_err(
|
||||
transmute_restriction.span,
|
||||
format!("transmute called on types with potentially different sizes: \
|
||||
{} (could be {} bit{}) to {} (could be {} bit{})",
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_from),
|
||||
from_type_size as uint,
|
||||
if from_type_size == 1 {""} else {"s"},
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_to),
|
||||
to_type_size as uint,
|
||||
if to_type_size == 1 {""} else {"s"}).as_slice());
|
||||
&format!("transmute called on types with potentially different sizes: \
|
||||
{} (could be {} bit{}) to {} (could be {} bit{})",
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_from),
|
||||
from_type_size as uint,
|
||||
if from_type_size == 1 {""} else {"s"},
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_to),
|
||||
to_type_size as uint,
|
||||
if to_type_size == 1 {""} else {"s"}));
|
||||
} else {
|
||||
ccx.sess().span_err(
|
||||
transmute_restriction.span,
|
||||
format!("transmute called on types with different sizes: \
|
||||
{} ({} bit{}) to {} ({} bit{})",
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_from),
|
||||
from_type_size as uint,
|
||||
if from_type_size == 1 {""} else {"s"},
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_to),
|
||||
to_type_size as uint,
|
||||
if to_type_size == 1 {""} else {"s"}).as_slice());
|
||||
&format!("transmute called on types with different sizes: \
|
||||
{} ({} bit{}) to {} ({} bit{})",
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_from),
|
||||
from_type_size as uint,
|
||||
if from_type_size == 1 {""} else {"s"},
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_to),
|
||||
to_type_size as uint,
|
||||
if to_type_size == 1 {""} else {"s"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -309,7 +309,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
let simple = get_simple_intrinsic(ccx, &*foreign_item);
|
||||
let llval = match (simple, name.get()) {
|
||||
(Some(llfn), _) => {
|
||||
Call(bcx, llfn, llargs.as_slice(), None, call_debug_location)
|
||||
Call(bcx, llfn, &llargs, None, call_debug_location)
|
||||
}
|
||||
(_, "breakpoint") => {
|
||||
let llfn = ccx.get_intrinsic(&("llvm.debugtrap"));
|
||||
|
@ -567,8 +567,8 @@ pub fn trans_object_shim<'a, 'tcx>(
|
||||
data.principal_trait_ref_with_self_ty(tcx, object_ty)
|
||||
}
|
||||
_ => {
|
||||
tcx.sess.bug(format!("trans_object_shim() called on non-object: {}",
|
||||
object_ty.repr(tcx)).as_slice());
|
||||
tcx.sess.bug(&format!("trans_object_shim() called on non-object: {}",
|
||||
object_ty.repr(tcx)));
|
||||
}
|
||||
};
|
||||
|
||||
@ -595,7 +595,7 @@ pub fn trans_object_shim<'a, 'tcx>(
|
||||
let function_name =
|
||||
link::mangle_internal_name_by_type_and_seq(ccx, method_bare_fn_ty, "object_shim");
|
||||
let llfn =
|
||||
decl_internal_rust_fn(ccx, method_bare_fn_ty, function_name.as_slice());
|
||||
decl_internal_rust_fn(ccx, method_bare_fn_ty, &function_name);
|
||||
|
||||
let sig = ty::erase_late_bound_regions(ccx.tcx(), &fty.sig);
|
||||
|
||||
@ -624,11 +624,11 @@ pub fn trans_object_shim<'a, 'tcx>(
|
||||
RustCall => {
|
||||
// unpack the tuple to extract the input type arguments:
|
||||
match sig.inputs[1].sty {
|
||||
ty::ty_tup(ref tys) => tys.as_slice(),
|
||||
ty::ty_tup(ref tys) => &**tys,
|
||||
_ => {
|
||||
bcx.sess().bug(
|
||||
format!("rust-call expects a tuple not {}",
|
||||
sig.inputs[1].repr(tcx)).as_slice());
|
||||
&format!("rust-call expects a tuple not {}",
|
||||
sig.inputs[1].repr(tcx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -673,7 +673,7 @@ pub fn trans_object_shim<'a, 'tcx>(
|
||||
method_bare_fn_ty,
|
||||
method_offset_in_vtable,
|
||||
llobject),
|
||||
ArgVals(llargs.as_slice()),
|
||||
ArgVals(&llargs),
|
||||
dest).bcx;
|
||||
|
||||
finish_fn(&fcx, bcx, sig.output, DebugLoc::None);
|
||||
@ -744,8 +744,8 @@ pub fn get_vtable<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
// an object type; this cannot happen because we
|
||||
// cannot cast an unsized type into a trait object
|
||||
bcx.sess().bug(
|
||||
format!("cannot get vtable for an object type: {}",
|
||||
data.repr(bcx.tcx())).as_slice());
|
||||
&format!("cannot get vtable for an object type: {}",
|
||||
data.repr(bcx.tcx())));
|
||||
}
|
||||
traits::VtableParam(..) => {
|
||||
bcx.sess().bug(
|
||||
|
@ -113,7 +113,7 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let mut atys: Vec<Type> = Vec::new();
|
||||
|
||||
// First, munge the inputs, if this has the `rust-call` ABI.
|
||||
let inputs = untuple_arguments_if_necessary(cx, sig.inputs.as_slice(), abi);
|
||||
let inputs = untuple_arguments_if_necessary(cx, &sig.inputs, abi);
|
||||
|
||||
// Arg 0: Output pointer.
|
||||
// (if the output type is non-immediate)
|
||||
|
@ -272,7 +272,7 @@ pub fn ast_path_substs_for_ty<'tcx>(
|
||||
}
|
||||
};
|
||||
|
||||
prohibit_projections(this.tcx(), assoc_bindings.as_slice());
|
||||
prohibit_projections(this.tcx(), &assoc_bindings);
|
||||
|
||||
create_substs_for_ast_path(this,
|
||||
rscope,
|
||||
@ -656,7 +656,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
|
||||
|
||||
match projections {
|
||||
None => {
|
||||
prohibit_projections(this.tcx(), assoc_bindings.as_slice());
|
||||
prohibit_projections(this.tcx(), &assoc_bindings);
|
||||
}
|
||||
Some(ref mut v) => {
|
||||
for binding in &assoc_bindings {
|
||||
@ -960,7 +960,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
|
||||
|
||||
// FIXME(#20300) -- search where clauses, not bounds
|
||||
suitable_bounds =
|
||||
traits::transitive_bounds(tcx, ty_param_def.bounds.trait_bounds.as_slice())
|
||||
traits::transitive_bounds(tcx, &ty_param_def.bounds.trait_bounds)
|
||||
.filter(|b| trait_defines_associated_type_named(this, b.def_id(), assoc_name))
|
||||
.collect();
|
||||
}
|
||||
@ -1595,11 +1595,11 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx>(
|
||||
let region_bound = compute_region_bound(this,
|
||||
rscope,
|
||||
span,
|
||||
region_bounds.as_slice(),
|
||||
®ion_bounds,
|
||||
principal_trait_ref,
|
||||
builtin_bounds);
|
||||
|
||||
ty::sort_bounds_list(projection_bounds.as_mut_slice());
|
||||
ty::sort_bounds_list(&mut projection_bounds);
|
||||
|
||||
ty::ExistentialBounds {
|
||||
region_bound: region_bound,
|
||||
|
@ -164,7 +164,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
||||
check_pat_enum(pcx, pat, path, subpats, expected);
|
||||
}
|
||||
ast::PatStruct(ref path, ref fields, etc) => {
|
||||
check_pat_struct(pcx, pat, path, fields.as_slice(), etc, expected);
|
||||
check_pat_struct(pcx, pat, path, fields, etc, expected);
|
||||
}
|
||||
ast::PatTup(ref elements) => {
|
||||
let element_tys: Vec<_> =
|
||||
@ -480,7 +480,7 @@ pub fn check_pat_struct<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &'tcx ast::Pat,
|
||||
.unwrap_or_else(|| Substs::empty());
|
||||
|
||||
let struct_fields = ty::struct_fields(tcx, variant_def_id, &item_substs);
|
||||
check_struct_pat_fields(pcx, pat.span, fields, struct_fields.as_slice(),
|
||||
check_struct_pat_fields(pcx, pat.span, fields, &struct_fields,
|
||||
variant_def_id, etc);
|
||||
}
|
||||
|
||||
|
@ -252,10 +252,10 @@ fn confirm_builtin_call<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
|
||||
call_expr.span,
|
||||
expected,
|
||||
fn_sig.output,
|
||||
fn_sig.inputs.as_slice());
|
||||
&fn_sig.inputs);
|
||||
check_argument_types(fcx,
|
||||
call_expr.span,
|
||||
fn_sig.inputs.as_slice(),
|
||||
&fn_sig.inputs,
|
||||
&expected_arg_tys[],
|
||||
arg_exprs,
|
||||
AutorefArgs::No,
|
||||
|
@ -655,9 +655,9 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
|
||||
None => {
|
||||
self.tcx().sess.span_bug(
|
||||
self.span,
|
||||
format!("cannot upcast `{}` to `{}`",
|
||||
source_trait_ref.repr(self.tcx()),
|
||||
target_trait_def_id.repr(self.tcx())).as_slice());
|
||||
&format!("cannot upcast `{}` to `{}`",
|
||||
source_trait_ref.repr(self.tcx()),
|
||||
target_trait_def_id.repr(self.tcx())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
|
||||
})
|
||||
.collect();
|
||||
|
||||
self.elaborate_bounds(bounds.as_slice(), |this, poly_trait_ref, m, method_num| {
|
||||
self.elaborate_bounds(&bounds, |this, poly_trait_ref, m, method_num| {
|
||||
let trait_ref =
|
||||
this.erase_late_bound_regions(&poly_trait_ref);
|
||||
|
||||
|
@ -730,7 +730,7 @@ pub fn check_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
|
||||
check_impl_items_against_trait(ccx,
|
||||
it.span,
|
||||
&*impl_trait_ref,
|
||||
impl_items.as_slice());
|
||||
impl_items);
|
||||
}
|
||||
None => { }
|
||||
}
|
||||
@ -806,7 +806,7 @@ fn check_trait_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
}) {
|
||||
if let Some(ref istring) = attr.value_str() {
|
||||
let parser = Parser::new(istring.get());
|
||||
let types = generics.ty_params.as_slice();
|
||||
let types = &*generics.ty_params;
|
||||
for token in parser {
|
||||
match token {
|
||||
Piece::String(_) => (), // Normal string, no need to check it
|
||||
@ -908,9 +908,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
// caught in resolve.
|
||||
tcx.sess.span_bug(
|
||||
impl_method.span,
|
||||
format!("item `{}` is of a different kind from its trait `{}`",
|
||||
token::get_name(impl_item_ty.name()),
|
||||
impl_trait_ref.repr(tcx)).as_slice());
|
||||
&format!("item `{}` is of a different kind from its trait `{}`",
|
||||
token::get_name(impl_item_ty.name()),
|
||||
impl_trait_ref.repr(tcx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -919,9 +919,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
// caught in resolve.
|
||||
tcx.sess.span_bug(
|
||||
impl_method.span,
|
||||
format!("method `{}` is not a member of trait `{}`",
|
||||
token::get_name(impl_item_ty.name()),
|
||||
impl_trait_ref.repr(tcx)).as_slice());
|
||||
&format!("method `{}` is not a member of trait `{}`",
|
||||
token::get_name(impl_item_ty.name()),
|
||||
impl_trait_ref.repr(tcx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -944,9 +944,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
// already been caught in resolve.
|
||||
tcx.sess.span_bug(
|
||||
typedef.span,
|
||||
format!("item `{}` is of a different kind from its trait `{}`",
|
||||
token::get_name(typedef_ty.name()),
|
||||
impl_trait_ref.repr(tcx)).as_slice());
|
||||
&format!("item `{}` is of a different kind from its trait `{}`",
|
||||
token::get_name(typedef_ty.name()),
|
||||
impl_trait_ref.repr(tcx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -955,11 +955,11 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
// caught in resolve.
|
||||
tcx.sess.span_bug(
|
||||
typedef.span,
|
||||
format!(
|
||||
&format!(
|
||||
"associated type `{}` is not a member of \
|
||||
trait `{}`",
|
||||
token::get_name(typedef_ty.name()),
|
||||
impl_trait_ref.repr(tcx)).as_slice());
|
||||
impl_trait_ref.repr(tcx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3123,7 +3123,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
}
|
||||
if let Some(n) = best {
|
||||
tcx.sess.span_help(field.span,
|
||||
format!("did you mean `{}`?", n).as_slice());
|
||||
&format!("did you mean `{}`?", n));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3734,7 +3734,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
}
|
||||
}
|
||||
ast::ExprMatch(ref discrim, ref arms, match_src) => {
|
||||
_match::check_match(fcx, expr, &**discrim, arms.as_slice(), expected, match_src);
|
||||
_match::check_match(fcx, expr, &**discrim, arms, expected, match_src);
|
||||
}
|
||||
ast::ExprClosure(capture, ref decl, ref body) => {
|
||||
closure::check_expr_closure(fcx, expr, capture, &**decl, &**body, expected);
|
||||
@ -5217,7 +5217,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
|
||||
pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
||||
fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
|
||||
let name = token::intern(format!("P{}", n).as_slice());
|
||||
let name = token::intern(&format!("P{}", n));
|
||||
ty::mk_param(ccx.tcx, subst::FnSpace, n, name)
|
||||
}
|
||||
|
||||
|
@ -153,31 +153,31 @@ pub fn check_object_safety<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
ObjectSafetyViolation::Method(method, MethodViolationCode::ByValueSelf) => {
|
||||
tcx.sess.span_note(
|
||||
span,
|
||||
format!("method `{}` has a receiver type of `Self`, \
|
||||
which cannot be used with a trait object",
|
||||
method.name.user_string(tcx)).as_slice());
|
||||
&format!("method `{}` has a receiver type of `Self`, \
|
||||
which cannot be used with a trait object",
|
||||
method.name.user_string(tcx)));
|
||||
}
|
||||
|
||||
ObjectSafetyViolation::Method(method, MethodViolationCode::StaticMethod) => {
|
||||
tcx.sess.span_note(
|
||||
span,
|
||||
format!("method `{}` has no receiver",
|
||||
method.name.user_string(tcx)).as_slice());
|
||||
&format!("method `{}` has no receiver",
|
||||
method.name.user_string(tcx)));
|
||||
}
|
||||
|
||||
ObjectSafetyViolation::Method(method, MethodViolationCode::ReferencesSelf) => {
|
||||
tcx.sess.span_note(
|
||||
span,
|
||||
format!("method `{}` references the `Self` type \
|
||||
in its arguments or return type",
|
||||
method.name.user_string(tcx)).as_slice());
|
||||
&format!("method `{}` references the `Self` type \
|
||||
in its arguments or return type",
|
||||
method.name.user_string(tcx)));
|
||||
}
|
||||
|
||||
ObjectSafetyViolation::Method(method, MethodViolationCode::Generic) => {
|
||||
tcx.sess.span_note(
|
||||
span,
|
||||
format!("method `{}` has generic type parameters",
|
||||
method.name.user_string(tcx)).as_slice());
|
||||
&format!("method `{}` has generic type parameters",
|
||||
method.name.user_string(tcx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
|
||||
variants.iter().flat_map(|v| v.fields.iter().map(|f| f.ty)).collect();
|
||||
|
||||
regionck::regionck_ensure_component_tys_wf(
|
||||
fcx, item.span, field_tys.as_slice());
|
||||
fcx, item.span, &field_tys);
|
||||
});
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
|
||||
// There are special rules that apply to drop.
|
||||
if
|
||||
fcx.tcx().lang_items.drop_trait() == Some(trait_ref.def_id) &&
|
||||
!attr::contains_name(item.attrs.as_slice(), "unsafe_destructor")
|
||||
!attr::contains_name(&item.attrs, "unsafe_destructor")
|
||||
{
|
||||
match self_ty.sty {
|
||||
ty::ty_struct(def_id, _) |
|
||||
|
@ -94,9 +94,9 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OrphanChecker<'cx, 'tcx> {
|
||||
param_ty.user_string(self.tcx));
|
||||
self.tcx.sess.span_note(
|
||||
item.span,
|
||||
format!("for a limited time, you can add \
|
||||
`#![feature(old_orphan_check)]` to your crate \
|
||||
to disable this rule").as_slice());
|
||||
&format!("for a limited time, you can add \
|
||||
`#![feature(old_orphan_check)]` to your crate \
|
||||
to disable this rule"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,9 +169,9 @@ impl<'a, 'tcx> AstConv<'tcx> for CollectCtxt<'a, 'tcx> {
|
||||
ty_of_foreign_item(self, &*foreign_item, abi)
|
||||
}
|
||||
x => {
|
||||
self.tcx.sess.bug(format!("unexpected sort of node \
|
||||
in get_item_type_scheme(): {:?}",
|
||||
x).as_slice());
|
||||
self.tcx.sess.bug(&format!("unexpected sort of node \
|
||||
in get_item_type_scheme(): {:?}",
|
||||
x));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -562,7 +562,7 @@ fn convert(ccx: &CollectCtxt, it: &ast::Item) {
|
||||
write_ty_to_tcx(tcx, it.id, scheme.ty);
|
||||
get_enum_variant_types(ccx,
|
||||
scheme.ty,
|
||||
enum_definition.variants.as_slice(),
|
||||
&enum_definition.variants,
|
||||
generics);
|
||||
},
|
||||
ast::ItemImpl(_, _,
|
||||
@ -846,7 +846,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
|
||||
ref generics,
|
||||
ref supertraits,
|
||||
ref items) => {
|
||||
(unsafety, generics, supertraits, items.as_slice())
|
||||
(unsafety, generics, supertraits, items)
|
||||
}
|
||||
ref s => {
|
||||
tcx.sess.span_bug(
|
||||
@ -878,7 +878,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
|
||||
|
||||
let bounds = compute_bounds(ccx,
|
||||
self_param_ty.to_ty(ccx.tcx),
|
||||
bounds.as_slice(),
|
||||
bounds,
|
||||
SizedByDefault::No,
|
||||
it.span);
|
||||
|
||||
@ -1136,7 +1136,7 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
|
||||
|
||||
let bounds = compute_bounds(ccx,
|
||||
assoc_ty,
|
||||
assoc_type_def.bounds.as_slice(),
|
||||
&*assoc_type_def.bounds,
|
||||
SizedByDefault::Yes,
|
||||
assoc_type_def.span);
|
||||
|
||||
@ -1448,7 +1448,7 @@ fn conv_param_bounds<'a,'tcx>(ccx: &CollectCtxt<'a,'tcx>,
|
||||
let astconv::PartitionedBounds { builtin_bounds,
|
||||
trait_bounds,
|
||||
region_bounds } =
|
||||
astconv::partition_bounds(ccx.tcx, span, ast_bounds.as_slice());
|
||||
astconv::partition_bounds(ccx.tcx, span, ast_bounds);
|
||||
|
||||
let mut projection_bounds = Vec::new();
|
||||
|
||||
@ -1701,9 +1701,9 @@ fn enforce_impl_ty_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
if ty::has_attr(tcx, impl_def_id, "old_impl_check") {
|
||||
tcx.sess.span_warn(
|
||||
ty_param.span,
|
||||
format!("the type parameter `{}` is not constrained by the \
|
||||
impl trait, self type, or predicates",
|
||||
param_ty.user_string(tcx)).as_slice());
|
||||
&format!("the type parameter `{}` is not constrained by the \
|
||||
impl trait, self type, or predicates",
|
||||
param_ty.user_string(tcx)));
|
||||
} else {
|
||||
span_err!(tcx.sess, ty_param.span, E0207,
|
||||
"the type parameter `{}` is not constrained by the \
|
||||
@ -1711,8 +1711,8 @@ fn enforce_impl_ty_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
param_ty.user_string(tcx));
|
||||
tcx.sess.span_help(
|
||||
ty_param.span,
|
||||
format!("you can temporarily opt out of this rule by placing \
|
||||
the `#[old_impl_check]` attribute on the impl").as_slice());
|
||||
&format!("you can temporarily opt out of this rule by placing \
|
||||
the `#[old_impl_check]` attribute on the impl"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ fn build_struct(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::Stru
|
||||
let fields = ty::lookup_struct_fields(tcx, did);
|
||||
|
||||
clean::Struct {
|
||||
struct_type: match fields.as_slice() {
|
||||
struct_type: match &*fields {
|
||||
[] => doctree::Unit,
|
||||
[ref f] if f.name == unnamed_field.name => doctree::Newtype,
|
||||
[ref f, ..] if f.name == unnamed_field.name => doctree::Tuple,
|
||||
@ -340,7 +340,7 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
|
||||
let polarity = csearch::get_impl_polarity(tcx, did);
|
||||
return Some(clean::Item {
|
||||
inner: clean::ImplItem(clean::Impl {
|
||||
derived: clean::detect_derived(attrs.as_slice()),
|
||||
derived: clean::detect_derived(&attrs),
|
||||
trait_: associated_trait.clean(cx).map(|bound| {
|
||||
match bound {
|
||||
clean::TraitBound(polyt, _) => polyt.trait_,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user